OLD | NEW |
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 Loading... |
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 |
OLD | NEW |