replacing third-party datetime formatter with internal formatter

This commit is contained in:
MaysWind
2025-08-25 23:33:49 +08:00
parent 0b48502a10
commit 23ffdbb163
7 changed files with 276 additions and 169 deletions
+12 -1
View File
@@ -7,13 +7,24 @@ export interface DateTime {
getGregorianCalendarQuarter(): number;
getLocalizedCalendarQuarter(): number;
getGregorianCalendarMonth(): number;
getGregorianCalendarMonthName(): string;
getGregorianCalendarMonthDisplayName(): string;
getGregorianCalendarMonthDisplayShortName(): string;
getLocalizedCalendarMonth(): number;
getLocalizedCalendarMonthDisplayName(): string;
getLocalizedCalendarMonthDisplayShortName(): string;
getGregorianCalendarDay(): number;
getLocalizedCalendarDay(): number;
getGregorianCalendarYearDashMonthDashDay(): TextualYearMonthDay;
getGregorianCalendarYearDashMonth(): TextualYearMonth;
getWeekDay(): WeekDay;
getWeekDayDisplayName(): string
getWeekDayDisplayShortName(): string;
getWeekDayDisplayMinName(): string;
getHour(): number;
getMinute(): number;
getSecond(): number;
getDisplayAMPM(): string;
getTimezoneUtcOffsetMinutes(): number;
toGregorianCalendarYearMonthDay(): YearMonthDay;
toGregorianCalendarYear0BasedMonth(): Year0BasedMonth;
format(format: string): string;
+144 -144
View File
@@ -199,15 +199,15 @@
"expected": {
"January 1": {
"unixTime": 1640995200,
"unixTimeISO": "2022-01-01T00:00:00Z"
"unixTimeISO": "2022-01-01T00:00:00+00:00"
},
"April 1": {
"unixTime": 1617235200,
"unixTimeISO": "2021-04-01T00:00:00Z"
"unixTimeISO": "2021-04-01T00:00:00+00:00"
},
"October 1": {
"unixTime": 1633046400,
"unixTimeISO": "2021-10-01T00:00:00Z"
"unixTimeISO": "2021-10-01T00:00:00+00:00"
}
}
},
@@ -216,15 +216,15 @@
"expected": {
"January 1": {
"unixTime": 1640995200,
"unixTimeISO": "2022-01-01T00:00:00Z"
"unixTimeISO": "2022-01-01T00:00:00+00:00"
},
"April 1": {
"unixTime": 1617235200,
"unixTimeISO": "2021-04-01T00:00:00Z"
"unixTimeISO": "2021-04-01T00:00:00+00:00"
},
"October 1": {
"unixTime": 1633046400,
"unixTimeISO": "2021-10-01T00:00:00Z"
"unixTimeISO": "2021-10-01T00:00:00+00:00"
}
}
},
@@ -233,15 +233,15 @@
"expected": {
"January 1": {
"unixTime": 1640995200,
"unixTimeISO": "2022-01-01T00:00:00Z"
"unixTimeISO": "2022-01-01T00:00:00+00:00"
},
"April 1": {
"unixTime": 1648771200,
"unixTimeISO": "2022-04-01T00:00:00Z"
"unixTimeISO": "2022-04-01T00:00:00+00:00"
},
"October 1": {
"unixTime": 1633046400,
"unixTimeISO": "2021-10-01T00:00:00Z"
"unixTimeISO": "2021-10-01T00:00:00+00:00"
}
}
},
@@ -250,15 +250,15 @@
"expected": {
"January 1": {
"unixTime": 1640995200,
"unixTimeISO": "2022-01-01T00:00:00Z"
"unixTimeISO": "2022-01-01T00:00:00+00:00"
},
"April 1": {
"unixTime": 1648771200,
"unixTimeISO": "2022-04-01T00:00:00Z"
"unixTimeISO": "2022-04-01T00:00:00+00:00"
},
"October 1": {
"unixTime": 1633046400,
"unixTimeISO": "2021-10-01T00:00:00Z"
"unixTimeISO": "2021-10-01T00:00:00+00:00"
}
}
},
@@ -267,15 +267,15 @@
"expected": {
"January 1": {
"unixTime": 1640995200,
"unixTimeISO": "2022-01-01T00:00:00Z"
"unixTimeISO": "2022-01-01T00:00:00+00:00"
},
"April 1": {
"unixTime": 1648771200,
"unixTimeISO": "2022-04-01T00:00:00Z"
"unixTimeISO": "2022-04-01T00:00:00+00:00"
},
"October 1": {
"unixTime": 1664582400,
"unixTimeISO": "2022-10-01T00:00:00Z"
"unixTimeISO": "2022-10-01T00:00:00+00:00"
}
}
},
@@ -284,15 +284,15 @@
"expected": {
"January 1": {
"unixTime": 1640995200,
"unixTimeISO": "2022-01-01T00:00:00Z"
"unixTimeISO": "2022-01-01T00:00:00+00:00"
},
"April 1": {
"unixTime": 1648771200,
"unixTimeISO": "2022-04-01T00:00:00Z"
"unixTimeISO": "2022-04-01T00:00:00+00:00"
},
"October 1": {
"unixTime": 1664582400,
"unixTimeISO": "2022-10-01T00:00:00Z"
"unixTimeISO": "2022-10-01T00:00:00+00:00"
}
}
},
@@ -301,15 +301,15 @@
"expected": {
"January 1": {
"unixTime": 1672531200,
"unixTimeISO": "2023-01-01T00:00:00Z"
"unixTimeISO": "2023-01-01T00:00:00+00:00"
},
"April 1": {
"unixTime": 1648771200,
"unixTimeISO": "2022-04-01T00:00:00Z"
"unixTimeISO": "2022-04-01T00:00:00+00:00"
},
"October 1": {
"unixTime": 1664582400,
"unixTimeISO": "2022-10-01T00:00:00Z"
"unixTimeISO": "2022-10-01T00:00:00+00:00"
}
}
},
@@ -318,15 +318,15 @@
"expected": {
"January 1": {
"unixTime": 1672531200,
"unixTimeISO": "2023-01-01T00:00:00Z"
"unixTimeISO": "2023-01-01T00:00:00+00:00"
},
"April 1": {
"unixTime": 1648771200,
"unixTimeISO": "2022-04-01T00:00:00Z"
"unixTimeISO": "2022-04-01T00:00:00+00:00"
},
"October 1": {
"unixTime": 1664582400,
"unixTimeISO": "2022-10-01T00:00:00Z"
"unixTimeISO": "2022-10-01T00:00:00+00:00"
}
}
},
@@ -335,15 +335,15 @@
"expected": {
"January 1": {
"unixTime": 1672531200,
"unixTimeISO": "2023-01-01T00:00:00Z"
"unixTimeISO": "2023-01-01T00:00:00+00:00"
},
"April 1": {
"unixTime": 1680307200,
"unixTimeISO": "2023-04-01T00:00:00Z"
"unixTimeISO": "2023-04-01T00:00:00+00:00"
},
"October 1": {
"unixTime": 1664582400,
"unixTimeISO": "2022-10-01T00:00:00Z"
"unixTimeISO": "2022-10-01T00:00:00+00:00"
}
}
},
@@ -352,15 +352,15 @@
"expected": {
"January 1": {
"unixTime": 1672531200,
"unixTimeISO": "2023-01-01T00:00:00Z"
"unixTimeISO": "2023-01-01T00:00:00+00:00"
},
"April 1": {
"unixTime": 1680307200,
"unixTimeISO": "2023-04-01T00:00:00Z"
"unixTimeISO": "2023-04-01T00:00:00+00:00"
},
"October 1": {
"unixTime": 1664582400,
"unixTimeISO": "2022-10-01T00:00:00Z"
"unixTimeISO": "2022-10-01T00:00:00+00:00"
}
}
},
@@ -369,15 +369,15 @@
"expected": {
"January 1": {
"unixTime": 1672531200,
"unixTimeISO": "2023-01-01T00:00:00Z"
"unixTimeISO": "2023-01-01T00:00:00+00:00"
},
"April 1": {
"unixTime": 1680307200,
"unixTimeISO": "2023-04-01T00:00:00Z"
"unixTimeISO": "2023-04-01T00:00:00+00:00"
},
"October 1": {
"unixTime": 1696118400,
"unixTimeISO": "2023-10-01T00:00:00Z"
"unixTimeISO": "2023-10-01T00:00:00+00:00"
}
}
},
@@ -386,15 +386,15 @@
"expected": {
"January 1": {
"unixTime": 1672531200,
"unixTimeISO": "2023-01-01T00:00:00Z"
"unixTimeISO": "2023-01-01T00:00:00+00:00"
},
"April 1": {
"unixTime": 1680307200,
"unixTimeISO": "2023-04-01T00:00:00Z"
"unixTimeISO": "2023-04-01T00:00:00+00:00"
},
"October 1": {
"unixTime": 1696118400,
"unixTimeISO": "2023-10-01T00:00:00Z"
"unixTimeISO": "2023-10-01T00:00:00+00:00"
}
}
},
@@ -403,15 +403,15 @@
"expected": {
"January 1": {
"unixTime": 1704067200,
"unixTimeISO": "2024-01-01T00:00:00Z"
"unixTimeISO": "2024-01-01T00:00:00+00:00"
},
"April 1": {
"unixTime": 1680307200,
"unixTimeISO": "2023-04-01T00:00:00Z"
"unixTimeISO": "2023-04-01T00:00:00+00:00"
},
"October 1": {
"unixTime": 1696118400,
"unixTimeISO": "2023-10-01T00:00:00Z"
"unixTimeISO": "2023-10-01T00:00:00+00:00"
}
}
},
@@ -420,15 +420,15 @@
"expected": {
"January 1": {
"unixTime": 1704067200,
"unixTimeISO": "2024-01-01T00:00:00Z"
"unixTimeISO": "2024-01-01T00:00:00+00:00"
},
"April 1": {
"unixTime": 1680307200,
"unixTimeISO": "2023-04-01T00:00:00Z"
"unixTimeISO": "2023-04-01T00:00:00+00:00"
},
"October 1": {
"unixTime": 1696118400,
"unixTimeISO": "2023-10-01T00:00:00Z"
"unixTimeISO": "2023-10-01T00:00:00+00:00"
}
}
},
@@ -437,15 +437,15 @@
"expected": {
"January 1": {
"unixTime": 1704067200,
"unixTimeISO": "2024-01-01T00:00:00Z"
"unixTimeISO": "2024-01-01T00:00:00+00:00"
},
"April 1": {
"unixTime": 1711929600,
"unixTimeISO": "2024-04-01T00:00:00Z"
"unixTimeISO": "2024-04-01T00:00:00+00:00"
},
"October 1": {
"unixTime": 1696118400,
"unixTimeISO": "2023-10-01T00:00:00Z"
"unixTimeISO": "2023-10-01T00:00:00+00:00"
}
}
},
@@ -454,15 +454,15 @@
"expected": {
"January 1": {
"unixTime": 1704067200,
"unixTimeISO": "2024-01-01T00:00:00Z"
"unixTimeISO": "2024-01-01T00:00:00+00:00"
},
"April 1": {
"unixTime": 1711929600,
"unixTimeISO": "2024-04-01T00:00:00Z"
"unixTimeISO": "2024-04-01T00:00:00+00:00"
},
"October 1": {
"unixTime": 1696118400,
"unixTimeISO": "2023-10-01T00:00:00Z"
"unixTimeISO": "2023-10-01T00:00:00+00:00"
}
}
},
@@ -471,15 +471,15 @@
"expected": {
"January 1": {
"unixTime": 1704067200,
"unixTimeISO": "2024-01-01T00:00:00Z"
"unixTimeISO": "2024-01-01T00:00:00+00:00"
},
"April 1": {
"unixTime": 1711929600,
"unixTimeISO": "2024-04-01T00:00:00Z"
"unixTimeISO": "2024-04-01T00:00:00+00:00"
},
"October 1": {
"unixTime": 1727740800,
"unixTimeISO": "2024-10-01T00:00:00Z"
"unixTimeISO": "2024-10-01T00:00:00+00:00"
}
}
},
@@ -488,15 +488,15 @@
"expected": {
"January 1": {
"unixTime": 1704067200,
"unixTimeISO": "2024-01-01T00:00:00Z"
"unixTimeISO": "2024-01-01T00:00:00+00:00"
},
"April 1": {
"unixTime": 1711929600,
"unixTimeISO": "2024-04-01T00:00:00Z"
"unixTimeISO": "2024-04-01T00:00:00+00:00"
},
"October 1": {
"unixTime": 1727740800,
"unixTimeISO": "2024-10-01T00:00:00Z"
"unixTimeISO": "2024-10-01T00:00:00+00:00"
}
}
},
@@ -505,15 +505,15 @@
"expected": {
"January 1": {
"unixTime": 1735689600,
"unixTimeISO": "2025-01-01T00:00:00Z"
"unixTimeISO": "2025-01-01T00:00:00+00:00"
},
"April 1": {
"unixTime": 1711929600,
"unixTimeISO": "2024-04-01T00:00:00Z"
"unixTimeISO": "2024-04-01T00:00:00+00:00"
},
"October 1": {
"unixTime": 1727740800,
"unixTimeISO": "2024-10-01T00:00:00Z"
"unixTimeISO": "2024-10-01T00:00:00+00:00"
}
}
},
@@ -522,15 +522,15 @@
"expected": {
"January 1": {
"unixTime": 1735689600,
"unixTimeISO": "2025-01-01T00:00:00Z"
"unixTimeISO": "2025-01-01T00:00:00+00:00"
},
"April 1": {
"unixTime": 1711929600,
"unixTimeISO": "2024-04-01T00:00:00Z"
"unixTimeISO": "2024-04-01T00:00:00+00:00"
},
"October 1": {
"unixTime": 1727740800,
"unixTimeISO": "2024-10-01T00:00:00Z"
"unixTimeISO": "2024-10-01T00:00:00+00:00"
}
}
},
@@ -539,15 +539,15 @@
"expected": {
"January 1": {
"unixTime": 1735689600,
"unixTimeISO": "2025-01-01T00:00:00Z"
"unixTimeISO": "2025-01-01T00:00:00+00:00"
},
"April 1": {
"unixTime": 1743465600,
"unixTimeISO": "2025-04-01T00:00:00Z"
"unixTimeISO": "2025-04-01T00:00:00+00:00"
},
"October 1": {
"unixTime": 1727740800,
"unixTimeISO": "2024-10-01T00:00:00Z"
"unixTimeISO": "2024-10-01T00:00:00+00:00"
}
}
},
@@ -556,15 +556,15 @@
"expected": {
"January 1": {
"unixTime": 1735689600,
"unixTimeISO": "2025-01-01T00:00:00Z"
"unixTimeISO": "2025-01-01T00:00:00+00:00"
},
"April 1": {
"unixTime": 1743465600,
"unixTimeISO": "2025-04-01T00:00:00Z"
"unixTimeISO": "2025-04-01T00:00:00+00:00"
},
"October 1": {
"unixTime": 1727740800,
"unixTimeISO": "2024-10-01T00:00:00Z"
"unixTimeISO": "2024-10-01T00:00:00+00:00"
}
}
},
@@ -573,15 +573,15 @@
"expected": {
"January 1": {
"unixTime": 1735689600,
"unixTimeISO": "2025-01-01T00:00:00Z"
"unixTimeISO": "2025-01-01T00:00:00+00:00"
},
"April 1": {
"unixTime": 1743465600,
"unixTimeISO": "2025-04-01T00:00:00Z"
"unixTimeISO": "2025-04-01T00:00:00+00:00"
},
"October 1": {
"unixTime": 1759276800,
"unixTimeISO": "2025-10-01T00:00:00Z"
"unixTimeISO": "2025-10-01T00:00:00+00:00"
}
}
},
@@ -590,15 +590,15 @@
"expected": {
"January 1": {
"unixTime": 1735689600,
"unixTimeISO": "2025-01-01T00:00:00Z"
"unixTimeISO": "2025-01-01T00:00:00+00:00"
},
"April 1": {
"unixTime": 1743465600,
"unixTimeISO": "2025-04-01T00:00:00Z"
"unixTimeISO": "2025-04-01T00:00:00+00:00"
},
"October 1": {
"unixTime": 1759276800,
"unixTimeISO": "2025-10-01T00:00:00Z"
"unixTimeISO": "2025-10-01T00:00:00+00:00"
}
}
}
@@ -609,15 +609,15 @@
"expected": {
"January 1": {
"unixTime": 1672531199,
"unixTimeISO": "2022-12-31T23:59:59Z"
"unixTimeISO": "2022-12-31T23:59:59+00:00"
},
"April 1": {
"unixTime": 1648771199,
"unixTimeISO": "2022-03-31T23:59:59Z"
"unixTimeISO": "2022-03-31T23:59:59+00:00"
},
"October 1": {
"unixTime": 1664582399,
"unixTimeISO": "2022-09-30T23:59:59Z"
"unixTimeISO": "2022-09-30T23:59:59+00:00"
}
}
},
@@ -626,15 +626,15 @@
"expected": {
"January 1": {
"unixTime": 1672531199,
"unixTimeISO": "2022-12-31T23:59:59Z"
"unixTimeISO": "2022-12-31T23:59:59+00:00"
},
"April 1": {
"unixTime": 1648771199,
"unixTimeISO": "2022-03-31T23:59:59Z"
"unixTimeISO": "2022-03-31T23:59:59+00:00"
},
"October 1": {
"unixTime": 1664582399,
"unixTimeISO": "2022-09-30T23:59:59Z"
"unixTimeISO": "2022-09-30T23:59:59+00:00"
}
}
},
@@ -643,15 +643,15 @@
"expected": {
"January 1": {
"unixTime": 1672531199,
"unixTimeISO": "2022-12-31T23:59:59Z"
"unixTimeISO": "2022-12-31T23:59:59+00:00"
},
"April 1": {
"unixTime": 1680307199,
"unixTimeISO": "2023-03-31T23:59:59Z"
"unixTimeISO": "2023-03-31T23:59:59+00:00"
},
"October 1": {
"unixTime": 1664582399,
"unixTimeISO": "2022-09-30T23:59:59Z"
"unixTimeISO": "2022-09-30T23:59:59+00:00"
}
}
},
@@ -660,15 +660,15 @@
"expected": {
"January 1": {
"unixTime": 1672531199,
"unixTimeISO": "2022-12-31T23:59:59Z"
"unixTimeISO": "2022-12-31T23:59:59+00:00"
},
"April 1": {
"unixTime": 1680307199,
"unixTimeISO": "2023-03-31T23:59:59Z"
"unixTimeISO": "2023-03-31T23:59:59+00:00"
},
"October 1": {
"unixTime": 1664582399,
"unixTimeISO": "2022-09-30T23:59:59Z"
"unixTimeISO": "2022-09-30T23:59:59+00:00"
}
}
},
@@ -677,15 +677,15 @@
"expected": {
"January 1": {
"unixTime": 1672531199,
"unixTimeISO": "2022-12-31T23:59:59Z"
"unixTimeISO": "2022-12-31T23:59:59+00:00"
},
"April 1": {
"unixTime": 1680307199,
"unixTimeISO": "2023-03-31T23:59:59Z"
"unixTimeISO": "2023-03-31T23:59:59+00:00"
},
"October 1": {
"unixTime": 1696118399,
"unixTimeISO": "2023-09-30T23:59:59Z"
"unixTimeISO": "2023-09-30T23:59:59+00:00"
}
}
},
@@ -694,15 +694,15 @@
"expected": {
"January 1": {
"unixTime": 1672531199,
"unixTimeISO": "2022-12-31T23:59:59Z"
"unixTimeISO": "2022-12-31T23:59:59+00:00"
},
"April 1": {
"unixTime": 1680307199,
"unixTimeISO": "2023-03-31T23:59:59Z"
"unixTimeISO": "2023-03-31T23:59:59+00:00"
},
"October 1": {
"unixTime": 1696118399,
"unixTimeISO": "2023-09-30T23:59:59Z"
"unixTimeISO": "2023-09-30T23:59:59+00:00"
}
}
},
@@ -711,15 +711,15 @@
"expected": {
"January 1": {
"unixTime": 1704067199,
"unixTimeISO": "2023-12-31T23:59:59Z"
"unixTimeISO": "2023-12-31T23:59:59+00:00"
},
"April 1": {
"unixTime": 1680307199,
"unixTimeISO": "2023-03-31T23:59:59Z"
"unixTimeISO": "2023-03-31T23:59:59+00:00"
},
"October 1": {
"unixTime": 1696118399,
"unixTimeISO": "2023-09-30T23:59:59Z"
"unixTimeISO": "2023-09-30T23:59:59+00:00"
}
}
},
@@ -728,15 +728,15 @@
"expected": {
"January 1": {
"unixTime": 1704067199,
"unixTimeISO": "2023-12-31T23:59:59Z"
"unixTimeISO": "2023-12-31T23:59:59+00:00"
},
"April 1": {
"unixTime": 1680307199,
"unixTimeISO": "2023-03-31T23:59:59Z"
"unixTimeISO": "2023-03-31T23:59:59+00:00"
},
"October 1": {
"unixTime": 1696118399,
"unixTimeISO": "2023-09-30T23:59:59Z"
"unixTimeISO": "2023-09-30T23:59:59+00:00"
}
}
},
@@ -745,15 +745,15 @@
"expected": {
"January 1": {
"unixTime": 1704067199,
"unixTimeISO": "2023-12-31T23:59:59Z"
"unixTimeISO": "2023-12-31T23:59:59+00:00"
},
"April 1": {
"unixTime": 1711929599,
"unixTimeISO": "2024-03-31T23:59:59Z"
"unixTimeISO": "2024-03-31T23:59:59+00:00"
},
"October 1": {
"unixTime": 1696118399,
"unixTimeISO": "2023-09-30T23:59:59Z"
"unixTimeISO": "2023-09-30T23:59:59+00:00"
}
}
},
@@ -762,15 +762,15 @@
"expected": {
"January 1": {
"unixTime": 1704067199,
"unixTimeISO": "2023-12-31T23:59:59Z"
"unixTimeISO": "2023-12-31T23:59:59+00:00"
},
"April 1": {
"unixTime": 1711929599,
"unixTimeISO": "2024-03-31T23:59:59Z"
"unixTimeISO": "2024-03-31T23:59:59+00:00"
},
"October 1": {
"unixTime": 1696118399,
"unixTimeISO": "2023-09-30T23:59:59Z"
"unixTimeISO": "2023-09-30T23:59:59+00:00"
}
}
},
@@ -779,15 +779,15 @@
"expected": {
"January 1": {
"unixTime": 1704067199,
"unixTimeISO": "2023-12-31T23:59:59Z"
"unixTimeISO": "2023-12-31T23:59:59+00:00"
},
"April 1": {
"unixTime": 1711929599,
"unixTimeISO": "2024-03-31T23:59:59Z"
"unixTimeISO": "2024-03-31T23:59:59+00:00"
},
"October 1": {
"unixTime": 1727740799,
"unixTimeISO": "2024-09-30T23:59:59Z"
"unixTimeISO": "2024-09-30T23:59:59+00:00"
}
}
},
@@ -796,15 +796,15 @@
"expected": {
"January 1": {
"unixTime": 1704067199,
"unixTimeISO": "2023-12-31T23:59:59Z"
"unixTimeISO": "2023-12-31T23:59:59+00:00"
},
"April 1": {
"unixTime": 1711929599,
"unixTimeISO": "2024-03-31T23:59:59Z"
"unixTimeISO": "2024-03-31T23:59:59+00:00"
},
"October 1": {
"unixTime": 1727740799,
"unixTimeISO": "2024-09-30T23:59:59Z"
"unixTimeISO": "2024-09-30T23:59:59+00:00"
}
}
},
@@ -813,15 +813,15 @@
"expected": {
"January 1": {
"unixTime": 1735689599,
"unixTimeISO": "2024-12-31T23:59:59Z"
"unixTimeISO": "2024-12-31T23:59:59+00:00"
},
"April 1": {
"unixTime": 1711929599,
"unixTimeISO": "2024-03-31T23:59:59Z"
"unixTimeISO": "2024-03-31T23:59:59+00:00"
},
"October 1": {
"unixTime": 1727740799,
"unixTimeISO": "2024-09-30T23:59:59Z"
"unixTimeISO": "2024-09-30T23:59:59+00:00"
}
}
},
@@ -830,15 +830,15 @@
"expected": {
"January 1": {
"unixTime": 1735689599,
"unixTimeISO": "2024-12-31T23:59:59Z"
"unixTimeISO": "2024-12-31T23:59:59+00:00"
},
"April 1": {
"unixTime": 1711929599,
"unixTimeISO": "2024-03-31T23:59:59Z"
"unixTimeISO": "2024-03-31T23:59:59+00:00"
},
"October 1": {
"unixTime": 1727740799,
"unixTimeISO": "2024-09-30T23:59:59Z"
"unixTimeISO": "2024-09-30T23:59:59+00:00"
}
}
},
@@ -847,15 +847,15 @@
"expected": {
"January 1": {
"unixTime": 1735689599,
"unixTimeISO": "2024-12-31T23:59:59Z"
"unixTimeISO": "2024-12-31T23:59:59+00:00"
},
"April 1": {
"unixTime": 1743465599,
"unixTimeISO": "2025-03-31T23:59:59Z"
"unixTimeISO": "2025-03-31T23:59:59+00:00"
},
"October 1": {
"unixTime": 1727740799,
"unixTimeISO": "2024-09-30T23:59:59Z"
"unixTimeISO": "2024-09-30T23:59:59+00:00"
}
}
},
@@ -864,15 +864,15 @@
"expected": {
"January 1": {
"unixTime": 1735689599,
"unixTimeISO": "2024-12-31T23:59:59Z"
"unixTimeISO": "2024-12-31T23:59:59+00:00"
},
"April 1": {
"unixTime": 1743465599,
"unixTimeISO": "2025-03-31T23:59:59Z"
"unixTimeISO": "2025-03-31T23:59:59+00:00"
},
"October 1": {
"unixTime": 1727740799,
"unixTimeISO": "2024-09-30T23:59:59Z"
"unixTimeISO": "2024-09-30T23:59:59+00:00"
}
}
},
@@ -881,15 +881,15 @@
"expected": {
"January 1": {
"unixTime": 1735689599,
"unixTimeISO": "2024-12-31T23:59:59Z"
"unixTimeISO": "2024-12-31T23:59:59+00:00"
},
"April 1": {
"unixTime": 1743465599,
"unixTimeISO": "2025-03-31T23:59:59Z"
"unixTimeISO": "2025-03-31T23:59:59+00:00"
},
"October 1": {
"unixTime": 1759276799,
"unixTimeISO": "2025-09-30T23:59:59Z"
"unixTimeISO": "2025-09-30T23:59:59+00:00"
}
}
},
@@ -898,15 +898,15 @@
"expected": {
"January 1": {
"unixTime": 1735689599,
"unixTimeISO": "2024-12-31T23:59:59Z"
"unixTimeISO": "2024-12-31T23:59:59+00:00"
},
"April 1": {
"unixTime": 1743465599,
"unixTimeISO": "2025-03-31T23:59:59Z"
"unixTimeISO": "2025-03-31T23:59:59+00:00"
},
"October 1": {
"unixTime": 1759276799,
"unixTimeISO": "2025-09-30T23:59:59Z"
"unixTimeISO": "2025-09-30T23:59:59+00:00"
}
}
},
@@ -915,15 +915,15 @@
"expected": {
"January 1": {
"unixTime": 1767225599,
"unixTimeISO": "2025-12-31T23:59:59Z"
"unixTimeISO": "2025-12-31T23:59:59+00:00"
},
"April 1": {
"unixTime": 1743465599,
"unixTimeISO": "2025-03-31T23:59:59Z"
"unixTimeISO": "2025-03-31T23:59:59+00:00"
},
"October 1": {
"unixTime": 1759276799,
"unixTimeISO": "2025-09-30T23:59:59Z"
"unixTimeISO": "2025-09-30T23:59:59+00:00"
}
}
},
@@ -932,15 +932,15 @@
"expected": {
"January 1": {
"unixTime": 1767225599,
"unixTimeISO": "2025-12-31T23:59:59Z"
"unixTimeISO": "2025-12-31T23:59:59+00:00"
},
"April 1": {
"unixTime": 1743465599,
"unixTimeISO": "2025-03-31T23:59:59Z"
"unixTimeISO": "2025-03-31T23:59:59+00:00"
},
"October 1": {
"unixTime": 1759276799,
"unixTimeISO": "2025-09-30T23:59:59Z"
"unixTimeISO": "2025-09-30T23:59:59+00:00"
}
}
},
@@ -949,15 +949,15 @@
"expected": {
"January 1": {
"unixTime": 1767225599,
"unixTimeISO": "2025-12-31T23:59:59Z"
"unixTimeISO": "2025-12-31T23:59:59+00:00"
},
"April 1": {
"unixTime": 1775001599,
"unixTimeISO": "2026-03-31T23:59:59Z"
"unixTimeISO": "2026-03-31T23:59:59+00:00"
},
"October 1": {
"unixTime": 1759276799,
"unixTimeISO": "2025-09-30T23:59:59Z"
"unixTimeISO": "2025-09-30T23:59:59+00:00"
}
}
},
@@ -966,15 +966,15 @@
"expected": {
"January 1": {
"unixTime": 1767225599,
"unixTimeISO": "2025-12-31T23:59:59Z"
"unixTimeISO": "2025-12-31T23:59:59+00:00"
},
"April 1": {
"unixTime": 1775001599,
"unixTimeISO": "2026-03-31T23:59:59Z"
"unixTimeISO": "2026-03-31T23:59:59+00:00"
},
"October 1": {
"unixTime": 1759276799,
"unixTimeISO": "2025-09-30T23:59:59Z"
"unixTimeISO": "2025-09-30T23:59:59+00:00"
}
}
},
@@ -983,15 +983,15 @@
"expected": {
"January 1": {
"unixTime": 1767225599,
"unixTimeISO": "2025-12-31T23:59:59Z"
"unixTimeISO": "2025-12-31T23:59:59+00:00"
},
"April 1": {
"unixTime": 1775001599,
"unixTimeISO": "2026-03-31T23:59:59Z"
"unixTimeISO": "2026-03-31T23:59:59+00:00"
},
"October 1": {
"unixTime": 1790812799,
"unixTimeISO": "2026-09-30T23:59:59Z"
"unixTimeISO": "2026-09-30T23:59:59+00:00"
}
}
},
@@ -1000,15 +1000,15 @@
"expected": {
"January 1": {
"unixTime": 1767225599,
"unixTimeISO": "2025-12-31T23:59:59Z"
"unixTimeISO": "2025-12-31T23:59:59+00:00"
},
"April 1": {
"unixTime": 1775001599,
"unixTimeISO": "2026-03-31T23:59:59Z"
"unixTimeISO": "2026-03-31T23:59:59+00:00"
},
"October 1": {
"unixTime": 1790812799,
"unixTimeISO": "2026-09-30T23:59:59Z"
"unixTimeISO": "2026-09-30T23:59:59+00:00"
}
}
}
+1 -1
View File
@@ -35,7 +35,7 @@ function importTestData(datasetName: string): unknown[] {
}
function formatUnixTimeISO(unixTime: number): string {
return formatUnixTime(unixTime, 'YYYY-MM-DD[T]HH:mm:ss[Z]');
return formatUnixTime(unixTime, 'YYYY-MM-DDTHH:mm:ssZ');
}
function getTestTitleFormatDate(testFiscalYearStartId: string, testCaseDateString: string): string {
+110 -14
View File
@@ -22,7 +22,6 @@ import {
YearQuarterUnixTime,
YearMonthUnixTime,
YearMonthDayUnixTime,
Month,
WeekDay,
MeridiemIndicator,
DateRangeScene,
@@ -34,13 +33,40 @@ import {
FiscalYearStart
} from '@/core/fiscalyear.ts';
import {
isFunction,
isObject,
isString,
isNumber
} from './common.ts';
type DateTimeTokenFormatFunction = (d: MomentDateTime) => string;
class MomentDateTime implements DateTime {
private instance: moment.Moment;
private static readonly tokenFormatFuncs: Record<string, DateTimeTokenFormatFunction> = {
'YY': (d: MomentDateTime) => (d.getLocalizedCalendarYear() % 100).toString().padStart(2, '0'),
'YYYY': (d: MomentDateTime) => d.getLocalizedCalendarYear().toString().padStart(4, '0'),
'M': (d: MomentDateTime) => d.getLocalizedCalendarMonth().toString(),
'MM': (d: MomentDateTime) => d.getLocalizedCalendarMonth().toString().padStart(2, '0'),
'MMM': (d: MomentDateTime) => d.getLocalizedCalendarMonthDisplayShortName(),
'MMMM': (d: MomentDateTime) => d.getLocalizedCalendarMonthDisplayName(),
'D': (d: MomentDateTime) => d.getLocalizedCalendarDay().toString(),
'DD': (d: MomentDateTime) => d.getLocalizedCalendarDay().toString().padStart(2, '0'),
'dd': (d: MomentDateTime) => d.getWeekDayDisplayMinName(),
'ddd': (d: MomentDateTime) => d.getWeekDayDisplayShortName(),
'dddd': (d: MomentDateTime) => d.getWeekDayDisplayName(),
'H': (d: MomentDateTime) => d.getHour().toString(),
'HH': (d: MomentDateTime) => d.getHour().toString().padStart(2, '0'),
'h': (d: MomentDateTime) => getHourIn12HourFormat(d.getHour()).toString(),
'hh': (d: MomentDateTime) => getHourIn12HourFormat(d.getHour()).toString().padStart(2, '0'),
'm': (d: MomentDateTime) => d.getMinute().toString(),
'mm': (d: MomentDateTime) => d.getMinute().toString().padStart(2, '0'),
's': (d: MomentDateTime) => d.getSecond().toString(),
'ss': (d: MomentDateTime) => d.getSecond().toString().padStart(2, '0'),
'A': (d: MomentDateTime) => d.getDisplayAMPM(),
'Z': (d: MomentDateTime) => getUtcOffsetByUtcOffsetMinutes(d.getTimezoneUtcOffsetMinutes())
};
private readonly instance: moment.Moment;
private constructor(instance: moment.Moment) {
this.instance = instance;
@@ -70,14 +96,30 @@ class MomentDateTime implements DateTime {
return this.instance.month() + 1;
}
public getGregorianCalendarMonthName(): string {
return (Month.valueOf(this.instance.month() + 1) as Month).name;
public getGregorianCalendarMonthDisplayName(): string {
const names = this.instance.localeData().months();
return names[this.getGregorianCalendarMonth() - 1] || '';
}
public getGregorianCalendarMonthDisplayShortName(): string {
const names = this.instance.localeData().monthsShort();
return names[this.getGregorianCalendarMonth() - 1] || '';
}
public getLocalizedCalendarMonth(): number {
return this.instance.month() + 1;
}
public getLocalizedCalendarMonthDisplayName(): string {
const names = this.instance.localeData().months();
return names[this.getLocalizedCalendarMonth() - 1] || '';
}
public getLocalizedCalendarMonthDisplayShortName(): string {
const names = this.instance.localeData().monthsShort();
return names[this.getLocalizedCalendarMonth() - 1] || '';
}
public getGregorianCalendarDay(): number {
return this.instance.date();
}
@@ -95,7 +137,42 @@ class MomentDateTime implements DateTime {
}
public getWeekDay(): WeekDay {
return WeekDay.valueOf(this.instance.days()) as WeekDay;
return WeekDay.valueOf(this.instance.day()) as WeekDay;
}
public getWeekDayDisplayName(): string {
const names = this.instance.localeData().weekdays();
return names[this.instance.day()] || '';
}
public getWeekDayDisplayShortName(): string {
const names = this.instance.localeData().weekdaysShort();
return names[this.instance.day()] || '';
}
public getWeekDayDisplayMinName(): string {
const names = this.instance.localeData().weekdaysMin();
return names[this.instance.day()] || '';
}
public getHour(): number {
return this.instance.hour();
}
public getMinute(): number {
return this.instance.minute();
}
public getSecond(): number {
return this.instance.second();
}
public getDisplayAMPM(): string {
return this.instance.localeData().meridiem(this.getHour(), this.getMinute(), false);
}
public getTimezoneUtcOffsetMinutes(): number {
return this.instance.utcOffset();
}
public toGregorianCalendarYearMonthDay(): YearMonthDay {
@@ -114,7 +191,30 @@ class MomentDateTime implements DateTime {
}
public format(format: string): string {
return this.instance.format(format);
let result = '';
let i = 0;
while (i < format.length) {
let matched = false;
for (let len = 4; len > 0; len--) {
const token = format.substring(i, i + len);
const formatFunc = MomentDateTime.tokenFormatFuncs[token];
if (isFunction(formatFunc)) {
result += formatFunc(this);
i += len;
matched = true;
break;
}
}
if (!matched) {
result += format[i];
i++;
}
}
return result;
}
public static of(instance: moment.Moment): DateTime {
@@ -250,11 +350,7 @@ export function getUtcOffsetByUtcOffsetMinutes(utcOffsetMinutes: number): string
}
export function getTimezoneOffset(timezone?: string): string {
if (timezone) {
return moment().tz(timezone).format('Z');
} else {
return moment().format('Z');
}
return getUtcOffsetByUtcOffsetMinutes(getTimezoneOffsetMinutes(timezone));
}
export function getTimezoneOffsetMinutes(timezone?: string): number {
@@ -314,15 +410,15 @@ export function formatUnixTime(unixTime: number, format: string, utcOffset?: num
}
export function formatCurrentTime(format: string): string {
return moment().format(format);
return MomentDateTime.now().format(format);
}
export function formatGregorianCalendarYearDashMonthDashDay(date: TextualYearMonthDay, format: string): string {
return moment(date, 'YYYY-MM-DD').format(format);
return MomentDateTime.of(moment(date, 'YYYY-MM-DD')).format(format);
}
export function formatGregorianCalendarMonthDashDay(monthDay: TextualYearMonth, format: string): string {
return moment(monthDay, 'MM-DD').format(format);
return MomentDateTime.of(moment(monthDay, 'MM-DD')).format(format);
}
export function getGregorianCalendarYearAndMonthFromUnixTime(unixTime: number): TextualYearMonth | '' {
+3 -3
View File
@@ -36,7 +36,7 @@
"longDate": {
"yyyy_mm_dd": "YYYY MMMM DD",
"mm_dd_yyyy": "MMMM D, YYYY",
"dd_mm_yyyy": "D [de] MMMM [de] YYYY"
"dd_mm_yyyy": "D de MMMM de YYYY"
},
"shortDate": {
"yyyy_mm_dd": "YYYY/MM/DD",
@@ -56,7 +56,7 @@
"longYearMonth": {
"yyyy_mm_dd": "YYYY MMMM",
"mm_dd_yyyy": "MMMM, YYYY",
"dd_mm_yyyy": "MMMM [de] YYYY"
"dd_mm_yyyy": "MMMM de YYYY"
},
"shortYearMonth": {
"yyyy_mm_dd": "YYYY/MM",
@@ -66,7 +66,7 @@
"longMonthDay": {
"yyyy_mm_dd": "MMMM DD",
"mm_dd_yyyy": "MMMM D",
"dd_mm_yyyy": "D [de] MMMM"
"dd_mm_yyyy": "D de MMMM"
},
"shortMonthDay": {
"yyyy_mm_dd": "MM/DD",
+3 -3
View File
@@ -36,7 +36,7 @@
"longDate": {
"yyyy_mm_dd": "YYYY MMMM DD",
"mm_dd_yyyy": "MMMM D, YYYY",
"dd_mm_yyyy": "D [de] MMMM [de] YYYY"
"dd_mm_yyyy": "D de MMMM de YYYY"
},
"shortDate": {
"yyyy_mm_dd": "YYYY/MM/DD",
@@ -56,7 +56,7 @@
"longYearMonth": {
"yyyy_mm_dd": "YYYY MMMM",
"mm_dd_yyyy": "MMMM, YYYY",
"dd_mm_yyyy": "MMMM [de] YYYY"
"dd_mm_yyyy": "MMMM de YYYY"
},
"shortYearMonth": {
"yyyy_mm_dd": "YYYY/MM",
@@ -66,7 +66,7 @@
"longMonthDay": {
"yyyy_mm_dd": "MMMM DD",
"mm_dd_yyyy": "MMMM D",
"dd_mm_yyyy": "D [de] MMMM"
"dd_mm_yyyy": "D de MMMM"
},
"shortMonthDay": {
"yyyy_mm_dd": "MM/DD",
@@ -61,7 +61,7 @@ const emit = defineEmits<{
(e: 'click', event: MonthlyIncomeAndExpenseCardClickEvent): void;
}>();
const { tt, getCurrentLanguageTextDirection, getMonthShortName, formatAmountToLocalizedNumeralsWithCurrency } = useI18n();
const { tt, getCurrentLanguageTextDirection, formatAmountToLocalizedNumeralsWithCurrency } = useI18n();
const settingsStore = useSettingsStore();
const userStore = useUserStore();
@@ -97,9 +97,9 @@ const chartOptions = computed<object>(() => {
if (props.data) {
for (let i = 0; i < props.data.length; i++) {
const item = props.data[i];
const month = parseDateTimeFromUnixTime(item.monthStartTime).getGregorianCalendarMonthName();
const monthShortName = parseDateTimeFromUnixTime(item.monthStartTime).getGregorianCalendarMonthDisplayShortName();
monthNames.push(getMonthShortName(month));
monthNames.push(monthShortName);
incomeAmounts.push(item.incomeAmount);
expenseAmounts.push(-item.expenseAmount);