From 50ce95b37d7bbef4d91a43d441e59de9157783ee Mon Sep 17 00:00:00 2001 From: Guo Xiang Tan Date: Mon, 31 Aug 2015 00:11:52 +0800 Subject: [PATCH] FIX: Post age time not being translated correctly. --- app/assets/javascripts/discourse/lib/formatter.js.es6 | 5 ++--- test/javascripts/lib/formatter-test.js.es6 | 2 ++ 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/assets/javascripts/discourse/lib/formatter.js.es6 b/app/assets/javascripts/discourse/lib/formatter.js.es6 index a2cdaefb405..ebb5a8445a3 100644 --- a/app/assets/javascripts/discourse/lib/formatter.js.es6 +++ b/app/assets/javascripts/discourse/lib/formatter.js.es6 @@ -142,13 +142,13 @@ function relativeAgeTiny(date){ case(distanceInMinutes >= 45 && distanceInMinutes <= 89): formatted = t("about_x_hours", {count: 1}); break; - case(distanceInMinutes >= 90 && distanceInMinutes <= 1439): + case(distanceInMinutes >= 90 && distanceInMinutes <= 1409): formatted = t("about_x_hours", {count: Math.round(distanceInMinutes / 60.0)}); break; case(Discourse.SiteSettings.relative_date_duration === 0 && distanceInMinutes <= 525599): formatted = shortDateNoYear(date); break; - case(distanceInMinutes >= 1440 && distanceInMinutes <= 2519): + case(distanceInMinutes >= 1410 && distanceInMinutes <= 2519): formatted = t("x_days", {count: 1}); break; case(distanceInMinutes >= 2520 && distanceInMinutes <= ((Discourse.SiteSettings.relative_date_duration||14) * 1440)): @@ -266,4 +266,3 @@ export function number(val) { } return val.toString(); } - diff --git a/test/javascripts/lib/formatter-test.js.es6 b/test/javascripts/lib/formatter-test.js.es6 index 1774a8c295b..aff28836cb5 100644 --- a/test/javascripts/lib/formatter-test.js.es6 +++ b/test/javascripts/lib/formatter-test.js.es6 @@ -91,6 +91,8 @@ test("formating tiny dates", function() { equal(formatMins(2), "2m"); equal(formatMins(60), "1h"); equal(formatHours(4), "4h"); + equal(formatHours(23), "23h"); + equal(formatHours(23.5), "1d"); equal(formatDays(1), "1d"); equal(formatDays(14), "14d"); equal(formatDays(15), shortDate(15));