| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "base/time.h" | 5 #include "base/time.h" |
| 6 #include "base/string_util.h" | 6 #include "base/string_util.h" |
| 7 #include "base/sys_string_conversions.h" |
| 7 #include "base/third_party/nspr/prtime.h" | 8 #include "base/third_party/nspr/prtime.h" |
| 8 | 9 |
| 9 #include "base/logging.h" | 10 #include "base/logging.h" |
| 10 | 11 |
| 11 namespace base { | 12 namespace base { |
| 12 | 13 |
| 13 // TimeDelta ------------------------------------------------------------------ | 14 // TimeDelta ------------------------------------------------------------------ |
| 14 | 15 |
| 15 int TimeDelta::InDays() const { | 16 int TimeDelta::InDays() const { |
| 16 return static_cast<int>(delta_ / Time::kMicrosecondsPerDay); | 17 return static_cast<int>(delta_ / Time::kMicrosecondsPerDay); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 exploded.hour = 0; | 73 exploded.hour = 0; |
| 73 exploded.minute = 0; | 74 exploded.minute = 0; |
| 74 exploded.second = 0; | 75 exploded.second = 0; |
| 75 exploded.millisecond = 0; | 76 exploded.millisecond = 0; |
| 76 return FromLocalExploded(exploded); | 77 return FromLocalExploded(exploded); |
| 77 } | 78 } |
| 78 | 79 |
| 79 // static | 80 // static |
| 80 bool Time::FromString(const wchar_t* time_string, Time* parsed_time) { | 81 bool Time::FromString(const wchar_t* time_string, Time* parsed_time) { |
| 81 DCHECK((time_string != NULL) && (parsed_time != NULL)); | 82 DCHECK((time_string != NULL) && (parsed_time != NULL)); |
| 82 std::string ascii_time_string = WideToUTF8(time_string); | 83 std::string ascii_time_string = SysWideToUTF8(time_string); |
| 83 if (ascii_time_string.length() == 0) | 84 if (ascii_time_string.length() == 0) |
| 84 return false; | 85 return false; |
| 85 PRTime result_time = 0; | 86 PRTime result_time = 0; |
| 86 PRStatus result = PR_ParseTimeString(ascii_time_string.c_str(), PR_FALSE, | 87 PRStatus result = PR_ParseTimeString(ascii_time_string.c_str(), PR_FALSE, |
| 87 &result_time); | 88 &result_time); |
| 88 if (PR_SUCCESS != result) | 89 if (PR_SUCCESS != result) |
| 89 return false; | 90 return false; |
| 90 result_time += kTimeTToMicrosecondsOffset; | 91 result_time += kTimeTToMicrosecondsOffset; |
| 91 *parsed_time = Time(result_time); | 92 *parsed_time = Time(result_time); |
| 92 return true; | 93 return true; |
| 93 } | 94 } |
| 94 | 95 |
| 95 } // namespace base | 96 } // namespace base |
| OLD | NEW |