Index: chrome/browser/chromeos/gdata/gdata_util_unittest.cc |
diff --git a/chrome/browser/chromeos/gdata/gdata_util_unittest.cc b/chrome/browser/chromeos/gdata/gdata_util_unittest.cc |
index c37df86dcdbb96c0d168d7382a8b48e599c701e7..5a198f7d100996d822b0da1cd9994f7a02c91d7b 100644 |
--- a/chrome/browser/chromeos/gdata/gdata_util_unittest.cc |
+++ b/chrome/browser/chromeos/gdata/gdata_util_unittest.cc |
@@ -6,6 +6,7 @@ |
#include "base/file_path.h" |
#include "base/i18n/time_formatting.h" |
+#include "base/stringprintf.h" |
#include "base/time.h" |
#include "base/utf_string_conversions.h" |
#include "chrome/browser/chromeos/system/timezone_settings.h" |
@@ -14,6 +15,19 @@ |
namespace gdata { |
namespace util { |
+namespace { |
+ |
+// Formats |time|'s UTC representation as "2012-07-16 15:25:13:528". |
+std::string FormatTimeAsUTCString(const base::Time& time) { |
+ base::Time::Exploded exploded; |
+ time.UTCExplode(&exploded); |
+ return base::StringPrintf( |
+ "%04d-%02d-%02d %02d:%02d:%02d.%03d", |
+ exploded.year, exploded.month, exploded.day_of_month, |
+ exploded.hour, exploded.minute, exploded.second, exploded.millisecond); |
+} |
+ |
+} // namespace |
namespace { |
@@ -171,5 +185,11 @@ TEST(GDataUtilTest, GetTimeFromString) { |
FormatTime(test_time)); |
} |
+TEST(GDataUtilTest, FormatTimeAsString) { |
+ base::Time::Exploded exploded_time = {2012, 7, 0, 19, 15, 59, 13, 123}; |
+ base::Time time = base::Time::FromUTCExploded(exploded_time); |
+ EXPECT_EQ("2012-07-19T15:59:13.123Z", FormatTimeAsString(time)); |
+} |
+ |
} // namespace util |
} // namespace gdata |