| 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 "chrome/common/time_format.h" | 5 #include "chrome/common/time_format.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/scoped_ptr.h" | 10 #include "base/scoped_ptr.h" |
| 11 #include "base/singleton.h" | 11 #include "base/singleton.h" |
| 12 #include "base/string_util.h" | 12 #include "base/string_util.h" |
| 13 #include "base/time.h" | 13 #include "base/time.h" |
| 14 #include "base/time_format.h" | 14 #include "base/time_format.h" |
| 15 #include "chrome/common/l10n_util.h" | 15 #include "chrome/common/l10n_util.h" |
| 16 #include "chrome/common/stl_util-inl.h" | 16 #include "chrome/common/stl_util-inl.h" |
| 17 #include "generated_resources.h" | 17 #include "generated_resources.h" |
| 18 #include "unicode/datefmt.h" | 18 #include "unicode/datefmt.h" |
| 19 #include "unicode/locid.h" | 19 #include "unicode/locid.h" |
| 20 #include "unicode/plurfmt.h" | 20 #include "unicode/plurfmt.h" |
| 21 #include "unicode/plurrule.h" | 21 #include "unicode/plurrule.h" |
| 22 #include "unicode/smpdtfmt.h" | 22 #include "unicode/smpdtfmt.h" |
| 23 | 23 |
| 24 using base::Time; |
| 25 using base::TimeDelta; |
| 26 |
| 24 class TimeRemainingFormat { | 27 class TimeRemainingFormat { |
| 25 public: | 28 public: |
| 26 const std::vector<PluralFormat*>& formatter(bool short_version) { | 29 const std::vector<PluralFormat*>& formatter(bool short_version) { |
| 27 return short_version ? short_formatter_ : long_formatter_; | 30 return short_version ? short_formatter_ : long_formatter_; |
| 28 } | 31 } |
| 29 private: | 32 private: |
| 30 TimeRemainingFormat() { | 33 TimeRemainingFormat() { |
| 31 BuildFormats(true, &short_formatter_); | 34 BuildFormats(true, &short_formatter_); |
| 32 BuildFormats(false, &long_formatter_); | 35 BuildFormats(false, &long_formatter_); |
| 33 } | 36 } |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 237 // Filter out "today" and "yesterday" | 240 // Filter out "today" and "yesterday" |
| 238 if (time >= midnight_today) | 241 if (time >= midnight_today) |
| 239 return l10n_util::GetString(IDS_PAST_TIME_TODAY); | 242 return l10n_util::GetString(IDS_PAST_TIME_TODAY); |
| 240 else if (time >= midnight_today - | 243 else if (time >= midnight_today - |
| 241 TimeDelta::FromMicroseconds(Time::kMicrosecondsPerDay)) | 244 TimeDelta::FromMicroseconds(Time::kMicrosecondsPerDay)) |
| 242 return l10n_util::GetString(IDS_PAST_TIME_YESTERDAY); | 245 return l10n_util::GetString(IDS_PAST_TIME_YESTERDAY); |
| 243 | 246 |
| 244 return std::wstring(); | 247 return std::wstring(); |
| 245 } | 248 } |
| 246 | 249 |
| OLD | NEW |