mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-19 01:04:25 +08:00
add explicit type for string-based datetimes, replacing third-party datetime type with internal DateTime type
This commit is contained in:
@@ -1,5 +1,27 @@
|
||||
import type { TypeAndName, TypeAndDisplayName } from '@/core/base.ts';
|
||||
|
||||
export interface DateTime {
|
||||
getUnixTime(): number;
|
||||
getLocalizedCalendarYear(): number;
|
||||
getGregorianCalendarYear(): number;
|
||||
getGregorianCalendarQuarter(): number;
|
||||
getLocalizedCalendarQuarter(): number;
|
||||
getGregorianCalendarMonth(): number;
|
||||
getGregorianCalendarMonthName(): string;
|
||||
getLocalizedCalendarMonth(): number;
|
||||
getGregorianCalendarDay(): number;
|
||||
getLocalizedCalendarDay(): number;
|
||||
getGregorianCalendarYearDashMonthDashDay(): TextualYearMonthDay;
|
||||
getGregorianCalendarYearDashMonth(): TextualYearMonth;
|
||||
getWeekDay(): WeekDay;
|
||||
toGregorianCalendarYearMonthDay(): YearMonthDay;
|
||||
toGregorianCalendarYear0BasedMonth(): Year0BasedMonth;
|
||||
format(format: string): string;
|
||||
}
|
||||
|
||||
export type TextualYearMonth = `${number}-${number}`;
|
||||
export type TextualYearMonthDay = `${number}-${number}-${number}`;
|
||||
|
||||
export interface YearQuarter {
|
||||
readonly year: number;
|
||||
readonly quarter: number;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { UnixTimeRange } from './datetime.ts';
|
||||
import type { TextualYearMonth, UnixTimeRange } from './datetime.ts';
|
||||
|
||||
export class FiscalYearStart {
|
||||
public static readonly JanuaryFirstDay = new FiscalYearStart(1, 1);
|
||||
@@ -75,8 +75,8 @@ export class FiscalYearStart {
|
||||
return FiscalYearStart.of(month, day);
|
||||
}
|
||||
|
||||
public toMonthDashDayString(): string {
|
||||
return `${this.month.toString().padStart(2, '0')}-${this.day.toString().padStart(2, '0')}`;
|
||||
public toMonthDashDayString(): TextualYearMonth {
|
||||
return `${this.month.toString().padStart(2, '0')}-${this.day.toString().padStart(2, '0')}` as TextualYearMonth;
|
||||
}
|
||||
|
||||
private static isValidFiscalYearMonthDay(month: number, day: number): boolean {
|
||||
|
||||
Reference in New Issue
Block a user