Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(35)

Side by Side Diff: base/time_unittest.cc

Issue 150097: Convert Linux internal time format to Windows 1601 epoch. (Closed)
Patch Set: Apply mac patch Created 11 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « base/time_posix.cc ('k') | net/base/cookie_monster_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 <time.h> 5 #include <time.h>
6 6
7 #include "base/platform_thread.h" 7 #include "base/platform_thread.h"
8 #include "base/time.h" 8 #include "base/time.h"
9 #include "build/build_config.h" 9 #include "build/build_config.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 TimeDelta::FromMicroseconds(2000)); 133 TimeDelta::FromMicroseconds(2000));
134 EXPECT_EQ(13, TimeDelta::FromDays(13).InDays()); 134 EXPECT_EQ(13, TimeDelta::FromDays(13).InDays());
135 EXPECT_EQ(13, TimeDelta::FromHours(13).InHours()); 135 EXPECT_EQ(13, TimeDelta::FromHours(13).InHours());
136 EXPECT_EQ(13, TimeDelta::FromMinutes(13).InMinutes()); 136 EXPECT_EQ(13, TimeDelta::FromMinutes(13).InMinutes());
137 EXPECT_EQ(13, TimeDelta::FromSeconds(13).InSeconds()); 137 EXPECT_EQ(13, TimeDelta::FromSeconds(13).InSeconds());
138 EXPECT_EQ(13.0, TimeDelta::FromSeconds(13).InSecondsF()); 138 EXPECT_EQ(13.0, TimeDelta::FromSeconds(13).InSecondsF());
139 EXPECT_EQ(13, TimeDelta::FromMilliseconds(13).InMilliseconds()); 139 EXPECT_EQ(13, TimeDelta::FromMilliseconds(13).InMilliseconds());
140 EXPECT_EQ(13.0, TimeDelta::FromMilliseconds(13).InMillisecondsF()); 140 EXPECT_EQ(13.0, TimeDelta::FromMilliseconds(13).InMillisecondsF());
141 EXPECT_EQ(13, TimeDelta::FromMicroseconds(13).InMicroseconds()); 141 EXPECT_EQ(13, TimeDelta::FromMicroseconds(13).InMicroseconds());
142 } 142 }
143
144 #if defined(OS_LINUX) || defined(OS_WINDOWS) // TODO(deanm): Mac.
145 // Our internal time format is serialized in things like databases, so it's
146 // important that it's consistent across all our platforms. We use the 1601
147 // Windows epoch as the internal format across all platforms.
148 TEST(TimeDelta, WindowsEpoch) {
149 Time::Exploded exploded;
150 exploded.year = 1970;
151 exploded.month = 1;
152 exploded.day_of_week = 0; // Should be unusued.
153 exploded.day_of_month = 1;
154 exploded.hour = 0;
155 exploded.minute = 0;
156 exploded.second = 0;
157 exploded.millisecond = 0;
158 Time t = Time::FromUTCExploded(exploded);
159 // Unix 1970 epoch.
160 EXPECT_EQ(GG_INT64_C(11644473600000000), t.ToInternalValue());
161
162 // We can't test 1601 epoch, since the system time functions on Linux
163 // only compute years starting from 1900.
164 }
165 #endif
OLDNEW
« no previous file with comments | « base/time_posix.cc ('k') | net/base/cookie_monster_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698