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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ppapi/shared_impl/time_conversion.h ('k') | ppapi/thunk/ppb_flash_api.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ppapi/shared_impl/time_conversion.h" 5 #include "ppapi/shared_impl/time_conversion.h"
6 6
7 namespace ppapi { 7 namespace ppapi {
8 8
9 namespace { 9 namespace {
10 10
(...skipping 28 matching lines...) Expand all
39 } 39 }
40 40
41 PP_TimeTicks EventTimeToPPTimeTicks(double event_time) { 41 PP_TimeTicks EventTimeToPPTimeTicks(double event_time) {
42 return event_time + GetTimeToTimeTicksDeltaInSeconds(); 42 return event_time + GetTimeToTimeTicksDeltaInSeconds();
43 } 43 }
44 44
45 double PPTimeTicksToEventTime(PP_TimeTicks t) { 45 double PPTimeTicksToEventTime(PP_TimeTicks t) {
46 return t - GetTimeToTimeTicksDeltaInSeconds(); 46 return t - GetTimeToTimeTicksDeltaInSeconds();
47 } 47 }
48 48
49 double PPGetLocalTimeZoneOffset(const base::Time& time) {
50 // Explode it to local time and then unexplode it as if it were UTC. Also
51 // explode it to UTC and unexplode it (this avoids mismatching rounding or
52 // lack thereof). The time zone offset is their difference.
53 base::Time::Exploded exploded = { 0 };
54 base::Time::Exploded utc_exploded = { 0 };
55 time.LocalExplode(&exploded);
56 time.UTCExplode(&utc_exploded);
57 if (exploded.HasValidValues() && utc_exploded.HasValidValues()) {
58 base::Time adj_time = base::Time::FromUTCExploded(exploded);
59 base::Time cur = base::Time::FromUTCExploded(utc_exploded);
60 return (adj_time - cur).InSecondsF();
61 }
62 return 0.0;
63 }
64
49 } // namespace ppapi 65 } // namespace ppapi
OLDNEW
« 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