1
0
mirror of https://github.com/flarum/core.git synced 2025-07-16 14:26:25 +02:00

convert: common/utils/humanTime

This commit is contained in:
David Sevilla Martin
2020-06-21 19:07:22 -04:00
committed by Franz Liedke
parent bdb759c558
commit 24a48310ff

View File

@@ -1,11 +1,8 @@
/** /**
* The `humanTime` utility converts a date to a localized, human-readable time- * The `humanTime` utility converts a date to a localized, human-readable time-
* ago string. * ago string.
*
* @param {Date} time
* @return {String}
*/ */
export default function humanTime(time) { export default function humanTime(time: Date): string {
let d = dayjs(time); let d = dayjs(time);
const now = dayjs(); const now = dayjs();
@@ -18,7 +15,7 @@ export default function humanTime(time) {
const day = 864e5; const day = 864e5;
const diff = d.diff(dayjs()); 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 // 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. // in the string. If it wasn't this year, we'll show the year as well.