Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(963)

Issue 143633003: Fix rounding of time interval strings (Closed)

Created:
6 years, 10 months ago by Thiemo Nagel
Modified:
6 years, 10 months ago
CC:
chromium-reviews, jshin+watch_chromium.org, bartfab (slow)
Base URL:
https://chromium.googlesource.com/chromium/src.git@master
Visibility:
Public.

Description

Fix rounding of time interval strings Previously, text output for time intervals always was rounded down. For example, a time interval of 1 min 59 sec was displayed as "1 min", which was confusing users in some cases. This CL implements rounding to nearest integer. Some example outputs are given below. 0.49 sec --> "0 secs" 0.5 sec --> "1 sec" 59.4 sec --> "59 secs" 59.5 sec --> "1 min" 89.9 sec --> "1 min" 90.0 sec --> "2 mins" 59 min --> "59 mins" 60 min --> "1 hour" 89 min --> "1 hour" 90 min --> "2 hours" ... BUG=338631 TEST=unit tests updated Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=247948

Patch Set 1 #

Total comments: 4

Patch Set 2 : Addressing (most of) Bartosz' concerns #

Total comments: 18

Patch Set 3 : Re-formatted code according to Bartosz' suggestions #

Total comments: 2
Unified diffs Side-by-side diffs Delta from patch set Stats (+52 lines, -42 lines) Patch
M ui/base/l10n/time_format.cc View 1 2 1 chunk +32 lines, -25 lines 1 comment Download
M ui/base/l10n/time_format_unittest.cc View 1 2 1 chunk +20 lines, -17 lines 1 comment Download

Messages

Total messages: 10 (0 generated)
Thiemo Nagel
Hi Jungshik, could you please be so kind to take a look at this CL? ...
6 years, 10 months ago (2014-01-28 15:03:52 UTC) #1
bartfab (slow)
https://codereview.chromium.org/143633003/diff/1/ui/base/l10n/time_format.cc File ui/base/l10n/time_format.cc (right): https://codereview.chromium.org/143633003/diff/1/ui/base/l10n/time_format.cc#newcode297 ui/base/l10n/time_format.cc:297: const int64 d2i = delta.ToInternalValue(); Nit: Wherever possible, we ...
6 years, 10 months ago (2014-01-28 15:16:46 UTC) #2
Thiemo Nagel
Updated taking into account Bartosz' comments. https://codereview.chromium.org/143633003/diff/1/ui/base/l10n/time_format_unittest.cc File ui/base/l10n/time_format_unittest.cc (right): https://codereview.chromium.org/143633003/diff/1/ui/base/l10n/time_format_unittest.cc#newcode32 ui/base/l10n/time_format_unittest.cc:32: const TimeDelta min ...
6 years, 10 months ago (2014-01-28 16:08:58 UTC) #3
bartfab (slow)
https://codereview.chromium.org/143633003/diff/20001/ui/base/l10n/time_format.cc File ui/base/l10n/time_format.cc (right): https://codereview.chromium.org/143633003/diff/20001/ui/base/l10n/time_format.cc#newcode285 ui/base/l10n/time_format.cc:285: if (delta < TimeDelta::FromSeconds(0)) { Nit: The TimeDelta() constructor ...
6 years, 10 months ago (2014-01-29 15:40:12 UTC) #4
Thiemo Nagel
Hi Bartosz, thank you for your comments! Could you please be so kind to take ...
6 years, 10 months ago (2014-01-29 17:40:12 UTC) #5
jungshik at Google
LGTM I'm with bartfab about the name scheme for constants (kOneMinute, etc), but it's not ...
6 years, 10 months ago (2014-01-29 22:43:59 UTC) #6
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/tnagel@chromium.org/143633003/40001
6 years, 10 months ago (2014-01-30 09:35:07 UTC) #7
Thiemo Nagel
On 2014/01/29 22:43:59, Jungshik Shin wrote: > I'm with bartfab about the name scheme for ...
6 years, 10 months ago (2014-01-30 09:39:46 UTC) #8
commit-bot: I haz the power
Change committed as 247948
6 years, 10 months ago (2014-01-30 13:39:38 UTC) #9
bartfab (slow)
6 years, 10 months ago (2014-01-31 13:17:09 UTC) #10
Message was sent while issue was closed.
https://codereview.chromium.org/143633003/diff/40001/ui/base/l10n/time_format.cc
File ui/base/l10n/time_format.cc (right):

https://codereview.chromium.org/143633003/diff/40001/ui/base/l10n/time_format...
ui/base/l10n/time_format.cc:308: const int seconds = static_cast<int>((delta +
half_second).InSeconds());
Nit: Is the cast needed? Will the compiler not implictly cast from int64 to int
for you?

https://codereview.chromium.org/143633003/diff/40001/ui/base/l10n/time_format...
File ui/base/l10n/time_format_unittest.cc (right):

https://codereview.chromium.org/143633003/diff/40001/ui/base/l10n/time_format...
ui/base/l10n/time_format_unittest.cc:42: TestTimeFormats(1 * one_second + 499 *
one_millisecond, "1 sec");
Nit: Is there much point in doing "1 *"? Does it makes things clearer in your
opinion? I think I would just leave out the "1 *".

Powered by Google App Engine
This is Rietveld 408576698