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