@bereasoftware/time-guard 2.5.3 → 2.5.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/calendars/index.es.js +1 -1
- package/dist/plugins/advanced-format.es.js +1 -1
- package/dist/plugins/duration.es.js +1 -1
- package/dist/plugins/relative-time.es.js +1 -1
- package/dist/time-guard.cjs +1 -1
- package/dist/time-guard.es.js +2 -2
- package/dist/time-guard.iife.js +1 -1
- package/dist/time-guard.umd.js +1 -1
- package/dist/types/adapters/temporal.adapter.d.ts +66 -0
- package/dist/types/calendars/calendar.manager.d.ts +52 -0
- package/dist/types/calendars/index.d.ts +81 -1
- package/dist/types/formatters/date.formatter.d.ts +21 -0
- package/dist/types/index.d.ts +205 -1
- package/dist/types/locales/additional.locale.d.ts +5 -0
- package/dist/types/locales/asian.locale.d.ts +9 -0
- package/dist/types/locales/english.locale.d.ts +6 -0
- package/dist/types/locales/european.locale.d.ts +9 -0
- package/dist/types/locales/index.d.ts +17 -1
- package/dist/types/locales/locale.manager.d.ts +42 -0
- package/dist/types/locales/middle-eastern.locale.d.ts +5 -0
- package/dist/types/locales/nordic.locale.d.ts +6 -0
- package/dist/types/locales/romance.locale.d.ts +7 -0
- package/dist/types/locales/slavic.locale.d.ts +6 -0
- package/dist/types/locales/spanish.locale.d.ts +5 -0
- package/dist/types/plugins/advanced-format/index.d.ts +15 -0
- package/dist/types/plugins/advanced-format.d.ts +5 -0
- package/dist/types/plugins/duration/index.d.ts +107 -0
- package/dist/types/plugins/duration/types.d.ts +85 -0
- package/dist/types/plugins/duration.d.ts +5 -0
- package/dist/types/plugins/index.d.ts +10 -0
- package/dist/types/plugins/manager.d.ts +58 -0
- package/dist/types/plugins/relative-time/index.d.ts +39 -0
- package/dist/types/plugins/relative-time/types.d.ts +27 -0
- package/dist/types/plugins/relative-time.d.ts +5 -0
- package/dist/types/types/index.d.ts +586 -0
- package/dist/types/utils/duration-locale.d.ts +33 -0
- package/package.json +1 -1
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { Temporal } from '@js-temporal/polyfill';
|
|
2
|
+
type TemporalPlainDateTime = Temporal.PlainDateTime;
|
|
3
|
+
type TemporalZonedDateTime = Temporal.ZonedDateTime;
|
|
4
|
+
/**
|
|
5
|
+
* Adapter for Temporal date/time operations
|
|
6
|
+
*/
|
|
7
|
+
export declare class TemporalAdapter {
|
|
8
|
+
/**
|
|
9
|
+
* Parse various input formats to Temporal.PlainDateTime
|
|
10
|
+
*/
|
|
11
|
+
static parseToPlainDateTime(input: unknown): TemporalPlainDateTime;
|
|
12
|
+
/**
|
|
13
|
+
* Convert JavaScript Date to Temporal.PlainDateTime
|
|
14
|
+
*/
|
|
15
|
+
static fromDate(date: Date): TemporalPlainDateTime;
|
|
16
|
+
/**
|
|
17
|
+
* Convert Unix timestamp (milliseconds) to Temporal.PlainDateTime
|
|
18
|
+
*/
|
|
19
|
+
static fromUnix(timestamp: number): TemporalPlainDateTime;
|
|
20
|
+
/**
|
|
21
|
+
* Parse ISO string to Temporal.PlainDateTime
|
|
22
|
+
*/
|
|
23
|
+
static parseISOString(iso: string): TemporalPlainDateTime;
|
|
24
|
+
/**
|
|
25
|
+
* Create from object with date components
|
|
26
|
+
*/
|
|
27
|
+
static fromObject(obj: Record<string, any>): TemporalPlainDateTime;
|
|
28
|
+
/**
|
|
29
|
+
* Convert Temporal.PlainDateTime to JavaScript Date
|
|
30
|
+
*/
|
|
31
|
+
static toDate(temporal: TemporalPlainDateTime | TemporalZonedDateTime): Date;
|
|
32
|
+
/**
|
|
33
|
+
* Convert to Unix timestamp (milliseconds)
|
|
34
|
+
*/
|
|
35
|
+
static toUnix(temporal: TemporalPlainDateTime | TemporalZonedDateTime): number;
|
|
36
|
+
/**
|
|
37
|
+
* Convert to ISO string
|
|
38
|
+
*/
|
|
39
|
+
static toISOString(temporal: TemporalPlainDateTime | TemporalZonedDateTime): string;
|
|
40
|
+
/**
|
|
41
|
+
* Ensure we have a PlainDateTime
|
|
42
|
+
*/
|
|
43
|
+
static toPlainDateTime(temporal: TemporalPlainDateTime | TemporalZonedDateTime): TemporalPlainDateTime;
|
|
44
|
+
/**
|
|
45
|
+
* Type guards
|
|
46
|
+
*/
|
|
47
|
+
static isPlainDateTime(obj: unknown): obj is TemporalPlainDateTime;
|
|
48
|
+
static isZonedDateTime(obj: unknown): obj is TemporalZonedDateTime;
|
|
49
|
+
static isPlainDate(obj: unknown): obj is any;
|
|
50
|
+
static isPlainTime(obj: unknown): obj is any;
|
|
51
|
+
/**
|
|
52
|
+
* Get current time as PlainDateTime
|
|
53
|
+
*/
|
|
54
|
+
static now(): TemporalPlainDateTime;
|
|
55
|
+
/**
|
|
56
|
+
* Get current time as ZonedDateTime with timezone
|
|
57
|
+
*/
|
|
58
|
+
static nowInTimezone(timezone: string): TemporalZonedDateTime;
|
|
59
|
+
/**
|
|
60
|
+
* Compare two Temporal.PlainDateTime objects
|
|
61
|
+
* Returns: -1 if dt1 < dt2, 0 if equal, 1 if dt1 > dt2
|
|
62
|
+
* Uses ISO string comparison as fallback for polyfills that don't have Temporal.PlainDateTime.compare
|
|
63
|
+
*/
|
|
64
|
+
static compare(dt1: TemporalPlainDateTime, dt2: TemporalPlainDateTime): number;
|
|
65
|
+
}
|
|
66
|
+
export {};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { ICalendarSystem, ICalendarManager } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Gregorian Calendar System (ISO 8601 default)
|
|
4
|
+
*/
|
|
5
|
+
export declare class GregorianCalendar implements ICalendarSystem {
|
|
6
|
+
readonly id = "gregory";
|
|
7
|
+
readonly name = "Gregorian Calendar";
|
|
8
|
+
readonly locale = "en";
|
|
9
|
+
private monthNames;
|
|
10
|
+
private monthNamesShort;
|
|
11
|
+
private weekdayNames;
|
|
12
|
+
private weekdayNamesShort;
|
|
13
|
+
getMonthName(month: number, short?: boolean): string;
|
|
14
|
+
getWeekdayName(day: number, short?: boolean): string;
|
|
15
|
+
isLeapYear(year: number): boolean;
|
|
16
|
+
daysInMonth(year: number, month: number): number;
|
|
17
|
+
daysInYear(year: number): number;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Calendar Manager - Singleton for managing calendar systems
|
|
21
|
+
*/
|
|
22
|
+
export declare class CalendarManager implements ICalendarManager {
|
|
23
|
+
private static instance;
|
|
24
|
+
private calendars;
|
|
25
|
+
private defaultCalendar;
|
|
26
|
+
private constructor();
|
|
27
|
+
/**
|
|
28
|
+
* Get singleton instance
|
|
29
|
+
*/
|
|
30
|
+
static getInstance(): CalendarManager;
|
|
31
|
+
/**
|
|
32
|
+
* Register a new calendar system
|
|
33
|
+
*/
|
|
34
|
+
register(calendar: ICalendarSystem): void;
|
|
35
|
+
/**
|
|
36
|
+
* Get calendar by ID
|
|
37
|
+
*/
|
|
38
|
+
get(id: string): ICalendarSystem | undefined;
|
|
39
|
+
/**
|
|
40
|
+
* List all available calendars
|
|
41
|
+
*/
|
|
42
|
+
list(): string[];
|
|
43
|
+
/**
|
|
44
|
+
* Set default calendar
|
|
45
|
+
*/
|
|
46
|
+
setDefault(id: string): void;
|
|
47
|
+
/**
|
|
48
|
+
* Get default calendar
|
|
49
|
+
*/
|
|
50
|
+
getDefault(): ICalendarSystem;
|
|
51
|
+
}
|
|
52
|
+
export declare const calendarManager: CalendarManager;
|
|
@@ -1 +1,81 @@
|
|
|
1
|
-
|
|
1
|
+
import { ICalendarSystem } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Islamic Calendar (Hijri)
|
|
4
|
+
* @experimental Uses simplified calculations. May not be accurate for all dates.
|
|
5
|
+
*/
|
|
6
|
+
export declare class IslamicCalendar implements ICalendarSystem {
|
|
7
|
+
readonly id = "islamic";
|
|
8
|
+
readonly name = "Islamic Calendar (Hijri)";
|
|
9
|
+
readonly locale = "ar";
|
|
10
|
+
private monthNames;
|
|
11
|
+
getMonthName(month: number): string;
|
|
12
|
+
getWeekdayName(day: number, short?: boolean): string;
|
|
13
|
+
isLeapYear(year: number): boolean;
|
|
14
|
+
daysInMonth(year: number, month: number): number;
|
|
15
|
+
daysInYear(year: number): number;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Hebrew Calendar
|
|
19
|
+
* @experimental Uses simplified calculations. May not be accurate for all dates.
|
|
20
|
+
*/
|
|
21
|
+
export declare class HebrewCalendar implements ICalendarSystem {
|
|
22
|
+
readonly id = "hebrew";
|
|
23
|
+
readonly name = "Hebrew Calendar";
|
|
24
|
+
readonly locale = "he";
|
|
25
|
+
private monthNames;
|
|
26
|
+
getMonthName(month: number): string;
|
|
27
|
+
getWeekdayName(day: number, short?: boolean): string;
|
|
28
|
+
isLeapYear(year: number): boolean;
|
|
29
|
+
daysInMonth(_year: number, month: number): number;
|
|
30
|
+
daysInYear(year: number): number;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Chinese Calendar
|
|
34
|
+
* @experimental Uses simplified calculations. May not be accurate for all dates.
|
|
35
|
+
*/
|
|
36
|
+
export declare class ChineseCalendar implements ICalendarSystem {
|
|
37
|
+
readonly id = "chinese";
|
|
38
|
+
readonly name = "Chinese Calendar";
|
|
39
|
+
readonly locale = "zh";
|
|
40
|
+
private monthNames;
|
|
41
|
+
private terrestrialBranches;
|
|
42
|
+
getMonthName(month: number): string;
|
|
43
|
+
getWeekdayName(day: number, short?: boolean): string;
|
|
44
|
+
isLeapYear(year: number): boolean;
|
|
45
|
+
daysInMonth(_year: number, month: number): number;
|
|
46
|
+
daysInYear(year: number): number;
|
|
47
|
+
/**
|
|
48
|
+
* Get zodiac sign for year
|
|
49
|
+
*/
|
|
50
|
+
getZodiacSign(year: number): string;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Japanese Calendar
|
|
54
|
+
* @experimental Uses Gregorian rules post-1873. Historical dates may not be accurate.
|
|
55
|
+
*/
|
|
56
|
+
export declare class JapaneseCalendar implements ICalendarSystem {
|
|
57
|
+
readonly id = "japanese";
|
|
58
|
+
readonly name = "Japanese Calendar";
|
|
59
|
+
readonly locale = "ja";
|
|
60
|
+
private monthNames;
|
|
61
|
+
getMonthName(month: number): string;
|
|
62
|
+
getWeekdayName(day: number, short?: boolean): string;
|
|
63
|
+
isLeapYear(year: number): boolean;
|
|
64
|
+
daysInMonth(year: number, month: number): number;
|
|
65
|
+
daysInYear(year: number): number;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Buddhist Calendar
|
|
69
|
+
* @experimental Uses Gregorian rules with BE year offset (CE + 543).
|
|
70
|
+
*/
|
|
71
|
+
export declare class BuddhistCalendar implements ICalendarSystem {
|
|
72
|
+
readonly id = "buddhist";
|
|
73
|
+
readonly name = "Buddhist Calendar";
|
|
74
|
+
readonly locale = "th";
|
|
75
|
+
private monthNames;
|
|
76
|
+
getMonthName(month: number): string;
|
|
77
|
+
getWeekdayName(day: number): string;
|
|
78
|
+
isLeapYear(year: number): boolean;
|
|
79
|
+
daysInMonth(year: number, month: number): number;
|
|
80
|
+
daysInYear(year: number): number;
|
|
81
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { IDateFormatter, FormatPreset } from '../types';
|
|
2
|
+
import { Temporal } from '@js-temporal/polyfill';
|
|
3
|
+
/**
|
|
4
|
+
* Date Formatter implementation
|
|
5
|
+
*/
|
|
6
|
+
export declare class DateFormatter implements IDateFormatter {
|
|
7
|
+
private localeManager;
|
|
8
|
+
constructor();
|
|
9
|
+
/**
|
|
10
|
+
* Format date with pattern and locale
|
|
11
|
+
*/
|
|
12
|
+
format(date: Temporal.PlainDateTime, pattern: string, locale?: string): string;
|
|
13
|
+
/**
|
|
14
|
+
* Get format pattern for preset
|
|
15
|
+
*/
|
|
16
|
+
getPreset(preset: FormatPreset): string;
|
|
17
|
+
/**
|
|
18
|
+
* Format with preset
|
|
19
|
+
*/
|
|
20
|
+
formatPreset(date: Temporal.PlainDateTime, preset: FormatPreset, locale?: string): string;
|
|
21
|
+
}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1 +1,205 @@
|
|
|
1
|
-
|
|
1
|
+
import { ITimeGuard, ITimeGuardConfig, Unit, FormatPreset, IRoundOptions, IDurationOptions, IDiffResult, IDiffOptions, DurationParts, IDurationExplanation, IFormattableDuration } from './types';
|
|
2
|
+
import { LocaleManager, EN_LOCALE, ES_LOCALE } from './locales/locale.manager';
|
|
3
|
+
/**
|
|
4
|
+
* Diff result object that allows chaining with .as()
|
|
5
|
+
*
|
|
6
|
+
* Supports two modes:
|
|
7
|
+
* - 'exact': Returns precise time differences
|
|
8
|
+
* - 'calendar': Returns calendar-aware breakdown
|
|
9
|
+
*/
|
|
10
|
+
declare class DiffResult implements IDiffResult, IFormattableDuration {
|
|
11
|
+
private _value;
|
|
12
|
+
private _tg1;
|
|
13
|
+
private _tg2;
|
|
14
|
+
private _mode;
|
|
15
|
+
private _breakdownData;
|
|
16
|
+
private _locale;
|
|
17
|
+
constructor(value: number, tg1: TimeGuard, tg2: TimeGuard, mode?: 'calendar' | 'exact', breakdownData?: DurationParts, locale?: string);
|
|
18
|
+
as(unit: Unit): number;
|
|
19
|
+
breakdown(): DurationParts | null;
|
|
20
|
+
format(locale?: string): string;
|
|
21
|
+
getMode(): 'calendar' | 'exact';
|
|
22
|
+
valueOf(): number;
|
|
23
|
+
toString(): string;
|
|
24
|
+
toJSON(): number;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* DurationResult class - Represents a duration breakdown with humanize support
|
|
28
|
+
* Returned by until(), since(), and between() methods
|
|
29
|
+
*/
|
|
30
|
+
export declare class DurationResult implements DurationParts, IFormattableDuration {
|
|
31
|
+
years: number;
|
|
32
|
+
months: number;
|
|
33
|
+
weeks: number;
|
|
34
|
+
days: number;
|
|
35
|
+
hours: number;
|
|
36
|
+
minutes: number;
|
|
37
|
+
seconds: number;
|
|
38
|
+
milliseconds: number;
|
|
39
|
+
private _locale;
|
|
40
|
+
private _startDate?;
|
|
41
|
+
private _endDate?;
|
|
42
|
+
private _steps;
|
|
43
|
+
private _mode;
|
|
44
|
+
private _leapYearFlags;
|
|
45
|
+
private _calculationTimeMs;
|
|
46
|
+
constructor(parts: DurationParts, locale?: string, metadata?: {
|
|
47
|
+
startDate?: string;
|
|
48
|
+
endDate?: string;
|
|
49
|
+
steps?: string[];
|
|
50
|
+
mode?: 'exact' | 'estimated';
|
|
51
|
+
leapYearFlags?: Array<{
|
|
52
|
+
year: number;
|
|
53
|
+
isLeap: boolean;
|
|
54
|
+
daysInFebruary: number;
|
|
55
|
+
}>;
|
|
56
|
+
calculationTimeMs?: number;
|
|
57
|
+
});
|
|
58
|
+
humanize(options?: {
|
|
59
|
+
locale?: string;
|
|
60
|
+
fullBreakdown?: boolean;
|
|
61
|
+
numeric?: 'always' | 'auto';
|
|
62
|
+
}): string;
|
|
63
|
+
total(unit: Unit): number;
|
|
64
|
+
toString(): string;
|
|
65
|
+
toJSON(): Record<string, number>;
|
|
66
|
+
explain(): IDurationExplanation;
|
|
67
|
+
private generateExplanationSteps;
|
|
68
|
+
private pluralizeUnit;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* TimeRange - Fluent API for date range operations
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* TimeGuard.range('2024-01-15', '2024-03-20')
|
|
75
|
+
* .toDuration().humanize() // "2 months and 5 days"
|
|
76
|
+
* .inMonths() // 2.1355 (precise decimal)
|
|
77
|
+
*/
|
|
78
|
+
export declare class TimeRange {
|
|
79
|
+
private _start;
|
|
80
|
+
private _end;
|
|
81
|
+
constructor(start: TimeGuard, end: TimeGuard);
|
|
82
|
+
toDuration(): DurationResult;
|
|
83
|
+
inMonths(): number;
|
|
84
|
+
humanize(options?: {
|
|
85
|
+
locale?: string;
|
|
86
|
+
fullBreakdown?: boolean;
|
|
87
|
+
numeric?: 'always' | 'auto';
|
|
88
|
+
}): string;
|
|
89
|
+
in(unit: Unit): number;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* TimeGuard implementation - Main facade class
|
|
93
|
+
*/
|
|
94
|
+
export declare class TimeGuard implements ITimeGuard {
|
|
95
|
+
private temporal;
|
|
96
|
+
private config;
|
|
97
|
+
private formatterInstance;
|
|
98
|
+
private static readonly ZERO_DURATION;
|
|
99
|
+
private static isLeapYearValue;
|
|
100
|
+
private static toDurationParts;
|
|
101
|
+
constructor(input?: unknown, config?: ITimeGuardConfig);
|
|
102
|
+
static now(config?: ITimeGuardConfig): TimeGuard;
|
|
103
|
+
static from(input: unknown, config?: ITimeGuardConfig): TimeGuard;
|
|
104
|
+
static fromTemporal(temporal: any, // Temporal.PlainDateTime | Temporal.ZonedDateTime
|
|
105
|
+
config?: ITimeGuardConfig): TimeGuard;
|
|
106
|
+
/**
|
|
107
|
+
* Calculate duration between two dates - always returns positive duration
|
|
108
|
+
*
|
|
109
|
+
* @example
|
|
110
|
+
* TimeGuard.between(start, end).humanize() // "2 months and 5 days"
|
|
111
|
+
* TimeGuard.between(end, start).humanize() // "2 months and 5 days" (still positive)
|
|
112
|
+
*/
|
|
113
|
+
static between(date1: TimeGuard, date2: TimeGuard): DurationResult;
|
|
114
|
+
/**
|
|
115
|
+
* Create a TimeRange for fluent duration calculations
|
|
116
|
+
*
|
|
117
|
+
* @example
|
|
118
|
+
* TimeGuard.range("2024-01-15", "2024-03-20").humanize() // "2 months and 5 days"
|
|
119
|
+
*/
|
|
120
|
+
static range(start: unknown, end: unknown): TimeRange;
|
|
121
|
+
toTemporal(): any;
|
|
122
|
+
toDate(): Date;
|
|
123
|
+
toISOString(): string;
|
|
124
|
+
valueOf(): number;
|
|
125
|
+
unix(): number;
|
|
126
|
+
toJSON(): string;
|
|
127
|
+
toString(): string;
|
|
128
|
+
locale(): string;
|
|
129
|
+
locale(locale: string): TimeGuard;
|
|
130
|
+
timezone(): string | null;
|
|
131
|
+
timezone(timezone: string): TimeGuard;
|
|
132
|
+
format(pattern: string | FormatPreset): string;
|
|
133
|
+
get(component: Unit): number;
|
|
134
|
+
add(units: Partial<Record<Unit, number>>): TimeGuard;
|
|
135
|
+
subtract(units: Partial<Record<Unit, number>>): TimeGuard;
|
|
136
|
+
diff(other: TimeGuard): DiffResult;
|
|
137
|
+
diff(other: TimeGuard, unit: Unit): number;
|
|
138
|
+
diff(other: TimeGuard, options: IDiffOptions): DiffResult;
|
|
139
|
+
isBefore(other: TimeGuard): boolean;
|
|
140
|
+
isAfter(other: TimeGuard): boolean;
|
|
141
|
+
isSame(other: TimeGuard, unit?: Unit): boolean;
|
|
142
|
+
isBetween(start: TimeGuard, end: TimeGuard, unit?: Unit, inclusivity?: '[)' | '()' | '[]' | '(]'): boolean;
|
|
143
|
+
clone(): TimeGuard;
|
|
144
|
+
startOf(unit: Unit): TimeGuard;
|
|
145
|
+
endOf(unit: Unit): TimeGuard;
|
|
146
|
+
set(values: Partial<Record<Unit, number>>): TimeGuard;
|
|
147
|
+
year(): number;
|
|
148
|
+
month(): number;
|
|
149
|
+
day(): number;
|
|
150
|
+
hour(): number;
|
|
151
|
+
minute(): number;
|
|
152
|
+
second(): number;
|
|
153
|
+
millisecond(): number;
|
|
154
|
+
dayOfWeek(): number;
|
|
155
|
+
dayOfYear(): number;
|
|
156
|
+
weekOfYear(): number;
|
|
157
|
+
daysInMonth(): number;
|
|
158
|
+
daysInYear(): number;
|
|
159
|
+
inLeapYear(): boolean;
|
|
160
|
+
until(other: TimeGuard, options?: IDurationOptions): DurationResult;
|
|
161
|
+
private generateUntilSteps;
|
|
162
|
+
round(options?: IRoundOptions): TimeGuard;
|
|
163
|
+
toPlainDate(): {
|
|
164
|
+
year: number;
|
|
165
|
+
month: number;
|
|
166
|
+
day: number;
|
|
167
|
+
dayOfWeek: number;
|
|
168
|
+
};
|
|
169
|
+
toPlainTime(): {
|
|
170
|
+
hour: number;
|
|
171
|
+
minute: number;
|
|
172
|
+
second: number;
|
|
173
|
+
millisecond: number;
|
|
174
|
+
};
|
|
175
|
+
withDate(year: number, month: number, day: number): TimeGuard;
|
|
176
|
+
withTime(hour: number, minute?: number, second?: number, millisecond?: number): TimeGuard;
|
|
177
|
+
getOffset(): string;
|
|
178
|
+
getOffsetNanoseconds(): number;
|
|
179
|
+
getTimeZoneId(): string | null;
|
|
180
|
+
startOfDay(): TimeGuard;
|
|
181
|
+
endOfDay(): TimeGuard;
|
|
182
|
+
since(other: TimeGuard, options?: IDurationOptions): DurationResult;
|
|
183
|
+
toDurationString(other?: TimeGuard): string;
|
|
184
|
+
isPast(): boolean;
|
|
185
|
+
isFuture(): boolean;
|
|
186
|
+
isToday(): boolean;
|
|
187
|
+
isTomorrow(): boolean;
|
|
188
|
+
isYesterday(): boolean;
|
|
189
|
+
}
|
|
190
|
+
export type { ITimeGuard, ITimeGuardConfig, ITimeGuardFactory, ITimeGuardPlugin, IDateParser, IDateFormatter, ILocaleManager, IDateArithmetic, IDateQuery, IDateManipulation, ITimezoneAdapter, ICalendarSystem, ICalendarManager, IRoundOptions, IDurationOptions, IDurationResult, IDurationExplanation, IHumanizeOptions, IDiffResult, IDiffOptions, DurationParts, Unit, FormatPreset, ILocale, } from './types';
|
|
191
|
+
export { TemporalAdapter } from './adapters/temporal.adapter';
|
|
192
|
+
export { LocaleManager, EN_LOCALE, ES_LOCALE };
|
|
193
|
+
export { getAvailableLocales, LOCALES_COUNT, ALL_LOCALES, registerAllLocales } from './locales/index';
|
|
194
|
+
export { DateFormatter } from './formatters/date.formatter';
|
|
195
|
+
export { CalendarManager, GregorianCalendar, calendarManager, } from './calendars/calendar.manager';
|
|
196
|
+
export { IslamicCalendar, HebrewCalendar, ChineseCalendar, JapaneseCalendar, BuddhistCalendar, } from './calendars/index';
|
|
197
|
+
export * from './plugins/index';
|
|
198
|
+
export { PluginManager } from './plugins/manager';
|
|
199
|
+
export { RelativeTimePlugin, default as relativeTimePlugin } from './plugins/relative-time';
|
|
200
|
+
export type { RelativeTimeConfig, RelativeTimeFormats, RelativeTimeThreshold } from './plugins/relative-time/types';
|
|
201
|
+
export { DurationPlugin, Duration, default as durationPlugin } from './plugins/duration';
|
|
202
|
+
export type { IDuration, DurationInput, DurationObject, DurationUnit } from './plugins/duration/types';
|
|
203
|
+
export { AdvancedFormatPlugin, default as advancedFormatPlugin } from './plugins/advanced-format';
|
|
204
|
+
export declare function timeGuard(input?: unknown, config?: ITimeGuardConfig): TimeGuard;
|
|
205
|
+
export declare const version: string;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ILocale } from '../types';
|
|
2
|
+
export declare const JA_LOCALE_DATA: ILocale;
|
|
3
|
+
export declare const ZH_CN_LOCALE_DATA: ILocale;
|
|
4
|
+
export declare const ZH_TW_LOCALE_DATA: ILocale;
|
|
5
|
+
export declare const KO_LOCALE_DATA: ILocale;
|
|
6
|
+
export declare const TH_LOCALE_DATA: ILocale;
|
|
7
|
+
export declare const VI_LOCALE_DATA: ILocale;
|
|
8
|
+
export declare const ID_LOCALE_DATA: ILocale;
|
|
9
|
+
export declare const ASIAN_LOCALES: Record<string, ILocale>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ILocale } from '../types';
|
|
2
|
+
export declare const EN_LOCALE_DATA: ILocale;
|
|
3
|
+
export declare const EN_AU_LOCALE_DATA: ILocale;
|
|
4
|
+
export declare const EN_GB_LOCALE_DATA: ILocale;
|
|
5
|
+
export declare const EN_CA_LOCALE_DATA: ILocale;
|
|
6
|
+
export declare const ENGLISH_LOCALES: Record<string, ILocale>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ILocale } from '../types';
|
|
2
|
+
export declare const DE_LOCALE_DATA: ILocale;
|
|
3
|
+
export declare const NL_LOCALE_DATA: ILocale;
|
|
4
|
+
export declare const EL_LOCALE_DATA: ILocale;
|
|
5
|
+
export declare const HU_LOCALE_DATA: ILocale;
|
|
6
|
+
export declare const EU_LOCALE_DATA: ILocale;
|
|
7
|
+
export declare const CA_LOCALE_DATA: ILocale;
|
|
8
|
+
export declare const TR_LOCALE_DATA: ILocale;
|
|
9
|
+
export declare const EUROPEAN_LOCALES: Record<string, ILocale>;
|
|
@@ -1 +1,17 @@
|
|
|
1
|
-
|
|
1
|
+
import { ILocale } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Aggregated locale data from all modules
|
|
4
|
+
*/
|
|
5
|
+
export declare const ALL_LOCALES: Record<string, ILocale>;
|
|
6
|
+
/**
|
|
7
|
+
* Register all locales into a locale map
|
|
8
|
+
*/
|
|
9
|
+
export declare function registerAllLocales(localeMap: Map<string, ILocale> | Record<string, ILocale>): void;
|
|
10
|
+
/**
|
|
11
|
+
* Get all available locales
|
|
12
|
+
*/
|
|
13
|
+
export declare function getAvailableLocales(): string[];
|
|
14
|
+
/**
|
|
15
|
+
* Total locales count (minimum 40 required)
|
|
16
|
+
*/
|
|
17
|
+
export declare const LOCALES_COUNT = 40;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { ILocale, ILocaleManager } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* English locale data
|
|
4
|
+
*/
|
|
5
|
+
export declare const EN_LOCALE: ILocale;
|
|
6
|
+
/**
|
|
7
|
+
* Spanish locale data (sample for i18n support)
|
|
8
|
+
*/
|
|
9
|
+
export declare const ES_LOCALE: ILocale;
|
|
10
|
+
/**
|
|
11
|
+
* Locale Manager - implements ILocaleManager
|
|
12
|
+
*/
|
|
13
|
+
export declare class LocaleManager implements ILocaleManager {
|
|
14
|
+
private static instance;
|
|
15
|
+
private locales;
|
|
16
|
+
private currentLocale;
|
|
17
|
+
/**
|
|
18
|
+
* Singleton pattern
|
|
19
|
+
*/
|
|
20
|
+
static getInstance(): LocaleManager;
|
|
21
|
+
private constructor();
|
|
22
|
+
/**
|
|
23
|
+
* Set or register a locale
|
|
24
|
+
*/
|
|
25
|
+
setLocale(locale: string, data?: ILocale): void;
|
|
26
|
+
/**
|
|
27
|
+
* Get locale information
|
|
28
|
+
*/
|
|
29
|
+
getLocale(locale?: string): ILocale;
|
|
30
|
+
/**
|
|
31
|
+
* List all registered locales
|
|
32
|
+
*/
|
|
33
|
+
listLocales(): string[];
|
|
34
|
+
/**
|
|
35
|
+
* Get current locale
|
|
36
|
+
*/
|
|
37
|
+
getCurrentLocale(): string;
|
|
38
|
+
/**
|
|
39
|
+
* Load multiple locales
|
|
40
|
+
*/
|
|
41
|
+
loadLocales(locales: Record<string, ILocale>): void;
|
|
42
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ILocale } from '../types';
|
|
2
|
+
export declare const SV_LOCALE_DATA: ILocale;
|
|
3
|
+
export declare const NB_LOCALE_DATA: ILocale;
|
|
4
|
+
export declare const DA_LOCALE_DATA: ILocale;
|
|
5
|
+
export declare const FI_LOCALE_DATA: ILocale;
|
|
6
|
+
export declare const NORDIC_LOCALES: Record<string, ILocale>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ILocale } from '../types';
|
|
2
|
+
export declare const FR_LOCALE_DATA: ILocale;
|
|
3
|
+
export declare const IT_LOCALE_DATA: ILocale;
|
|
4
|
+
export declare const PT_LOCALE_DATA: ILocale;
|
|
5
|
+
export declare const PT_BR_LOCALE_DATA: ILocale;
|
|
6
|
+
export declare const RO_LOCALE_DATA: ILocale;
|
|
7
|
+
export declare const ROMANCE_LOCALES: Record<string, ILocale>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ILocale } from '../types';
|
|
2
|
+
export declare const RU_LOCALE_DATA: ILocale;
|
|
3
|
+
export declare const PL_LOCALE_DATA: ILocale;
|
|
4
|
+
export declare const CS_LOCALE_DATA: ILocale;
|
|
5
|
+
export declare const SK_LOCALE_DATA: ILocale;
|
|
6
|
+
export declare const SLAVIC_LOCALES: Record<string, ILocale>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ITimeGuardPlugin } from '../../types';
|
|
2
|
+
import { TimeGuard } from '../../index';
|
|
3
|
+
export declare class AdvancedFormatPlugin implements ITimeGuardPlugin {
|
|
4
|
+
name: string;
|
|
5
|
+
version: string;
|
|
6
|
+
/**
|
|
7
|
+
* Install plugin into TimeGuard
|
|
8
|
+
*/
|
|
9
|
+
install(TimeGuardClass: typeof TimeGuard): void;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Create and export default instance
|
|
13
|
+
*/
|
|
14
|
+
declare const _default: AdvancedFormatPlugin;
|
|
15
|
+
export default _default;
|