@bereasoftware/time-guard 2.5.2 → 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/README.en.md +1 -1
- package/README.md +1 -1
- package/dist/calendars/index.es.js +1 -1
- package/dist/plugins/advanced-format.cjs.map +1 -1
- package/dist/plugins/advanced-format.es.js +1 -1
- package/dist/plugins/advanced-format.es.js.map +1 -1
- package/dist/plugins/duration.cjs.map +1 -1
- package/dist/plugins/duration.es.js +1 -1
- package/dist/plugins/duration.es.js.map +1 -1
- package/dist/plugins/relative-time.cjs.map +1 -1
- package/dist/plugins/relative-time.es.js +1 -1
- package/dist/plugins/relative-time.es.js.map +1 -1
- package/dist/time-guard.cjs +1 -1
- package/dist/time-guard.cjs.map +1 -1
- package/dist/time-guard.es.js +3586 -3587
- package/dist/time-guard.es.js.map +1 -1
- package/dist/time-guard.iife.js +1 -1
- package/dist/time-guard.iife.js.map +1 -1
- package/dist/time-guard.umd.js +1 -1
- package/dist/time-guard.umd.js.map +1 -1
- package/dist/types/index.d.ts +188 -3
- package/dist/types/plugins/advanced-format/index.d.ts +1 -1
- package/dist/types/plugins/advanced-format.d.ts +6 -0
- package/dist/types/plugins/duration/index.d.ts +1 -1
- package/dist/types/plugins/duration.d.ts +6 -0
- package/dist/types/plugins/manager.d.ts +1 -1
- package/dist/types/plugins/relative-time/index.d.ts +1 -1
- package/dist/types/plugins/relative-time.d.ts +6 -0
- package/dist/types/types/index.d.ts +3 -3
- package/package.json +6 -6
- package/dist/types/time-guard.d.ts +0 -270
package/dist/types/index.d.ts
CHANGED
|
@@ -1,7 +1,192 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { ITimeGuardConfig } from './types';
|
|
1
|
+
import { ITimeGuard, ITimeGuardConfig, Unit, FormatPreset, IRoundOptions, IDurationOptions, IDiffResult, IDiffOptions, DurationParts, IDurationExplanation, IFormattableDuration } from './types';
|
|
3
2
|
import { LocaleManager, EN_LOCALE, ES_LOCALE } from './locales/locale.manager';
|
|
4
|
-
|
|
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
|
+
}
|
|
5
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';
|
|
6
191
|
export { TemporalAdapter } from './adapters/temporal.adapter';
|
|
7
192
|
export { LocaleManager, EN_LOCALE, ES_LOCALE };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ITimeGuardPlugin } from '../../types';
|
|
2
|
-
import { TimeGuard } from '../../
|
|
2
|
+
import { TimeGuard } from '../../index';
|
|
3
3
|
import { DurationInput, DurationObject, DurationUnit, IDuration } from './types';
|
|
4
4
|
/**
|
|
5
5
|
* Duration class - represents time span following ISO 8601 standard
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ITimeGuardPlugin } from '../types';
|
|
2
|
-
import { TimeGuard } from '../
|
|
2
|
+
import { TimeGuard } from '../index';
|
|
3
3
|
/**
|
|
4
4
|
* Plugin Manager - handles plugin registration and initialization
|
|
5
5
|
* Uses Singleton pattern to ensure single instance across application
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ITimeGuardPlugin } from '../../types';
|
|
2
|
-
import { TimeGuard } from '../../
|
|
2
|
+
import { TimeGuard } from '../../index';
|
|
3
3
|
import { RelativeTimeConfig, RelativeTimeFormats } from './types';
|
|
4
4
|
export declare class RelativeTimePlugin implements ITimeGuardPlugin {
|
|
5
5
|
name: string;
|
|
@@ -528,14 +528,14 @@ export interface ITimeGuardFactory {
|
|
|
528
528
|
}
|
|
529
529
|
/**
|
|
530
530
|
* Forward declaration for TimeGuard class
|
|
531
|
-
* Implementation is in ./
|
|
531
|
+
* Implementation is in ./index.ts, exported via ./index.ts
|
|
532
532
|
*/
|
|
533
533
|
export declare class TimeGuard {
|
|
534
534
|
constructor(input?: unknown, config?: ITimeGuardConfig);
|
|
535
535
|
}
|
|
536
536
|
/**
|
|
537
537
|
* Forward declaration for DurationResult class
|
|
538
|
-
* Implementation is in ./
|
|
538
|
+
* Implementation is in ./index.ts, exported via ./index.ts
|
|
539
539
|
*/
|
|
540
540
|
export declare class DurationResult implements IDurationResult {
|
|
541
541
|
constructor(parts: DurationParts, locale?: string, metadata?: {
|
|
@@ -571,7 +571,7 @@ export declare class DurationResult implements IDurationResult {
|
|
|
571
571
|
/**
|
|
572
572
|
* Forward declaration for TimeRange class
|
|
573
573
|
* Fluent API for date range operations with semantic naming
|
|
574
|
-
* Implementation is in ./
|
|
574
|
+
* Implementation is in ./index.ts, exported via ./index.ts
|
|
575
575
|
*/
|
|
576
576
|
export declare class TimeRange {
|
|
577
577
|
constructor(start: TimeGuard, end: TimeGuard);
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bereasoftware/time-guard",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "2.5.
|
|
4
|
+
"version": "2.5.4",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"main": "./dist/time-guard.cjs",
|
|
8
8
|
"module": "./dist/time-guard.es.js",
|
|
9
|
-
"types": "./dist/types/
|
|
9
|
+
"types": "./dist/types/index.d.ts",
|
|
10
10
|
"unpkg": "./dist/time-guard.umd.js",
|
|
11
11
|
"browser": {
|
|
12
12
|
"./dist/time-guard.umd.js": "./dist/time-guard.umd.js",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
},
|
|
15
15
|
"exports": {
|
|
16
16
|
".": {
|
|
17
|
-
"types": "./dist/types/
|
|
17
|
+
"types": "./dist/types/index.d.ts",
|
|
18
18
|
"import": "./dist/time-guard.es.js",
|
|
19
19
|
"require": "./dist/time-guard.cjs",
|
|
20
20
|
"default": "./dist/time-guard.es.js"
|
|
@@ -32,19 +32,19 @@
|
|
|
32
32
|
"default": "./dist/calendars/index.es.js"
|
|
33
33
|
},
|
|
34
34
|
"./plugins/relative-time": {
|
|
35
|
-
"types": "./dist/types/plugins/relative-time
|
|
35
|
+
"types": "./dist/types/plugins/relative-time.d.ts",
|
|
36
36
|
"import": "./dist/plugins/relative-time.es.js",
|
|
37
37
|
"require": "./dist/plugins/relative-time.cjs",
|
|
38
38
|
"default": "./dist/plugins/relative-time.es.js"
|
|
39
39
|
},
|
|
40
40
|
"./plugins/duration": {
|
|
41
|
-
"types": "./dist/types/plugins/duration
|
|
41
|
+
"types": "./dist/types/plugins/duration.d.ts",
|
|
42
42
|
"import": "./dist/plugins/duration.es.js",
|
|
43
43
|
"require": "./dist/plugins/duration.cjs",
|
|
44
44
|
"default": "./dist/plugins/duration.es.js"
|
|
45
45
|
},
|
|
46
46
|
"./plugins/advanced-format": {
|
|
47
|
-
"types": "./dist/types/plugins/advanced-format
|
|
47
|
+
"types": "./dist/types/plugins/advanced-format.d.ts",
|
|
48
48
|
"import": "./dist/plugins/advanced-format.es.js",
|
|
49
49
|
"require": "./dist/plugins/advanced-format.cjs",
|
|
50
50
|
"default": "./dist/plugins/advanced-format.es.js"
|
|
@@ -1,270 +0,0 @@
|
|
|
1
|
-
import { ITimeGuard, ITimeGuardConfig, Unit, FormatPreset, IRoundOptions, IDurationOptions, IDiffResult, IDiffOptions, DurationParts, IDurationExplanation, IFormattableDuration } from './types';
|
|
2
|
-
/**
|
|
3
|
-
* Diff result object that allows chaining with .as()
|
|
4
|
-
*
|
|
5
|
-
* Supports two modes:
|
|
6
|
-
* - 'exact': Returns precise time differences
|
|
7
|
-
* - 'calendar': Returns calendar-aware breakdown
|
|
8
|
-
*/
|
|
9
|
-
declare class DiffResult implements IDiffResult, IFormattableDuration {
|
|
10
|
-
private _value;
|
|
11
|
-
private _tg1;
|
|
12
|
-
private _tg2;
|
|
13
|
-
private _mode;
|
|
14
|
-
private _breakdownData;
|
|
15
|
-
private _locale;
|
|
16
|
-
constructor(value: number, tg1: TimeGuard, tg2: TimeGuard, mode?: 'calendar' | 'exact', breakdownData?: DurationParts, locale?: string);
|
|
17
|
-
as(unit: Unit): number;
|
|
18
|
-
breakdown(): DurationParts | null;
|
|
19
|
-
format(locale?: string): string;
|
|
20
|
-
getMode(): 'calendar' | 'exact';
|
|
21
|
-
valueOf(): number;
|
|
22
|
-
toString(): string;
|
|
23
|
-
toJSON(): number;
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* DurationResult class - Represents a duration breakdown with humanize support
|
|
27
|
-
* Returned by until(), since(), and between() methods
|
|
28
|
-
*/
|
|
29
|
-
export declare class DurationResult implements DurationParts, IFormattableDuration {
|
|
30
|
-
years: number;
|
|
31
|
-
months: number;
|
|
32
|
-
weeks: number;
|
|
33
|
-
days: number;
|
|
34
|
-
hours: number;
|
|
35
|
-
minutes: number;
|
|
36
|
-
seconds: number;
|
|
37
|
-
milliseconds: number;
|
|
38
|
-
private _locale;
|
|
39
|
-
private _startDate?;
|
|
40
|
-
private _endDate?;
|
|
41
|
-
private _steps;
|
|
42
|
-
private _mode;
|
|
43
|
-
private _leapYearFlags;
|
|
44
|
-
private _calculationTimeMs;
|
|
45
|
-
constructor(parts: DurationParts, locale?: string, metadata?: {
|
|
46
|
-
startDate?: string;
|
|
47
|
-
endDate?: string;
|
|
48
|
-
steps?: string[];
|
|
49
|
-
mode?: 'exact' | 'estimated';
|
|
50
|
-
leapYearFlags?: Array<{
|
|
51
|
-
year: number;
|
|
52
|
-
isLeap: boolean;
|
|
53
|
-
daysInFebruary: number;
|
|
54
|
-
}>;
|
|
55
|
-
calculationTimeMs?: number;
|
|
56
|
-
});
|
|
57
|
-
humanize(options?: {
|
|
58
|
-
locale?: string;
|
|
59
|
-
fullBreakdown?: boolean;
|
|
60
|
-
numeric?: 'always' | 'auto';
|
|
61
|
-
}): string;
|
|
62
|
-
total(unit: Unit): number;
|
|
63
|
-
toString(): string;
|
|
64
|
-
toJSON(): Record<string, number>;
|
|
65
|
-
explain(): IDurationExplanation;
|
|
66
|
-
private generateExplanationSteps;
|
|
67
|
-
private pluralizeUnit;
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* TimeGuard implementation - Main facade class
|
|
71
|
-
*/
|
|
72
|
-
/**
|
|
73
|
-
* TimeRange - Fluent API for date range operations
|
|
74
|
-
*
|
|
75
|
-
* @example
|
|
76
|
-
* TimeGuard.range('2024-01-15', '2024-03-20')
|
|
77
|
-
* .toDuration().humanize() // "2 months and 5 days"
|
|
78
|
-
* .inMonths() // 2.1355 (precise decimal)
|
|
79
|
-
*/
|
|
80
|
-
export declare class TimeRange {
|
|
81
|
-
private _start;
|
|
82
|
-
private _end;
|
|
83
|
-
constructor(start: TimeGuard, end: TimeGuard);
|
|
84
|
-
toDuration(): DurationResult;
|
|
85
|
-
inMonths(): number;
|
|
86
|
-
humanize(options?: {
|
|
87
|
-
locale?: string;
|
|
88
|
-
fullBreakdown?: boolean;
|
|
89
|
-
numeric?: 'always' | 'auto';
|
|
90
|
-
}): string;
|
|
91
|
-
in(unit: Unit): number;
|
|
92
|
-
}
|
|
93
|
-
export declare class TimeGuard implements ITimeGuard {
|
|
94
|
-
private temporal;
|
|
95
|
-
private config;
|
|
96
|
-
private formatterInstance;
|
|
97
|
-
private static readonly ZERO_DURATION;
|
|
98
|
-
private static isLeapYearValue;
|
|
99
|
-
private static toDurationParts;
|
|
100
|
-
constructor(input?: unknown, config?: ITimeGuardConfig);
|
|
101
|
-
static now(config?: ITimeGuardConfig): TimeGuard;
|
|
102
|
-
static from(input: unknown, config?: ITimeGuardConfig): TimeGuard;
|
|
103
|
-
static fromTemporal(temporal: any, // Temporal.PlainDateTime | Temporal.ZonedDateTime
|
|
104
|
-
config?: ITimeGuardConfig): TimeGuard;
|
|
105
|
-
/**
|
|
106
|
-
* Calculate duration between two dates - always returns positive duration
|
|
107
|
-
*
|
|
108
|
-
* @example
|
|
109
|
-
* TimeGuard.between(start, end).humanize() // "2 months and 5 days"
|
|
110
|
-
* TimeGuard.between(end, start).humanize() // "2 months and 5 days" (still positive)
|
|
111
|
-
*/
|
|
112
|
-
static between(date1: TimeGuard, date2: TimeGuard): DurationResult;
|
|
113
|
-
/**
|
|
114
|
-
* Create a TimeRange for fluent duration calculations
|
|
115
|
-
*
|
|
116
|
-
* @example
|
|
117
|
-
* TimeGuard.range("2024-01-15", "2024-03-20").humanize() // "2 months and 5 days"
|
|
118
|
-
*/
|
|
119
|
-
static range(start: unknown, end: unknown): TimeRange;
|
|
120
|
-
toTemporal(): any;
|
|
121
|
-
toDate(): Date;
|
|
122
|
-
toISOString(): string;
|
|
123
|
-
valueOf(): number;
|
|
124
|
-
unix(): number;
|
|
125
|
-
toJSON(): string;
|
|
126
|
-
toString(): string;
|
|
127
|
-
locale(): string;
|
|
128
|
-
locale(locale: string): TimeGuard;
|
|
129
|
-
timezone(): string | null;
|
|
130
|
-
timezone(timezone: string): TimeGuard;
|
|
131
|
-
format(pattern: string | FormatPreset): string;
|
|
132
|
-
get(component: Unit): number;
|
|
133
|
-
add(units: Partial<Record<Unit, number>>): TimeGuard;
|
|
134
|
-
subtract(units: Partial<Record<Unit, number>>): TimeGuard;
|
|
135
|
-
/**
|
|
136
|
-
* Calculate difference between two TimeGuard instances
|
|
137
|
-
*
|
|
138
|
-
* Supports multiple modes:
|
|
139
|
-
* 1. diff(other) - Returns DiffResult with fluent API (default: exact mode)
|
|
140
|
-
* 2. diff(other, unit) - Returns number (backward compatible)
|
|
141
|
-
* 3. diff(other, options) - Returns DiffResult with calendar or exact mode
|
|
142
|
-
*
|
|
143
|
-
* @example
|
|
144
|
-
* // Exact mode (default)
|
|
145
|
-
* tg1.diff(tg2).as('day') // 65
|
|
146
|
-
* // Calendar mode
|
|
147
|
-
* tg1.diff(tg2, { mode: 'calendar' }).format('en') // "2 months and 5 days"
|
|
148
|
-
*/
|
|
149
|
-
diff(other: TimeGuard): DiffResult;
|
|
150
|
-
diff(other: TimeGuard, unit: Unit): number;
|
|
151
|
-
diff(other: TimeGuard, options: IDiffOptions): DiffResult;
|
|
152
|
-
isBefore(other: TimeGuard): boolean;
|
|
153
|
-
isAfter(other: TimeGuard): boolean;
|
|
154
|
-
isSame(other: TimeGuard, unit?: Unit): boolean;
|
|
155
|
-
isBetween(start: TimeGuard, end: TimeGuard, unit?: Unit, inclusivity?: '[)' | '()' | '[]' | '(]'): boolean;
|
|
156
|
-
clone(): TimeGuard;
|
|
157
|
-
startOf(unit: Unit): TimeGuard;
|
|
158
|
-
endOf(unit: Unit): TimeGuard;
|
|
159
|
-
set(values: Partial<Record<Unit, number>>): TimeGuard;
|
|
160
|
-
year(): number;
|
|
161
|
-
month(): number;
|
|
162
|
-
day(): number;
|
|
163
|
-
hour(): number;
|
|
164
|
-
minute(): number;
|
|
165
|
-
second(): number;
|
|
166
|
-
millisecond(): number;
|
|
167
|
-
dayOfWeek(): number;
|
|
168
|
-
dayOfYear(): number;
|
|
169
|
-
weekOfYear(): number;
|
|
170
|
-
daysInMonth(): number;
|
|
171
|
-
daysInYear(): number;
|
|
172
|
-
inLeapYear(): boolean;
|
|
173
|
-
/**
|
|
174
|
-
* Calculate duration until another TimeGuard
|
|
175
|
-
* @returns Duration object with .humanize() and other methods
|
|
176
|
-
* @example
|
|
177
|
-
* start.until(end).humanize() // "2 months and 5 days"
|
|
178
|
-
* start.until(end).humanize({ fullBreakdown: true, locale: 'es' }) // "2 meses y 5 días"
|
|
179
|
-
*/
|
|
180
|
-
until(other: TimeGuard, options?: IDurationOptions): DurationResult;
|
|
181
|
-
/**
|
|
182
|
-
* Generate explanation steps for until() calculation
|
|
183
|
-
*/
|
|
184
|
-
private generateUntilSteps;
|
|
185
|
-
/**
|
|
186
|
-
* Round to a specific unit with optional rounding mode
|
|
187
|
-
*/
|
|
188
|
-
round(options?: IRoundOptions): TimeGuard;
|
|
189
|
-
/**
|
|
190
|
-
* Convert to PlainDate (removes time information)
|
|
191
|
-
*/
|
|
192
|
-
toPlainDate(): {
|
|
193
|
-
year: number;
|
|
194
|
-
month: number;
|
|
195
|
-
day: number;
|
|
196
|
-
dayOfWeek: number;
|
|
197
|
-
};
|
|
198
|
-
/**
|
|
199
|
-
* Convert to PlainTime (removes date information)
|
|
200
|
-
*/
|
|
201
|
-
toPlainTime(): {
|
|
202
|
-
hour: number;
|
|
203
|
-
minute: number;
|
|
204
|
-
second: number;
|
|
205
|
-
millisecond: number;
|
|
206
|
-
};
|
|
207
|
-
/**
|
|
208
|
-
* Create new TimeGuard with only date, keeping time from parameter
|
|
209
|
-
*/
|
|
210
|
-
withDate(year: number, month: number, day: number): TimeGuard;
|
|
211
|
-
/**
|
|
212
|
-
* Create new TimeGuard with only time, keeping date
|
|
213
|
-
*/
|
|
214
|
-
withTime(hour: number, minute?: number, second?: number, millisecond?: number): TimeGuard;
|
|
215
|
-
/**
|
|
216
|
-
* Get timezone offset in format ±HH:mm
|
|
217
|
-
*/
|
|
218
|
-
getOffset(): string;
|
|
219
|
-
/**
|
|
220
|
-
* Get timezone offset in nanoseconds
|
|
221
|
-
*/
|
|
222
|
-
getOffsetNanoseconds(): number;
|
|
223
|
-
/**
|
|
224
|
-
* Get timezone ID
|
|
225
|
-
*/
|
|
226
|
-
getTimeZoneId(): string | null;
|
|
227
|
-
/**
|
|
228
|
-
* Start of the day in current timezone
|
|
229
|
-
*/
|
|
230
|
-
startOfDay(): TimeGuard;
|
|
231
|
-
/**
|
|
232
|
-
* End of the day in current timezone
|
|
233
|
-
*/
|
|
234
|
-
endOfDay(): TimeGuard;
|
|
235
|
-
/**
|
|
236
|
-
* Calculate duration from another TimeGuard (inverse of until)
|
|
237
|
-
* Returns negative values if other is before this
|
|
238
|
-
* @returns Duration object with .humanize() and other methods
|
|
239
|
-
* @example
|
|
240
|
-
* end.since(start).humanize() // "2 months and 5 days"
|
|
241
|
-
* end.since(start).humanize({ locale: 'es' }) // "2 meses y 5 días"
|
|
242
|
-
*/
|
|
243
|
-
since(other: TimeGuard, options?: IDurationOptions): DurationResult;
|
|
244
|
-
/**
|
|
245
|
-
* Get ISO 8601 duration string
|
|
246
|
-
* Example: P1Y2M3DT4H5M6S
|
|
247
|
-
*/
|
|
248
|
-
toDurationString(other?: TimeGuard): string;
|
|
249
|
-
/**
|
|
250
|
-
* Check if this date is in the past
|
|
251
|
-
*/
|
|
252
|
-
isPast(): boolean;
|
|
253
|
-
/**
|
|
254
|
-
* Check if this date is in the future
|
|
255
|
-
*/
|
|
256
|
-
isFuture(): boolean;
|
|
257
|
-
/**
|
|
258
|
-
* Check if this date is today
|
|
259
|
-
*/
|
|
260
|
-
isToday(): boolean;
|
|
261
|
-
/**
|
|
262
|
-
* Check if this date is tomorrow
|
|
263
|
-
*/
|
|
264
|
-
isTomorrow(): boolean;
|
|
265
|
-
/**
|
|
266
|
-
* Check if this date is yesterday
|
|
267
|
-
*/
|
|
268
|
-
isYesterday(): boolean;
|
|
269
|
-
}
|
|
270
|
-
export { PluginManager } from './plugins/manager';
|