diff options
author | Iván Ávalos <avalos@disroot.org> | 2021-12-16 22:56:54 -0600 |
---|---|---|
committer | Iván Ávalos <avalos@disroot.org> | 2021-12-16 22:56:54 -0600 |
commit | 6e8b7de0a13ce1a37ea715652ef6e352b842ea30 (patch) | |
tree | e42fce9a145ecdc15b322ed0032c48bd9780bc7d /modern/src/common | |
parent | 26085c61fa72cc0f40d631aa2bbb31a722b7c35f (diff) | |
download | etbsa-traccar-web-6e8b7de0a13ce1a37ea715652ef6e352b842ea30.tar.gz etbsa-traccar-web-6e8b7de0a13ce1a37ea715652ef6e352b842ea30.tar.bz2 etbsa-traccar-web-6e8b7de0a13ce1a37ea715652ef6e352b842ea30.zip |
Dates temporarily translated to 'es' without moment.js, l10n support not implemented yet
Diffstat (limited to 'modern/src/common')
-rw-r--r-- | modern/src/common/formatter.js | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/modern/src/common/formatter.js b/modern/src/common/formatter.js index db0b7ff..f8a55da 100644 --- a/modern/src/common/formatter.js +++ b/modern/src/common/formatter.js @@ -4,9 +4,12 @@ export const formatBoolean = (value, t) => (value ? t('sharedYes') : t('sharedNo export const formatNumber = (value, precision = 1) => Number(value.toFixed(precision)); -export const formatDate = (value, format = 'YYYY-MM-DD HH:mm') => moment(value).format(format); +export const formatDate = (value, locale) => new Intl.DateTimeFormat(locale, { + dateStyle: 'medium', + timeStyle: 'short', +}).format(Date.parse(value)); -export const formatPosition = (value, key, t) => { +export const formatPosition = (value, key, t, locale = 'es') => { if (value != null && typeof value === 'object') { value = value[key]; } @@ -15,7 +18,7 @@ export const formatPosition = (value, key, t) => { case 'deviceTime': case 'serverTime': case 'eventTime': - return moment(value).format('LLL'); + return formatDate(value, locale); case 'latitude': case 'longitude': return value.toFixed(5); |