From b48a15cfa3fac3c68bdcb2c400e1008c464d0bbd Mon Sep 17 00:00:00 2001 From: Kailash Nadh Date: Mon, 27 Dec 2021 18:55:13 +0530 Subject: [PATCH] Fix incorrect 'nice date' formatting. Closes #635. --- frontend/src/utils.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/frontend/src/utils.js b/frontend/src/utils.js index 89c3513..2a7652d 100644 --- a/frontend/src/utils.js +++ b/frontend/src/utils.js @@ -32,13 +32,12 @@ export default class Utils { return ''; } - const d = new Date(stamp); - const day = this.i18n.t(`globals.days.${(d.getDay())}`); - const month = this.i18n.t(`globals.months.${(d.getMonth() + 1)}`); - let out = `${day}, ${d.getDate()}`; - out += ` ${month} ${d.getFullYear()}`; + const d = dayjs(stamp); + const day = this.i18n.t(`globals.days.${d.day()}`); + const month = this.i18n.t(`globals.months.${d.month() + 1}`); + let out = d.format(`[${day},] DD [${month}] YYYY`); if (showTime) { - out += ` ${d.getHours()}:${d.getMinutes()}`; + out += d.format(', HH:mm'); } return out;