From 90330d30f4d38a727b1056bb9304a37ab96dd291 Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Fri, 20 May 2016 16:06:37 -0400 Subject: [PATCH] FIX: Error in smart short date function --- app/assets/javascripts/discourse/lib/formatter.js.es6 | 6 +++--- test/javascripts/lib/formatter-test.js.es6 | 1 - 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/app/assets/javascripts/discourse/lib/formatter.js.es6 b/app/assets/javascripts/discourse/lib/formatter.js.es6 index 162a8c35a..b9e44bb0f 100644 --- a/app/assets/javascripts/discourse/lib/formatter.js.es6 +++ b/app/assets/javascripts/discourse/lib/formatter.js.es6 @@ -56,8 +56,8 @@ function shortDateNoYear(date) { } // Suppress year if it's this year -export function smartShortDate(date) { - return (date.getFullYear() === new Date().getFullYear()) ? shortDateNoYear(date) : tinyDateYear(date); +export function smartShortDate(date, withYear=tinyDateYear) { + return (date.getFullYear() === new Date().getFullYear()) ? shortDateNoYear(date) : withYear(date); } export function tinyDateYear(date) { @@ -220,7 +220,7 @@ function relativeAgeMedium(date, options) { if (distance < oneMinuteAgo) { displayDate = I18n.t("now"); } else if (distance > fiveDaysAgo) { - displayDate = smartShortDate(date); + displayDate = smartShortDate(date, shortDate); } else { displayDate = relativeAgeMediumSpan(distance, leaveAgo); } diff --git a/test/javascripts/lib/formatter-test.js.es6 b/test/javascripts/lib/formatter-test.js.es6 index 3abbb65e7..158bad969 100644 --- a/test/javascripts/lib/formatter-test.js.es6 +++ b/test/javascripts/lib/formatter-test.js.es6 @@ -80,7 +80,6 @@ test("formating medium length dates", function() { equal(strip(formatDays(8)), shortDate(8)); equal(strip(formatDays(10)), shortDateYear(10)); - }); test("formating tiny dates", function() {