mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-14 23:17:33 +08:00
support calendar display type (Gregorian and Buddhist)
This commit is contained in:
@@ -2,8 +2,7 @@ import type { TypeAndName } from '@/core/base.ts';
|
||||
|
||||
export enum CalendarType {
|
||||
Gregorian = 0,
|
||||
Buddhist = 1,
|
||||
Chinese = 2
|
||||
Buddhist = 1
|
||||
}
|
||||
|
||||
export class CalendarDisplayType implements TypeAndName {
|
||||
@@ -13,6 +12,7 @@ export class CalendarDisplayType implements TypeAndName {
|
||||
|
||||
public static readonly LanguageDefaultType: number = 0;
|
||||
public static readonly Gregorian = new CalendarDisplayType(1, 'Gregorian', 'Gregorian', CalendarType.Gregorian);
|
||||
public static readonly Buddhist = new CalendarDisplayType(2, 'Buddhist', 'Buddhist', CalendarType.Buddhist);
|
||||
|
||||
public static readonly Default = CalendarDisplayType.Gregorian;
|
||||
|
||||
|
||||
+11
-5
@@ -4,18 +4,19 @@ import type { NumeralSystem } from '@/core/numeral.ts';
|
||||
|
||||
export interface DateTime {
|
||||
getUnixTime(): number;
|
||||
getLocalizedCalendarYear(options: DateTimeFormatOptions): number;
|
||||
getLocalizedCalendarYear(options: DateTimeFormatOptions): string;
|
||||
getGregorianCalendarYear(): number;
|
||||
getGregorianCalendarQuarter(): number;
|
||||
getLocalizedCalendarQuarter(options: DateTimeFormatOptions): number;
|
||||
getGregorianCalendarMonth(): number;
|
||||
getGregorianCalendarMonthDisplayName(options: DateTimeFormatOptions): string;
|
||||
getGregorianCalendarMonthDisplayShortName(options: DateTimeFormatOptions): string;
|
||||
getLocalizedCalendarMonth(options: DateTimeFormatOptions): number;
|
||||
getLocalizedCalendarMonth(options: DateTimeFormatOptions): string;
|
||||
getLocalizedCalendarMonthIndex(options: DateTimeFormatOptions): number;
|
||||
getLocalizedCalendarMonthDisplayName(options: DateTimeFormatOptions): string;
|
||||
getLocalizedCalendarMonthDisplayShortName(options: DateTimeFormatOptions): string;
|
||||
getGregorianCalendarDay(): number;
|
||||
getLocalizedCalendarDay(options: DateTimeFormatOptions): number;
|
||||
getLocalizedCalendarDay(options: DateTimeFormatOptions): string;
|
||||
getGregorianCalendarYearDashMonthDashDay(): TextualYearMonthDay;
|
||||
getGregorianCalendarYearDashMonth(): TextualYearMonth;
|
||||
getWeekDay(): WeekDay;
|
||||
@@ -33,8 +34,8 @@ export interface DateTime {
|
||||
}
|
||||
|
||||
export interface DateTimeFormatOptions {
|
||||
calendarType: CalendarType;
|
||||
numeralSystem: NumeralSystem;
|
||||
calendarType: CalendarType;
|
||||
localeData: DateTimeLocaleData;
|
||||
}
|
||||
|
||||
@@ -70,12 +71,17 @@ export interface YearMonthRange {
|
||||
readonly endYearMonth: Year0BasedMonth;
|
||||
}
|
||||
|
||||
export interface YearMonthDay {
|
||||
export interface YearMonthDay extends MonthDay {
|
||||
readonly year: number;
|
||||
readonly month: number; // 1-based (1 = January, 12 = December)
|
||||
readonly day: number;
|
||||
}
|
||||
|
||||
export interface MonthDay {
|
||||
readonly month: number; // 1-based (1 = January, 12 = December
|
||||
readonly day: number;
|
||||
}
|
||||
|
||||
export interface TimeRange {
|
||||
readonly minTime: number;
|
||||
readonly maxTime: number;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { TextualYearMonth, UnixTimeRange } from './datetime.ts';
|
||||
import type { TextualYearMonth, MonthDay, UnixTimeRange } from './datetime.ts';
|
||||
|
||||
export class FiscalYearStart {
|
||||
public static readonly JanuaryFirstDay = new FiscalYearStart(1, 1);
|
||||
@@ -79,6 +79,13 @@ export class FiscalYearStart {
|
||||
return `${this.month.toString().padStart(2, '0')}-${this.day.toString().padStart(2, '0')}` as TextualYearMonth;
|
||||
}
|
||||
|
||||
public toMonthDay(): MonthDay {
|
||||
return {
|
||||
month: this.month,
|
||||
day: this.day
|
||||
};
|
||||
}
|
||||
|
||||
private static isValidFiscalYearMonthDay(month: number, day: number): boolean {
|
||||
return 1 <= month && month <= 12 && 1 <= day && day <= FiscalYearStart.MONTH_MAX_DAYS[month - 1];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user