diff options
Diffstat (limited to 'base/time/time.cc')
-rw-r--r-- | base/time/time.cc | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/base/time/time.cc b/base/time/time.cc index ce25dea..a9e4b1c 100644 --- a/base/time/time.cc +++ b/base/time/time.cc @@ -138,6 +138,19 @@ double Time::ToJsTime() const { kMicrosecondsPerMillisecond); } +int64 Time::ToJavaTime() const { + if (is_null()) { + // Preserve 0 so the invalid result doesn't depend on the platform. + return 0; + } + if (is_max()) { + // Preserve max without offset to prevent overflow. + return std::numeric_limits<int64>::max(); + } + return ((us_ - kTimeTToMicrosecondsOffset) / + kMicrosecondsPerMillisecond); +} + // static Time Time::UnixEpoch() { Time time; |