From 2a1a9829d4f0ffc1808e65c13d99e4a7718b54bd Mon Sep 17 00:00:00 2001 From: zihluwang Date: Mon, 15 Sep 2025 19:52:26 +0800 Subject: [PATCH] chore: replace dayjs with moment as date library Moment.js provides more extensive date manipulation features compared to dayjs, which better suits our current requirements for complex date handling. --- package.json | 2 +- pnpm-lock.yaml | 16 ++++++++-------- src/plugin/datetime/index.ts | 23 ----------------------- 3 files changed, 9 insertions(+), 32 deletions(-) delete mode 100644 src/plugin/datetime/index.ts diff --git a/package.json b/package.json index 7cc85a3..84a93fc 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,7 @@ "@reduxjs/toolkit": "^2.9.0", "@tailwindcss/vite": "^4.1.13", "axios": "^1.12.2", - "dayjs": "^1.11.18", + "moment": "^2.30.1", "react": "^19.1.1", "react-dom": "^19.1.1", "react-redux": "^9.2.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index bb038c0..94bae1f 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -17,9 +17,9 @@ importers: axios: specifier: ^1.12.2 version: 1.12.2 - dayjs: - specifier: ^1.11.18 - version: 1.11.18 + moment: + specifier: ^2.30.1 + version: 2.30.1 react: specifier: ^19.1.1 version: 19.1.1 @@ -872,9 +872,6 @@ packages: resolution: {integrity: sha512-BS8PfmtDGnrgYdOonGZQdLZslWIeCGFP9tpan0hi1Co2Zr2NKADsvGYA8XxuG/4UWgJ6Cjtv+YJnB6MM69QGlQ==} engines: {node: '>= 0.4'} - dayjs@1.11.18: - resolution: {integrity: sha512-zFBQ7WFRvVRhKcWoUh+ZA1g2HVgUbsZm9sbddh8EC5iv93sui8DVVz1Npvz+r6meo9VKfa8NyLWBsQK1VvIKPA==} - debug@4.4.3: resolution: {integrity: sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==} engines: {node: '>=6.0'} @@ -1466,6 +1463,9 @@ packages: engines: {node: '>=10'} hasBin: true + moment@2.30.1: + resolution: {integrity: sha512-uEmtNhbDOrWPFS+hdjFCBfy9f2YoyzRpwcl+DqpC6taX21FzsTLQVbMV/W7PzNSX6x/bhC1zA3c2UQ5NzH6how==} + ms@2.1.3: resolution: {integrity: sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==} @@ -2685,8 +2685,6 @@ snapshots: es-errors: 1.3.0 is-data-view: 1.0.2 - dayjs@1.11.18: {} - debug@4.4.3: dependencies: ms: 2.1.3 @@ -3369,6 +3367,8 @@ snapshots: mkdirp@3.0.1: {} + moment@2.30.1: {} + ms@2.1.3: {} nanoid@3.3.11: {} diff --git a/src/plugin/datetime/index.ts b/src/plugin/datetime/index.ts deleted file mode 100644 index fdf3fef..0000000 --- a/src/plugin/datetime/index.ts +++ /dev/null @@ -1,23 +0,0 @@ -import dayjs from "dayjs" -import duration from "dayjs/plugin/duration" - -dayjs.extend(duration) - -/** - * Dayjs with `Duration` plugin. - */ -export default dayjs - -/** - * Formats a given datetime string into a standardised "YYYY-MM-DD HH:mm:ss" format. - * - * This function utilises the [dayjs](https://day.js.org/) library for parsing and formatting. - * - * @param {string} datetime the datetime string to format - * @returns {string} the formatted datetime string in `YYYY-MM-DD HH:mm:ss` format - */ -function formatDatetime (datetime: string): string { - return dayjs(datetime).format("YYYY-MM-DD HH:mm:ss") -} - -export { formatDatetime } \ No newline at end of file