Skip to content

Commit

Permalink
fix: more typescript cleaning and fixing
Browse files Browse the repository at this point in the history
  • Loading branch information
amirhmoradi committed May 22, 2023
1 parent f9627ad commit 949eb8d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 15 deletions.
13 changes: 11 additions & 2 deletions types/calendarSystems/CalendarSystemBase.d.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
import { Dayjs, OpUnitType } from 'dayjs';


type DateLikeObject = { year: number; month: number; day: number; };
type DayjsLikeObject = { $y: number; $M: number; $D: number; };

export declare abstract class CalendarSystemBase {
locale: string;

constructor(locale?: string);

abstract convertFromGregorian(date: Date | string | number | undefined | null): { year: number; month: number; day: number; } | void;
abstract convertFromGregorian(date: Date | DateLikeObject | DayjsLikeObject | string | number | undefined | null): { year: number; month: number; day: number; } | void;
abstract convertToGregorian(year: number, month: number, day: number): { year: number; month: number; day: number; } | void;
abstract monthNames(locale?: string): string[];
getLocalizedMonthName(monthIndex: number): string;
localeOverride(locale?: string): { months: string[], monthsShort: string[] };
localeOverride(locale: string): Object;
daysInMonth?(): number;
startOf?(units: OpUnitType,isStartOf: Boolean): Dayjs;
endOf?(units: OpUnitType): Dayjs;
}
15 changes: 2 additions & 13 deletions types/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { PluginFunc, Dayjs, OpUnitType } from 'dayjs';

type DateLikeObject = { year: number; month: number; day: number; };
type DayjsLikeObject = { $y: number; $M: number; $D: number; };
import { PluginFunc, Dayjs } from 'dayjs';
import { CalendarSystemBase } from './calendarSystems/CalendarSystemBase';
type CalendarSystem = 'persian' | 'gregorian' | 'islamic' | 'julian' | 'indian' | 'hebrew' | 'ethiopian' | 'coptic' | 'buddhist' | 'japanese' | 'roc' | 'nanakshahi' | 'isoWeek' | 'week' | 'quarter' | 'month' | 'year' | 'decade' | 'century' | 'millennium';

declare module 'dayjs' {
Expand All @@ -25,14 +23,5 @@ declare module 'dayjs' {
const fromCalendarSystem: DayjsConstructor["fromCalendarSystem"];
}

interface CalendarSystemBase {
daysInMonth(year: number, month: number): number;
startOf(year: number, month: number, day: number, units: OpUnitType): Dayjs;
endOf(year: number, month: number, day: number, units: OpUnitType): Dayjs;
convertToGregorian(year: number, month: number, day: number): { year: number, month: number, day: number };
convertFromGregorian(date: Date | DateLikeObject | DayjsLikeObject | string | number | undefined | null): { year: number; month: number; day: number; };
localeOverride(locale: string): Object;
}

declare const calendarSystemsPlugin: PluginFunc;
export = calendarSystemsPlugin;

0 comments on commit 949eb8d

Please sign in to comment.