From 8faa2973a26818561d316c9eccd136bbf086546f Mon Sep 17 00:00:00 2001 From: "Jannis M. Hoffmann" Date: Wed, 10 Apr 2024 21:04:33 +0200 Subject: fix local datetime calculation --- src/jwebmail/static/src/localtime.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/jwebmail/static') diff --git a/src/jwebmail/static/src/localtime.js b/src/jwebmail/static/src/localtime.js index daa1455..11e42b3 100644 --- a/src/jwebmail/static/src/localtime.js +++ b/src/jwebmail/static/src/localtime.js @@ -1,5 +1,8 @@ +const dtFormat = new Intl.DateTimeFormat(document.documentElement.lang, { + dateStyle: 'short', + timeStyle: 'short', +}); + document.querySelectorAll('time.jwm-tolocaltime').forEach($e => { - const dateTime = new Date($e.dateTime); - $e.innerHTML = new Intl.DateTimeFormat(document.documentElement.lang). - format(dateTime.toLocaleString()); + $e.innerHTML = dtFormat.format(Date.parse($e.dateTime)); }); -- cgit v1.2.3