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

Unified Diff: ppapi/shared_impl/time_conversion.cc

Issue 11516020: Refactor PPB_Flash GetLocalTimeZoneOffset to the new PPAPI resource model (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 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 | « ppapi/shared_impl/time_conversion.h ('k') | ppapi/thunk/ppb_flash_api.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « ppapi/shared_impl/time_conversion.h ('k') | ppapi/thunk/ppb_flash_api.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698