| 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 raw_value, "T", base::KEEP_WHITESPACE, base::SPLIT_WANT_NONEMPTY); | 57 raw_value, "T", base::KEEP_WHITESPACE, base::SPLIT_WANT_NONEMPTY); |
| 58 if (parts.size() != 2) | 58 if (parts.size() != 2) |
| 59 return false; | 59 return false; |
| 60 date = parts[0]; | 60 date = parts[0]; |
| 61 time_and_tz = parts[1]; | 61 time_and_tz = parts[1]; |
| 62 } | 62 } |
| 63 | 63 |
| 64 // Parses timezone suffix on the time part if available. | 64 // Parses timezone suffix on the time part if available. |
| 65 { | 65 { |
| 66 std::vector<base::StringPiece> parts; | 66 std::vector<base::StringPiece> parts; |
| 67 if (time_and_tz[time_and_tz.size() - 1] == 'Z') { | 67 if (time_and_tz.back() == 'Z') { |
| 68 // Timezone is 'Z' (UTC) | 68 // Timezone is 'Z' (UTC) |
| 69 has_timezone = true; | 69 has_timezone = true; |
| 70 offset_to_utc_in_minutes = 0; | 70 offset_to_utc_in_minutes = 0; |
| 71 time = time_and_tz; | 71 time = time_and_tz; |
| 72 time.remove_suffix(1); | 72 time.remove_suffix(1); |
| 73 } else { | 73 } else { |
| 74 parts = base::SplitStringPiece( | 74 parts = base::SplitStringPiece( |
| 75 time_and_tz, "+", base::KEEP_WHITESPACE, base::SPLIT_WANT_NONEMPTY); | 75 time_and_tz, "+", base::KEEP_WHITESPACE, base::SPLIT_WANT_NONEMPTY); |
| 76 if (parts.size() == 2) { | 76 if (parts.size() == 2) { |
| 77 // Timezone is "+hh:mm" format | 77 // Timezone is "+hh:mm" format |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 base::Time::Exploded exploded; | 172 base::Time::Exploded exploded; |
| 173 time.LocalExplode(&exploded); | 173 time.LocalExplode(&exploded); |
| 174 return base::StringPrintf( | 174 return base::StringPrintf( |
| 175 "%04d-%02d-%02dT%02d:%02d:%02d.%03d", | 175 "%04d-%02d-%02dT%02d:%02d:%02d.%03d", |
| 176 exploded.year, exploded.month, exploded.day_of_month, | 176 exploded.year, exploded.month, exploded.day_of_month, |
| 177 exploded.hour, exploded.minute, exploded.second, exploded.millisecond); | 177 exploded.hour, exploded.minute, exploded.second, exploded.millisecond); |
| 178 } | 178 } |
| 179 | 179 |
| 180 } // namespace util | 180 } // namespace util |
| 181 } // namespace google_apis | 181 } // namespace google_apis |
| OLD | NEW |