OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/google_apis/gdata_util.h" | 5 #include "chrome/browser/google_apis/gdata_util.h" |
6 | 6 |
7 #include "base/i18n/time_formatting.h" | 7 #include "base/i18n/time_formatting.h" |
8 #include "base/time.h" | 8 #include "base/time.h" |
9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
11 | 11 |
12 #if defined(OS_CHROMEOS) | 12 #if defined(OS_CHROMEOS) |
13 #include "chrome/browser/chromeos/system/timezone_settings.h" | 13 #include "chrome/browser/chromeos/system/timezone_settings.h" |
14 #endif // OS_CHROMEOS | 14 #endif // OS_CHROMEOS |
15 | 15 |
16 namespace gdata { | 16 namespace gdata { |
17 namespace util { | 17 namespace util { |
| 18 #if defined(OS_CHROMEOS) |
| 19 // TODO(yoshiki): Find platform independent way to get/set local timezone. |
| 20 // (http://crbug.com/147524). |
18 namespace { | 21 namespace { |
19 | 22 |
20 std::string FormatTime(const base::Time& time) { | 23 std::string FormatTime(const base::Time& time) { |
21 return UTF16ToUTF8(TimeFormatShortDateAndTime(time)); | 24 return UTF16ToUTF8(TimeFormatShortDateAndTime(time)); |
22 } | 25 } |
23 | 26 |
24 } // namespace | 27 } // namespace |
25 | 28 |
26 // TODO(yoshiki): Find platform independent way to get/set local timezone. | |
27 // (http://crbug.com/147524). | |
28 #if defined(OS_CHROMEOS) | |
29 TEST(GDataUtilTest, GetTimeFromStringLocalTimezone) { | 29 TEST(GDataUtilTest, GetTimeFromStringLocalTimezone) { |
30 // Creates time object GMT. | 30 // Creates time object GMT. |
31 base::Time::Exploded exploded = {2012, 7, 0, 14, 1, 3, 21, 151}; | 31 base::Time::Exploded exploded = {2012, 7, 0, 14, 1, 3, 21, 151}; |
32 base::Time target_time = base::Time::FromUTCExploded(exploded); | 32 base::Time target_time = base::Time::FromUTCExploded(exploded); |
33 | 33 |
34 // Creates time object as the local time. | 34 // Creates time object as the local time. |
35 base::Time test_time; | 35 base::Time test_time; |
36 ASSERT_TRUE(GetTimeFromString("2012-07-14T01:03:21.151", &test_time)); | 36 ASSERT_TRUE(GetTimeFromString("2012-07-14T01:03:21.151", &test_time)); |
37 | 37 |
38 // Gets the offset between the local time and GMT. | 38 // Gets the offset between the local time and GMT. |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 #endif // OS_CHROMEOS | 94 #endif // OS_CHROMEOS |
95 | 95 |
96 TEST(GDataUtilTest, FormatTimeAsString) { | 96 TEST(GDataUtilTest, FormatTimeAsString) { |
97 base::Time::Exploded exploded_time = {2012, 7, 0, 19, 15, 59, 13, 123}; | 97 base::Time::Exploded exploded_time = {2012, 7, 0, 19, 15, 59, 13, 123}; |
98 base::Time time = base::Time::FromUTCExploded(exploded_time); | 98 base::Time time = base::Time::FromUTCExploded(exploded_time); |
99 EXPECT_EQ("2012-07-19T15:59:13.123Z", FormatTimeAsString(time)); | 99 EXPECT_EQ("2012-07-19T15:59:13.123Z", FormatTimeAsString(time)); |
100 } | 100 } |
101 | 101 |
102 } // namespace util | 102 } // namespace util |
103 } // namespace gdata | 103 } // namespace gdata |
OLD | NEW |