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

Side by Side Diff: ppapi/shared_impl/time_conversion.cc

Issue 2084503008: Make callers of FromUTC(Local)Exploded in ppapi/ use new time API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | 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 PP_Time TimeToPPTime(base::Time t) { return t.ToDoubleT(); } 9 PP_Time TimeToPPTime(base::Time t) { return t.ToDoubleT(); }
10 10
(...skipping 14 matching lines...) Expand all
25 25
26 double PPGetLocalTimeZoneOffset(const base::Time& time) { 26 double PPGetLocalTimeZoneOffset(const base::Time& time) {
27 // Explode it to local time and then unexplode it as if it were UTC. Also 27 // Explode it to local time and then unexplode it as if it were UTC. Also
28 // explode it to UTC and unexplode it (this avoids mismatching rounding or 28 // explode it to UTC and unexplode it (this avoids mismatching rounding or
29 // lack thereof). The time zone offset is their difference. 29 // lack thereof). The time zone offset is their difference.
30 base::Time::Exploded exploded = {0}; 30 base::Time::Exploded exploded = {0};
31 base::Time::Exploded utc_exploded = {0}; 31 base::Time::Exploded utc_exploded = {0};
32 time.LocalExplode(&exploded); 32 time.LocalExplode(&exploded);
33 time.UTCExplode(&utc_exploded); 33 time.UTCExplode(&utc_exploded);
34 if (exploded.HasValidValues() && utc_exploded.HasValidValues()) { 34 if (exploded.HasValidValues() && utc_exploded.HasValidValues()) {
35 base::Time adj_time = base::Time::FromUTCExploded(exploded); 35 base::Time adj_time;
36 base::Time cur = base::Time::FromUTCExploded(utc_exploded); 36 if (base::Time::FromUTCExploded(exploded, &adj_time)) {
37 return (adj_time - cur).InSecondsF(); 37 base::Time cur;
38 if (base::Time::FromUTCExploded(utc_exploded, &cur))
39 return (adj_time - cur).InSecondsF();
40 }
38 } 41 }
39 return 0.0; 42 return 0.0;
40 } 43 }
41 44
42 } // namespace ppapi 45 } // namespace ppapi
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698