UX: Use medium format for displaying time in post notices. (#8074)

UX: Use medium format for displaying time in post notices. (#8074)

diff --git a/app/assets/javascripts/discourse/lib/formatter.js.es6 b/app/assets/javascripts/discourse/lib/formatter.js.es6
index 2d5961a..2f71c83 100644
--- a/app/assets/javascripts/discourse/lib/formatter.js.es6
+++ b/app/assets/javascripts/discourse/lib/formatter.js.es6
@@ -262,7 +262,7 @@ function relativeAgeTinyShowsYear(relativeAgeString) {
   return relativeAgeString.match(/'[\d]{2}$/);
 }
 
-function relativeAgeMediumSpan(distance, leaveAgo) {
+export function relativeAgeMediumSpan(distance, leaveAgo) {
   let formatted;
   const distanceInMinutes = Math.round(distance / 60.0);
 
@@ -283,14 +283,24 @@ function relativeAgeMediumSpan(distance, leaveAgo) {
     case distanceInMinutes >= 90 && distanceInMinutes <= 1409:
       formatted = t("x_hours", { count: Math.round(distanceInMinutes / 60.0) });
       break;
-    case distanceInMinutes >= 1410 && distanceInMinutes <= 2159:
+    case distanceInMinutes >= 1410 && distanceInMinutes <= 2519:
       formatted = t("x_days", { count: 1 });
       break;
-    case distanceInMinutes >= 2160:
+    case distanceInMinutes >= 2520 && distanceInMinutes <= 129599:
       formatted = t("x_days", {
         count: Math.round((distanceInMinutes - 720.0) / 1440.0)
       });
       break;
+    case distanceInMinutes >= 129600 && distanceInMinutes <= 525599:
+      formatted = t("x_months", {
+        count: Math.round(distanceInMinutes / 43200.0)
+      });
+      break;
+    default:
+      formatted = t("x_years", {
+        count: Math.round(distanceInMinutes / 525600.0)
+      });
+      break;
   }
   return formatted || "&mdash;";
 }
diff --git a/app/assets/javascripts/discourse/widgets/post.js.es6 b/app/assets/javascripts/discourse/widgets/post.js.es6
index 4138fdb..65f55a9 100644
--- a/app/assets/javascripts/discourse/widgets/post.js.es6
+++ b/app/assets/javascripts/discourse/widgets/post.js.es6
@@ -14,7 +14,7 @@ import {
   formatUsername
 } from "discourse/lib/utilities";
 import hbs from "discourse/widgets/hbs-compiler";
-import { durationTiny } from "discourse/lib/formatter";
+import { relativeAgeMediumSpan } from "discourse/lib/formatter";
 import { prioritizeNameInUx } from "discourse/lib/settings";
 
 function transformWithCallbacks(post) {
@@ -472,7 +472,7 @@ createWidget("post-notice", {
         "p",
         I18n.t("post.notice.returning_user", {
           user,
-          time: durationTiny(distance, { addAgo: true })
+          time: relativeAgeMediumSpan(distance, true)
         })
       );
     }
diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml
index bc0dcbb..eaece65 100644
--- a/config/locales/client.en.yml
+++ b/config/locales/client.en.yml
@@ -124,6 +124,12 @@ en:
         x_days:
           one: "%{count} day ago"
           other: "%{count} days ago"
+        x_months:
+          one: "%{count} month ago"
+          other: "%{count} months ago"
+        x_years:
+          one: "%{count} year ago"
+          other: "%{count} years ago"
       later:
         x_days:
           one: "%{count} day later"
diff --git a/test/javascripts/widgets/post-test.js.es6 b/test/javascripts/widgets/post-test.js.es6
index 3735d10..422e485 100644
--- a/test/javascripts/widgets/post-test.js.es6
+++ b/test/javascripts/widgets/post-test.js.es6
@@ -893,7 +893,7 @@ widgetTest("post notice - with username", {
         .trim(),
       I18n.t("post.notice.returning_user", {
         user: "codinghorror",
-        time: "2d ago"
+        time: "2 days ago"
       })
     );
   }

GitHub sha: 8b2c272f