Index: ppapi/shared_impl/time_conversion.cc |
diff --git a/ppapi/shared_impl/time_conversion.cc b/ppapi/shared_impl/time_conversion.cc |
index 53d7b99de03b02726c4a28a8c7e2b5de82ff14fd..b14cb7d2b7909ce13cc832f1972d69b9dd815f5d 100644 |
--- a/ppapi/shared_impl/time_conversion.cc |
+++ b/ppapi/shared_impl/time_conversion.cc |
@@ -46,4 +46,20 @@ double PPTimeTicksToEventTime(PP_TimeTicks t) { |
return t - GetTimeToTimeTicksDeltaInSeconds(); |
} |
+double PPGetLocalTimeZoneOffset(const base::Time& time) { |
+ // Explode it to local time and then unexplode it as if it were UTC. Also |
+ // explode it to UTC and unexplode it (this avoids mismatching rounding or |
+ // lack thereof). The time zone offset is their difference. |
+ base::Time::Exploded exploded = { 0 }; |
+ base::Time::Exploded utc_exploded = { 0 }; |
+ time.LocalExplode(&exploded); |
+ time.UTCExplode(&utc_exploded); |
+ if (exploded.HasValidValues() && utc_exploded.HasValidValues()) { |
+ base::Time adj_time = base::Time::FromUTCExploded(exploded); |
+ base::Time cur = base::Time::FromUTCExploded(utc_exploded); |
+ return (adj_time - cur).InSecondsF(); |
+ } |
+ return 0.0; |
+} |
+ |
} // namespace ppapi |