Chromium Code Reviews| Index: ui/base/l10n/time_format.cc |
| diff --git a/ui/base/l10n/time_format.cc b/ui/base/l10n/time_format.cc |
| index f3b16a3f969ac1115b642550d5146660ce1b7ea3..2d2c43bdbfe65e620965e12e061d203917ccdd25 100644 |
| --- a/ui/base/l10n/time_format.cc |
| +++ b/ui/base/l10n/time_format.cc |
| @@ -294,27 +294,29 @@ base::string16 FormatTimeImpl(const TimeDelta& delta, FormatType format_type) { |
| UErrorCode error = U_ZERO_ERROR; |
| icu::UnicodeString time_string; |
| + const int64 d2i = delta.ToInternalValue(); |
|
bartfab (slow)
2014/01/28 15:16:46
Nit: Wherever possible, we avoid abbreviations. |d
|
| + |
| // Less than a minute gets "X seconds left" |
| - if (delta.ToInternalValue() < Time::kMicrosecondsPerMinute) { |
| - number = static_cast<int>(delta.ToInternalValue() / |
| + if (d2i < Time::kMicrosecondsPerMinute-Time::kMicrosecondsPerSecond/2) { |
|
bartfab (slow)
2014/01/28 15:16:46
1) Here and elsewhere in the file: Add spaces arou
|
| + number = static_cast<int>((d2i+Time::kMicrosecondsPerSecond/2) / |
| Time::kMicrosecondsPerSecond); |
| time_string = formatters[0]->format(number, error); |
| // Less than 1 hour gets "X minutes left". |
| - } else if (delta.ToInternalValue() < Time::kMicrosecondsPerHour) { |
| - number = static_cast<int>(delta.ToInternalValue() / |
| + } else if (d2i < Time::kMicrosecondsPerHour-Time::kMicrosecondsPerMinute/2) { |
| + number = static_cast<int>((d2i+Time::kMicrosecondsPerMinute/2) / |
| Time::kMicrosecondsPerMinute); |
| time_string = formatters[1]->format(number, error); |
| // Less than 1 day remaining gets "X hours left" |
| - } else if (delta.ToInternalValue() < Time::kMicrosecondsPerDay) { |
| - number = static_cast<int>(delta.ToInternalValue() / |
| + } else if (d2i < Time::kMicrosecondsPerDay-Time::kMicrosecondsPerHour/2) { |
| + number = static_cast<int>((d2i+Time::kMicrosecondsPerHour/2) / |
| Time::kMicrosecondsPerHour); |
| time_string = formatters[2]->format(number, error); |
| // Anything bigger gets "X days left" |
| } else { |
| - number = static_cast<int>(delta.ToInternalValue() / |
| + number = static_cast<int>((d2i+Time::kMicrosecondsPerDay/2) / |
| Time::kMicrosecondsPerDay); |
| time_string = formatters[3]->format(number, error); |
| } |