| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "google_apis/drive/time_util.h" | 5 #include "google_apis/drive/time_util.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 !base::StringToInt(seconds_parts[1], &exploded.millisecond)) { | 136 !base::StringToInt(seconds_parts[1], &exploded.millisecond)) { |
| 137 return false; | 137 return false; |
| 138 } | 138 } |
| 139 } | 139 } |
| 140 | 140 |
| 141 exploded.day_of_week = 0; | 141 exploded.day_of_week = 0; |
| 142 if (!exploded.HasValidValues()) | 142 if (!exploded.HasValidValues()) |
| 143 return false; | 143 return false; |
| 144 | 144 |
| 145 if (has_timezone) { | 145 if (has_timezone) { |
| 146 *parsed_time = base::Time::FromUTCExploded(exploded); | 146 if (!base::Time::FromUTCExploded(exploded, parsed_time)) |
| 147 return false; |
| 147 if (offset_to_utc_in_minutes != 0) | 148 if (offset_to_utc_in_minutes != 0) |
| 148 *parsed_time -= base::TimeDelta::FromMinutes(offset_to_utc_in_minutes); | 149 *parsed_time -= base::TimeDelta::FromMinutes(offset_to_utc_in_minutes); |
| 149 } else { | 150 } else { |
| 150 *parsed_time = base::Time::FromLocalExploded(exploded); | 151 if (!base::Time::FromLocalExploded(exploded, parsed_time)) |
| 152 return false; |
| 151 } | 153 } |
| 152 | 154 |
| 153 return true; | 155 return true; |
| 154 } | 156 } |
| 155 | 157 |
| 156 std::string FormatTimeAsString(const base::Time& time) { | 158 std::string FormatTimeAsString(const base::Time& time) { |
| 157 if (time.is_null()) | 159 if (time.is_null()) |
| 158 return kNullTimeString; | 160 return kNullTimeString; |
| 159 | 161 |
| 160 base::Time::Exploded exploded; | 162 base::Time::Exploded exploded; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 172 base::Time::Exploded exploded; | 174 base::Time::Exploded exploded; |
| 173 time.LocalExplode(&exploded); | 175 time.LocalExplode(&exploded); |
| 174 return base::StringPrintf( | 176 return base::StringPrintf( |
| 175 "%04d-%02d-%02dT%02d:%02d:%02d.%03d", | 177 "%04d-%02d-%02dT%02d:%02d:%02d.%03d", |
| 176 exploded.year, exploded.month, exploded.day_of_month, | 178 exploded.year, exploded.month, exploded.day_of_month, |
| 177 exploded.hour, exploded.minute, exploded.second, exploded.millisecond); | 179 exploded.hour, exploded.minute, exploded.second, exploded.millisecond); |
| 178 } | 180 } |
| 179 | 181 |
| 180 } // namespace util | 182 } // namespace util |
| 181 } // namespace google_apis | 183 } // namespace google_apis |
| OLD | NEW |