diff --git a/app/assets/javascripts/discourse/lib/formatter.js.es6 b/app/assets/javascripts/discourse/lib/formatter.js.es6 index 4ef0e9fe352..6e4b7c2a97c 100644 --- a/app/assets/javascripts/discourse/lib/formatter.js.es6 +++ b/app/assets/javascripts/discourse/lib/formatter.js.es6 @@ -132,7 +132,8 @@ function wrapAgo(dateStr) { function relativeAgeTiny(date, ageOpts) { const format = "tiny"; const distance = Math.round((new Date() - date) / 1000); - const distanceInMinutes = Math.round(distance / 60.0); + const dividedDistance = Math.round(distance / 60.0); + const distanceInMinutes = (dividedDistance < 1) ? 1 : dividedDistance; let formatted; const t = function(key, opts) { @@ -140,11 +141,9 @@ function relativeAgeTiny(date, ageOpts) { return (ageOpts && ageOpts.addAgo) ? wrapAgo(result) : result; }; + switch(true) { - case(distanceInMinutes < 1): - formatted = t("less_than_x_minutes", {count: 1}); - break; - case(distanceInMinutes >= 1 && distanceInMinutes <= 44): + case(distanceInMinutes >= 0 && distanceInMinutes <= 44): formatted = t("x_minutes", {count: distanceInMinutes}); break; case(distanceInMinutes >= 45 && distanceInMinutes <= 89): diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml index 2dbc72f55e4..32904cd8c4b 100644 --- a/config/locales/client.en.yml +++ b/config/locales/client.en.yml @@ -74,9 +74,6 @@ en: x_seconds: one: "1s" other: "%{count}s" - less_than_x_minutes: - one: "< 1m" - other: "< %{count}m" x_minutes: one: "1m" other: "%{count}m" diff --git a/test/javascripts/lib/formatter-test.js.es6 b/test/javascripts/lib/formatter-test.js.es6 index 158bad96910..adb11c60ecf 100644 --- a/test/javascripts/lib/formatter-test.js.es6 +++ b/test/javascripts/lib/formatter-test.js.es6 @@ -88,7 +88,8 @@ test("formating tiny dates", function() { }; format = "tiny"; - equal(formatMins(0), "< 1m"); + equal(formatMins(0), "1m"); + equal(formatMins(1), "1m"); equal(formatMins(2), "2m"); equal(formatMins(60), "1h"); equal(formatHours(4), "4h"); @@ -114,7 +115,8 @@ test("formating tiny dates", function() { equal(formatDays(2), shortDate(2)); Discourse.SiteSettings.relative_date_duration = 0; - equal(formatMins(0), "< 1m"); + equal(formatMins(0), "1m"); + equal(formatMins(1), "1m"); equal(formatMins(2), "2m"); equal(formatMins(60), "1h"); equal(formatDays(1), shortDate(1));