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

Unified Diff: base/time/time_unittest.cc

Issue 2593073002: base::Time should correctly handle -epoch time values from Javascript (Closed)
Patch Set: Created 4 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/time/time.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/time/time_unittest.cc
diff --git a/base/time/time_unittest.cc b/base/time/time_unittest.cc
index 8906c3bee193e1b876ceb0627a3cc844693fca6a..f25315ff647139634fdd2d93a7430381b5154795 100644
--- a/base/time/time_unittest.cc
+++ b/base/time/time_unittest.cc
@@ -159,6 +159,15 @@ TEST_F(TimeTest, JsTime) {
EXPECT_EQ(700.0003, t.ToDoubleT());
t = Time::FromDoubleT(800.73);
EXPECT_EQ(800730.0, t.ToJsTime());
+
+ // Correctly convert |- epoch offset| which is valid time in javascript.
+ Time minusEpoch = Time::FromJsTime(-11644473600000.0);
+ EXPECT_EQ(-11644473600000, minusEpoch.ToJsTime());
+
+ // Check conversion of boundary javascript time values.
+ // See http://www.ecma-international.org/ecma-262/6.0/#sec-timeclip
+ EXPECT_EQ(-8.46e15, Time::FromJsTime(-8.46e15).ToJsTime());
+ EXPECT_EQ(8.46e15, Time::FromJsTime(8.46e15).ToJsTime());
}
#if defined(OS_POSIX)
« no previous file with comments | « base/time/time.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698