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

Unified Diff: base/time/time.cc

Issue 22791013: Method to convet base::Time to Java timestamp. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added helper method to time Created 7 years, 4 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
« no previous file with comments | « base/time/time.h ('k') | chrome/browser/android/foreign_session_helper.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/time/time.cc
diff --git a/base/time/time.cc b/base/time/time.cc
index 5f495e3f1e57002a33c5b241d9828e8d2884a641..b41941eb1215383c1c1695f116344ca122c9a1f1 100644
--- a/base/time/time.cc
+++ b/base/time/time.cc
@@ -138,6 +138,18 @@ double Time::ToJsTime() const {
kMicrosecondsPerMillisecond);
}
+int64 Time::ToJavaTime() const {
Mark Mentovai 2013/09/20 15:46:25 It looks like, given this and ToJsTime’s equivalen
apiccion 2013/09/20 18:21:48 Thank you! On 2013/09/20 15:46:25, Mark Mentovai
+ if (is_null()) {
+ return 0;
Mark Mentovai 2013/09/20 15:46:25 You seem to have copied this from ToJsTime, but yo
apiccion 2013/09/20 18:21:48 Done.
+ }
+ if (is_max()) {
+ // Preserve max without offset to prevent overflow.
+ return std::numeric_limits<long>::max();
Mark Mentovai 2013/09/20 15:46:25 long is the wrong type here.
apiccion 2013/09/20 18:21:48 Done.
+ }
+ return ((us_ - kTimeTToMicrosecondsOffset) /
+ kMicrosecondsPerMillisecond);
+}
+
// static
Time Time::UnixEpoch() {
Time time;
« no previous file with comments | « base/time/time.h ('k') | chrome/browser/android/foreign_session_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698