diff --git a/package-lock.json b/package-lock.json index cb95a30ac..4ddb2b9de 100644 --- a/package-lock.json +++ b/package-lock.json @@ -24,6 +24,7 @@ "cordova": "13.0.0", "core-js": "^3.45.0", "crypto-js": "^4.2.0", + "dayjs": "^1.11.19", "dompurify": "^3.2.6", "escape-string-regexp": "^5.0.0", "filesize": "^11.0.2", @@ -36,7 +37,6 @@ "markdown-it-github-alerts": "^1.0.0", "markdown-it-task-lists": "^2.1.1", "mime-types": "^3.0.1", - "moment": "^2.30.1", "mustache": "^4.2.0", "picomatch": "^4.0.3", "url-parse": "^1.5.10", @@ -4704,6 +4704,12 @@ "integrity": "sha512-AsElvov3LoNB7tf5k37H2jYSB+ZZPMT5sG2QjJCcdlV5chIv6htBUBUui2IKRjgtKAKtCBN7Zbwa+MtwLjSeNw==", "dev": true }, + "node_modules/dayjs": { + "version": "1.11.19", + "resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.11.19.tgz", + "integrity": "sha512-t5EcLVS6QPBNqM2z8fakk/NKel+Xzshgt8FFKAn+qwlD1pzZWxh0nVCrvFK7ZDb6XucZeF9z8C7CBWTRIVApAw==", + "license": "MIT" + }, "node_modules/debug": { "version": "4.4.1", "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.1.tgz", @@ -6318,15 +6324,6 @@ "node": ">= 18" } }, - "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==", - "license": "MIT", - "engines": { - "node": "*" - } - }, "node_modules/ms": { "version": "2.1.3", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", diff --git a/package.json b/package.json index 094875d7b..a6464f09b 100644 --- a/package.json +++ b/package.json @@ -113,6 +113,7 @@ "cordova": "13.0.0", "core-js": "^3.45.0", "crypto-js": "^4.2.0", + "dayjs": "^1.11.19", "dompurify": "^3.2.6", "escape-string-regexp": "^5.0.0", "filesize": "^11.0.2", @@ -125,7 +126,6 @@ "markdown-it-github-alerts": "^1.0.0", "markdown-it-task-lists": "^2.1.1", "mime-types": "^3.0.1", - "moment": "^2.30.1", "mustache": "^4.2.0", "picomatch": "^4.0.3", "url-parse": "^1.5.10", diff --git a/src/pages/plugin/plugin.view.js b/src/pages/plugin/plugin.view.js index 6ed0b0886..0d012e2b4 100644 --- a/src/pages/plugin/plugin.view.js +++ b/src/pages/plugin/plugin.view.js @@ -1,15 +1,42 @@ import fsOperation from "fileSystem"; import TabView from "components/tabView"; import toast from "components/toast"; +import dayjs from "dayjs/esm"; +import dayjsRelativeTime from "dayjs/esm/plugin/relativeTime"; +import dayjsUpdateLocale from "dayjs/esm/plugin/updateLocale"; +import dayjsUtc from "dayjs/esm/plugin/utc"; import alert from "dialogs/alert"; import DOMPurify from "dompurify"; import Ref from "html-tag-js/ref"; import actionStack from "lib/actionStack"; import constants from "lib/constants"; -import moment from "moment"; import helpers from "utils/helpers"; import Url from "utils/Url"; +dayjs.extend(dayjsRelativeTime); +dayjs.extend(dayjsUtc); +dayjs.extend(dayjsUpdateLocale); + +// Configure dayjs for shorter relative time format +dayjs.updateLocale("en", { + relativeTime: { + future: "in %s", + past: "%s ago", + s: "now", + ss: "now", + m: "1m", + mm: "%dm", + h: "1h", + hh: "%dh", + d: "1d", + dd: "%dd", + M: "1mo", + MM: "%dmo", + y: "1y", + yy: "%dy", + }, +}); + export default (props) => { const { id, @@ -48,32 +75,12 @@ export default (props) => { if (!dateString) return null; try { - // Configure moment for shorter relative time format - moment.updateLocale("en", { - relativeTime: { - future: "in %s", - past: "%s ago", - s: "now", - ss: "now", - m: "1m", - mm: "%dm", - h: "1h", - hh: "%dh", - d: "1d", - dd: "%dd", - M: "1mo", - MM: "%dmo", - y: "1y", - yy: "%dy", - }, - }); - - const updateTime = moment.utc(dateString); + const updateTime = dayjs.utc(dateString); if (!updateTime.isValid()) return null; - return updateTime.fromNow(); + return updateTime.fromNow(true); } catch (error) { - console.warn("Error parsing date with moment:", dateString, error); + console.warn("Error parsing date with dayjs:", dateString, error); return null; } };