diff --git a/package-lock.json b/package-lock.json index f9b9aa770a..62f7b7d2a3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -24,7 +24,7 @@ "file-saver": "^2.0.5", "js-cookie": "^3.0.5", "lodash": "^4.17.21", - "moment": "^2.30.1", + "luxon": "^3.5.0", "monaco-editor": "^0.44.0", "monaco-yaml": "^5.2.2", "react": "^18.3.1", @@ -11905,6 +11905,15 @@ "node": ">=10" } }, + "node_modules/luxon": { + "version": "3.5.0", + "resolved": "https://registry.npmjs.org/luxon/-/luxon-3.5.0.tgz", + "integrity": "sha512-rh+Zjr6DNfUYR3bPwJEnuwDdqMbxZW7LOQfUN4B54+Cl+0o5zaU9RJ6bcidfDtC1cWCZXQ+nvX8bf6bAji37QQ==", + "license": "MIT", + "engines": { + "node": ">=12" + } + }, "node_modules/magic-string": { "version": "0.25.9", "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.25.9.tgz", @@ -12746,14 +12755,6 @@ "node": ">=10" } }, - "node_modules/moment": { - "version": "2.30.1", - "resolved": "https://registry.npmjs.org/moment/-/moment-2.30.1.tgz", - "integrity": "sha512-uEmtNhbDOrWPFS+hdjFCBfy9f2YoyzRpwcl+DqpC6taX21FzsTLQVbMV/W7PzNSX6x/bhC1zA3c2UQ5NzH6how==", - "engines": { - "node": "*" - } - }, "node_modules/monaco-editor": { "version": "0.44.0", "resolved": "https://registry.npmjs.org/monaco-editor/-/monaco-editor-0.44.0.tgz", diff --git a/package.json b/package.json index f5ed20cb8e..a58a5a70f3 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "file-saver": "^2.0.5", "js-cookie": "^3.0.5", "lodash": "^4.17.21", - "moment": "^2.30.1", + "luxon": "^3.5.0", "monaco-editor": "^0.44.0", "monaco-yaml": "^5.2.2", "react": "^18.3.1", diff --git a/src/components/date-component.tsx b/src/components/date-component.tsx index 2754662fa4..b4d771c7f6 100644 --- a/src/components/date-component.tsx +++ b/src/components/date-component.tsx @@ -1,12 +1,16 @@ -import * as moment from 'moment'; +import { DateTime } from 'luxon'; import React from 'react'; import { Tooltip } from 'src/components'; +import { language as locale } from 'src/l10n'; + +const dateFormat = (date) => + DateTime.fromISO(date, { locale }).toFormat('d MMMM y, HH:mm z'); +const relativeFormat = (date) => + DateTime.fromISO(date, { locale }).toRelative(); export const DateComponent = ({ date }: { date: string }) => date && ( ); diff --git a/src/l10n.ts b/src/l10n.ts index 49b6f6a2b4..6e456ebe0a 100644 --- a/src/l10n.ts +++ b/src/l10n.ts @@ -1,5 +1,4 @@ import { i18n } from '@lingui/core'; -import * as moment from 'moment'; // remember to update lingui.config.js as well export const availableLanguages = [ @@ -12,6 +11,7 @@ export const availableLanguages = [ 'ja', 'zh', ]; + export const languageNames = { en: 'English', es: 'Español', @@ -23,11 +23,6 @@ export const languageNames = { zh: '中文', }; -// map missing moment locales (node_modules/moment/src/locale/.js must exist, except for english) -const momentLocales = { - zh: 'zh-cn', -}; - async function activate(locale: string, pseudolocalization = false) { const { messages } = await import(`src/../locale/${locale}.js`); @@ -45,8 +40,6 @@ async function activate(locale: string, pseudolocalization = false) { i18n.load(locale, messages); i18n.activate(locale); - - moment.locale(momentLocales[locale] || locale); } // Accept-Language