| 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 "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/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 318 string16 TimeFormat::TimeRemainingShort(const TimeDelta& delta) { | 318 string16 TimeFormat::TimeRemainingShort(const TimeDelta& delta) { |
| 319 return FormatTimeImpl(delta, FORMAT_SHORT); | 319 return FormatTimeImpl(delta, FORMAT_SHORT); |
| 320 } | 320 } |
| 321 | 321 |
| 322 // static | 322 // static |
| 323 string16 TimeFormat::RelativeDate( | 323 string16 TimeFormat::RelativeDate( |
| 324 const Time& time, | 324 const Time& time, |
| 325 const Time* optional_midnight_today) { | 325 const Time* optional_midnight_today) { |
| 326 Time midnight_today = optional_midnight_today ? *optional_midnight_today : | 326 Time midnight_today = optional_midnight_today ? *optional_midnight_today : |
| 327 Time::Now().LocalMidnight(); | 327 Time::Now().LocalMidnight(); |
| 328 | 328 TimeDelta day = TimeDelta::FromMicroseconds(Time::kMicrosecondsPerDay); |
| 329 // Filter out "today" and "yesterday" | 329 Time tomorrow = midnight_today + day; |
| 330 if (time >= midnight_today) | 330 Time yesterday = midnight_today - day; |
| 331 if (time >= tomorrow) |
| 332 return string16(); |
| 333 else if (time >= midnight_today) |
| 331 return l10n_util::GetStringUTF16(IDS_PAST_TIME_TODAY); | 334 return l10n_util::GetStringUTF16(IDS_PAST_TIME_TODAY); |
| 332 else if (time >= midnight_today - | 335 else if (time >= yesterday) |
| 333 TimeDelta::FromMicroseconds(Time::kMicrosecondsPerDay)) | |
| 334 return l10n_util::GetStringUTF16(IDS_PAST_TIME_YESTERDAY); | 336 return l10n_util::GetStringUTF16(IDS_PAST_TIME_YESTERDAY); |
| 335 | |
| 336 return string16(); | 337 return string16(); |
| 337 } | 338 } |
| OLD | NEW |