From 24a48310ffa18a638ca6385afed60cba4bba1f2f Mon Sep 17 00:00:00 2001 From: David Sevilla Martin Date: Sun, 21 Jun 2020 19:07:22 -0400 Subject: [PATCH] convert: common/utils/humanTime --- js/src/common/utils/{humanTime.js => humanTime.ts} | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) rename js/src/common/utils/{humanTime.js => humanTime.ts} (88%) diff --git a/js/src/common/utils/humanTime.js b/js/src/common/utils/humanTime.ts similarity index 88% rename from js/src/common/utils/humanTime.js rename to js/src/common/utils/humanTime.ts index e1529eb1e..79216aa8a 100644 --- a/js/src/common/utils/humanTime.js +++ b/js/src/common/utils/humanTime.ts @@ -1,11 +1,8 @@ /** * The `humanTime` utility converts a date to a localized, human-readable time- * ago string. - * - * @param {Date} time - * @return {String} */ -export default function humanTime(time) { +export default function humanTime(time: Date): string { let d = dayjs(time); const now = dayjs(); @@ -18,7 +15,7 @@ export default function humanTime(time) { const day = 864e5; const diff = d.diff(dayjs()); - let ago = null; + let ago: string; // If this date was more than a month ago, we'll show the name of the month // in the string. If it wasn't this year, we'll show the year as well.