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

Unified Diff: base/time_unittest.cc

Issue 10536061: Add Javascript time methods to base::Time. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 6 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 side-by-side diff with in-line comments
Download patch
« base/time.cc ('K') | « base/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_unittest.cc
diff --git a/base/time_unittest.cc b/base/time_unittest.cc
index cb1f839b5baa6adabcdd6bd4a6d66659b8d080aa..f89fc8bee3831f6c43125b61d57a021dd027f4aa 100644
--- a/base/time_unittest.cc
+++ b/base/time_unittest.cc
@@ -88,6 +88,16 @@ TEST_F(TimeTest, TimeT) {
EXPECT_EQ(0, Time::FromTimeT(0).ToInternalValue());
}
+// Test conversions to/from javascript time.
+TEST_F(TimeTest, JsTime) {
+ Time epoch = Time::FromJsTime(0.0);
+ EXPECT_EQ(epoch, Time::UnixEpoch());
+ Time t = Time::FromJsTime(700000.3);
+ EXPECT_EQ(700.0003, t.ToDoubleT());
+ t = Time::FromDoubleT(800.73);
+ EXPECT_EQ(800730.0, t.ToJsTime());
+}
+
TEST_F(TimeTest, FromExplodedWithMilliseconds) {
// Some platform implementations of FromExploded are liable to drop
// milliseconds if we aren't careful.
« base/time.cc ('K') | « base/time.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698