From d3fea106fc9bb07c2355a09fc2a462d192b47f49 Mon Sep 17 00:00:00 2001 From: Guo Xiang Tan Date: Mon, 31 Aug 2015 00:14:57 +0800 Subject: [PATCH] FIX: Update relativeAgeMedium to be consistent with relativeAgeTiny. --- app/assets/javascripts/discourse/lib/formatter.js.es6 | 4 ++-- test/javascripts/lib/formatter-test.js.es6 | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/app/assets/javascripts/discourse/lib/formatter.js.es6 b/app/assets/javascripts/discourse/lib/formatter.js.es6 index ebb5a8445..0dfd09fb8 100644 --- a/app/assets/javascripts/discourse/lib/formatter.js.es6 +++ b/app/assets/javascripts/discourse/lib/formatter.js.es6 @@ -189,10 +189,10 @@ function relativeAgeMediumSpan(distance, leaveAgo) { case(distanceInMinutes >= 56 && distanceInMinutes <= 89): formatted = t("x_hours", {count: 1}); break; - case(distanceInMinutes >= 90 && distanceInMinutes <= 1379): + case(distanceInMinutes >= 90 && distanceInMinutes <= 1409): formatted = t("x_hours", {count: Math.round(distanceInMinutes / 60.0)}); break; - case(distanceInMinutes >= 1380 && distanceInMinutes <= 2159): + case(distanceInMinutes >= 1410 && distanceInMinutes <= 2159): formatted = t("x_days", {count: 1}); break; case(distanceInMinutes >= 2160): diff --git a/test/javascripts/lib/formatter-test.js.es6 b/test/javascripts/lib/formatter-test.js.es6 index aff28836c..3abbb65e7 100644 --- a/test/javascripts/lib/formatter-test.js.es6 +++ b/test/javascripts/lib/formatter-test.js.es6 @@ -52,7 +52,8 @@ test("formating medium length dates", function() { equal(strip(formatMins(56)), "1 hour ago"); equal(strip(formatHours(4)), "4 hours ago"); equal(strip(formatHours(22)), "22 hours ago"); - equal(strip(formatHours(23)), "1 day ago"); + equal(strip(formatHours(23)), "23 hours ago"); + equal(strip(formatHours(23.5)), "1 day ago"); equal(strip(formatDays(4.85)), "4 days ago"); leaveAgo = false; @@ -63,7 +64,8 @@ test("formating medium length dates", function() { equal(strip(formatMins(56)), "1 hour"); equal(strip(formatHours(4)), "4 hours"); equal(strip(formatHours(22)), "22 hours"); - equal(strip(formatHours(23)), "1 day"); + equal(strip(formatHours(23)), "23 hours"); + equal(strip(formatHours(23.5)), "1 day"); equal(strip(formatDays(4.85)), "4 days"); equal(strip(formatDays(6)), shortDate(6));