@bereasoftware/time-guard 2.6.1 → 2.7.0

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.
Files changed (98) hide show
  1. package/README.en.md +232 -0
  2. package/README.md +259 -4
  3. package/dist/angular/index.cjs +148 -0
  4. package/dist/angular/index.d.ts +2 -0
  5. package/dist/angular/index.es.js +143 -0
  6. package/dist/angular.d.ts +59 -0
  7. package/dist/calendars/index.cjs +357 -2
  8. package/dist/calendars/index.es.js +99 -68
  9. package/dist/chunk-Ddh6569R.cjs +36 -0
  10. package/dist/core-BAd7GYfw.js +1809 -0
  11. package/dist/core-CafqOI7W.cjs +1892 -0
  12. package/dist/core.d.ts +224 -0
  13. package/dist/index.d.ts +9 -0
  14. package/dist/locales/african.locale.d.ts +7 -0
  15. package/dist/locales/index.cjs +7 -1
  16. package/dist/{types/locales → locales}/index.d.ts +2 -2
  17. package/dist/locales/index.es.js +3 -3
  18. package/dist/locales/south-american.locale.d.ts +7 -0
  19. package/dist/locales-C2-lOmC8.cjs +3537 -0
  20. package/dist/{locales-DSBvgSaw.js → locales-CcuSu4P1.js} +749 -33
  21. package/dist/native/index.cjs +48 -0
  22. package/dist/native/index.d.ts +2 -0
  23. package/dist/native/index.es.js +18 -0
  24. package/dist/native.d.ts +9 -0
  25. package/dist/plugins/advanced-format.cjs +105 -2
  26. package/dist/plugins/advanced-format.es.js +63 -45
  27. package/dist/plugins/duration.cjs +258 -2
  28. package/dist/plugins/duration.es.js +165 -61
  29. package/dist/plugins/relative-time.cjs +166 -2
  30. package/dist/plugins/relative-time.es.js +74 -37
  31. package/dist/qwik/index.cjs +104 -0
  32. package/dist/qwik/index.d.ts +2 -0
  33. package/dist/qwik/index.es.js +100 -0
  34. package/dist/qwik.d.ts +32 -0
  35. package/dist/react/index.cjs +112 -0
  36. package/dist/react/index.d.ts +2 -0
  37. package/dist/react/index.es.js +103 -0
  38. package/dist/react.d.ts +46 -0
  39. package/dist/solid/index.cjs +127 -0
  40. package/dist/solid/index.d.ts +2 -0
  41. package/dist/solid/index.es.js +122 -0
  42. package/dist/solid.d.ts +53 -0
  43. package/dist/svelte/index.cjs +398 -0
  44. package/dist/svelte/index.d.ts +2 -0
  45. package/dist/svelte/index.es.js +393 -0
  46. package/dist/svelte.d.ts +88 -0
  47. package/dist/time-guard.cjs +7359 -4
  48. package/dist/time-guard.es.js +3625 -8085
  49. package/dist/time-guard.iife.js +13549 -4
  50. package/dist/time-guard.umd.js +13550 -4
  51. package/dist/types/index.d.ts +651 -127
  52. package/dist/vue/index.cjs +143 -0
  53. package/dist/vue/index.d.ts +2 -0
  54. package/dist/vue/index.es.js +137 -0
  55. package/dist/vue.d.ts +35 -0
  56. package/package.json +107 -27
  57. package/dist/calendars/index.cjs.map +0 -1
  58. package/dist/calendars/index.es.js.map +0 -1
  59. package/dist/locales-DSBvgSaw.js.map +0 -1
  60. package/dist/locales-ybx7jS8G.cjs +0 -2
  61. package/dist/locales-ybx7jS8G.cjs.map +0 -1
  62. package/dist/plugins/advanced-format.cjs.map +0 -1
  63. package/dist/plugins/advanced-format.es.js.map +0 -1
  64. package/dist/plugins/duration.cjs.map +0 -1
  65. package/dist/plugins/duration.es.js.map +0 -1
  66. package/dist/plugins/relative-time.cjs.map +0 -1
  67. package/dist/plugins/relative-time.es.js.map +0 -1
  68. package/dist/time-guard.cjs.map +0 -1
  69. package/dist/time-guard.es.js.map +0 -1
  70. package/dist/time-guard.iife.js.map +0 -1
  71. package/dist/time-guard.umd.js.map +0 -1
  72. package/dist/types/types/index.d.ts +0 -641
  73. /package/dist/{types/adapters → adapters}/temporal.adapter.d.ts +0 -0
  74. /package/dist/{types/calendars → calendars}/calendar.manager.d.ts +0 -0
  75. /package/dist/{types/calendars → calendars}/index.d.ts +0 -0
  76. /package/dist/{types/formatters → formatters}/date.formatter.d.ts +0 -0
  77. /package/dist/{types/locales → locales}/additional.locale.d.ts +0 -0
  78. /package/dist/{types/locales → locales}/asian.locale.d.ts +0 -0
  79. /package/dist/{types/locales → locales}/english.locale.d.ts +0 -0
  80. /package/dist/{types/locales → locales}/european.locale.d.ts +0 -0
  81. /package/dist/{types/locales → locales}/locale.manager.d.ts +0 -0
  82. /package/dist/{types/locales → locales}/middle-eastern.locale.d.ts +0 -0
  83. /package/dist/{types/locales → locales}/nordic.locale.d.ts +0 -0
  84. /package/dist/{types/locales → locales}/romance.locale.d.ts +0 -0
  85. /package/dist/{types/locales → locales}/slavic.locale.d.ts +0 -0
  86. /package/dist/{types/locales → locales}/spanish.locale.d.ts +0 -0
  87. /package/dist/{types/plugins → plugins}/advanced-format/index.d.ts +0 -0
  88. /package/dist/{types/plugins → plugins}/advanced-format.d.ts +0 -0
  89. /package/dist/{types/plugins → plugins}/duration/index.d.ts +0 -0
  90. /package/dist/{types/plugins → plugins}/duration/types.d.ts +0 -0
  91. /package/dist/{types/plugins → plugins}/duration.d.ts +0 -0
  92. /package/dist/{types/plugins → plugins}/index.d.ts +0 -0
  93. /package/dist/{types/plugins → plugins}/manager.d.ts +0 -0
  94. /package/dist/{types/plugins → plugins}/relative-time/index.d.ts +0 -0
  95. /package/dist/{types/plugins → plugins}/relative-time/types.d.ts +0 -0
  96. /package/dist/{types/plugins → plugins}/relative-time.d.ts +0 -0
  97. /package/dist/{types/time-guard.d.ts → time-guard.d.ts} +0 -0
  98. /package/dist/{types/utils → utils}/duration-locale.d.ts +0 -0
@@ -1,641 +0,0 @@
1
- import { Temporal } from '@js-temporal/polyfill';
2
- export type TemporalPlainDateTime = Temporal.PlainDateTime;
3
- export type TemporalZonedDateTime = Temporal.ZonedDateTime;
4
- export type TemporalPlainDate = Temporal.PlainDate;
5
- export type TemporalPlainTime = Temporal.PlainTime;
6
- export type TemporalDuration = Temporal.Duration;
7
- export interface TemporalPlainDateTimeExtended extends TemporalPlainDateTime {
8
- dayOfWeek: number;
9
- dayOfYear: number;
10
- weekOfYear: number;
11
- yearOfWeek: number;
12
- microsecond: number;
13
- nanosecond: number;
14
- add<T extends TemporalPlainDateTime>(duration: TemporalDuration | Record<string, unknown>): T;
15
- subtract<T extends TemporalPlainDateTime>(duration: TemporalDuration | Record<string, unknown>): T;
16
- with<T extends TemporalPlainDateTime>(fields: Record<string, unknown>): T;
17
- }
18
- export interface TemporalZonedDateTimeExtended extends TemporalZonedDateTime {
19
- offset: string;
20
- offsetNanoseconds: number;
21
- timeZoneId: string;
22
- }
23
- export interface TemporalDurationExtended extends TemporalDuration {
24
- abs<T extends TemporalDuration>(this: T): T;
25
- }
26
- export interface TemporalDurationLike {
27
- years?: number;
28
- months?: number;
29
- weeks?: number;
30
- days?: number;
31
- hours?: number;
32
- minutes?: number;
33
- seconds?: number;
34
- milliseconds?: number;
35
- microseconds?: number;
36
- nanoseconds?: number;
37
- }
38
- export type DurationLike = TemporalDuration | TemporalDurationLike | Record<string, unknown>;
39
- export interface TemporalPlainDateTimePolyfill extends TemporalPlainDateTime {
40
- toZonedDateTime(timeZone: string): TemporalZonedDateTime;
41
- dayOfWeek: number;
42
- dayOfYear: number;
43
- weekOfYear: number;
44
- yearOfWeek: number;
45
- add(duration: DurationLike): TemporalPlainDateTimePolyfill;
46
- subtract(duration: DurationLike): TemporalPlainDateTimePolyfill;
47
- with(fields: Record<string, unknown>): TemporalPlainDateTimePolyfill;
48
- since(other: TemporalPlainDateTime, options?: Record<string, unknown>): TemporalDuration;
49
- }
50
- export interface TemporalZonedDateTimePolyfill extends TemporalZonedDateTime {
51
- offset: string;
52
- offsetNanoseconds: number;
53
- timeZoneId: string;
54
- toPlainDateTime(): TemporalPlainDateTime;
55
- }
56
- export interface TemporalLike {
57
- toPlainDateTime(): TemporalPlainDateTime;
58
- toPlainDate?(): TemporalPlainDate;
59
- toPlainTime?(): TemporalPlainTime;
60
- }
61
- export type DateInput = TemporalPlainDateTime | TemporalZonedDateTime | TemporalPlainDate | TemporalPlainTime | Date | string | number | Record<string, unknown>;
62
- /**
63
- * Unit type for date/time operations
64
- */
65
- export type Unit = 'year' | 'month' | 'week' | 'day' | 'hour' | 'minute' | 'second' | 'millisecond' | 'microsecond' | 'nanosecond';
66
- /**
67
- * Format preset strings for common patterns
68
- */
69
- export type FormatPreset = 'iso' | 'date' | 'time' | 'datetime' | 'rfc2822' | 'rfc3339' | 'utc';
70
- /**
71
- * Duration-like object for arithmetic operations
72
- */
73
- export interface IDuration {
74
- years?: number;
75
- months?: number;
76
- weeks?: number;
77
- days?: number;
78
- hours?: number;
79
- minutes?: number;
80
- seconds?: number;
81
- milliseconds?: number;
82
- microseconds?: number;
83
- nanoseconds?: number;
84
- }
85
- /**
86
- * Round options for precision control
87
- */
88
- export interface IRoundOptions {
89
- smallestUnit?: Unit;
90
- roundingMode?: 'ceil' | 'floor' | 'expand' | 'trunc' | 'halfExpand' | 'halfFloor' | 'halfCeil' | 'halfTrunc';
91
- roundingIncrement?: number;
92
- }
93
- /**
94
- * Duration options for normalizing time differences
95
- */
96
- export interface IDurationOptions {
97
- largestUnit?: 'year' | 'month' | 'week' | 'day' | 'hour' | 'minute' | 'second' | 'millisecond';
98
- smallestUnit?: 'year' | 'month' | 'week' | 'day' | 'hour' | 'minute' | 'second' | 'millisecond';
99
- }
100
- /**
101
- * Diff result object that allows chaining with .as()
102
- * Example: tg1.diff(tg2).as('month')
103
- */
104
- export interface IDiffResult {
105
- as(unit: Unit): number;
106
- /**
107
- * Get breakdown in calendar mode (e.g., "2 months 5 days")
108
- * Only available when mode is 'calendar'
109
- */
110
- breakdown(): DurationParts | null;
111
- /**
112
- * Format the difference as a human-readable string
113
- * @param locale Locale code (e.g., 'en', 'es', 'fr')
114
- * @example
115
- * diff.format('en') // "2 months and 5 days"
116
- * diff.format('es') // "2 meses y 5 días"
117
- */
118
- format(locale?: string): string;
119
- /**
120
- * Get the mode used for this diff calculation
121
- */
122
- getMode(): 'calendar' | 'exact';
123
- }
124
- /**
125
- * Options for diff() method
126
- */
127
- export interface IDiffOptions {
128
- /**
129
- * Calculation mode:
130
- * - 'calendar': Returns months/days breakdown (e.g., 65 days → 2 months 5 days)
131
- * - 'exact': Returns exact time units (e.g., 65 days)
132
- * @default 'exact'
133
- */
134
- mode?: 'calendar' | 'exact';
135
- /**
136
- * Unit for diff when using 'exact' mode
137
- * @default 'millisecond'
138
- */
139
- unit?: Unit;
140
- /**
141
- * Locale for formatting output text
142
- * @default from TimeGuard instance config
143
- */
144
- locale?: string;
145
- }
146
- /**
147
- * Duration parts breakdown
148
- */
149
- export interface DurationParts {
150
- years: number;
151
- months: number;
152
- weeks: number;
153
- days: number;
154
- hours: number;
155
- minutes: number;
156
- seconds: number;
157
- milliseconds: number;
158
- }
159
- /**
160
- * Base interface for formattable duration-like objects
161
- * Common functionality shared by DiffResult and DurationResult
162
- */
163
- export interface IFormattableDuration {
164
- toString(): string;
165
- toJSON(): Record<string, number> | number;
166
- }
167
- /**
168
- * Options for humanize() method
169
- */
170
- export interface IHumanizeOptions {
171
- /**
172
- * Locale code (e.g., 'en', 'es', 'fr')
173
- * @default from TimeGuard instance config
174
- */
175
- locale?: string;
176
- /**
177
- * Show full breakdown (e.g., "2 months and 5 days")
178
- * or just largest unit (e.g., "2 months")
179
- * @default false (largest unit only with Intl.RelativeTimeFormat style)
180
- */
181
- fullBreakdown?: boolean;
182
- /**
183
- * Numeric format: 'always', 'auto'
184
- * @default 'always'
185
- */
186
- numeric?: 'always' | 'auto';
187
- }
188
- /**
189
- * Duration result with humanize and total methods
190
- * Returned by until(), since(), and between()
191
- * Rich object for business logic: payments, metrics, analytics
192
- */
193
- export interface IDurationResult extends DurationParts {
194
- /**
195
- * Convert duration to human-readable string
196
- * @example
197
- * duration.humanize() // "2 months"
198
- * duration.humanize({ fullBreakdown: true, locale: 'es' }) // "2 meses y 5 días"
199
- */
200
- humanize(options?: IHumanizeOptions): string;
201
- /**
202
- * Get total duration in specified unit (date-fns style)
203
- * Perfect for business metrics: payments, analytics, calculations
204
- *
205
- * Conversion factors account for:
206
- * - Leap years (1 year = 365.25 days)
207
- * - Average month length (1 month = 30.4375 days)
208
- *
209
- * @example
210
- * duration.total('days') // 65
211
- * duration.total('months') // 2.166... (65 / 30.4375)
212
- * duration.total('hours') // 1560
213
- * duration.total('seconds') // 5616000
214
- *
215
- * Use cases:
216
- * - Billing calculations: `duration.total('days') * dailyRate`
217
- * - Performance metrics: `duration.total('milliseconds')`
218
- * - Report generation: `duration.total('months')`
219
- */
220
- total(unit: Unit): number;
221
- /**
222
- * String representation
223
- * Returns humanized format for display
224
- */
225
- toString(): string;
226
- /**
227
- * JSON representation
228
- * Returns breakdown as object for API responses
229
- */
230
- toJSON(): Record<string, number>;
231
- /**
232
- * Explain the calculation - killer feature for debugging and education
233
- * Returns detailed breakdown of how the duration was calculated
234
- *
235
- * Perfect for:
236
- * - Debugging complex date calculations
237
- * - Educational purposes (showing date math)
238
- * - Auditing time-based business logic
239
- *
240
- * @example
241
- * duration.explain()
242
- * // {
243
- * // input: ['2024-01-15', '2024-03-20'],
244
- * // steps: ['...step 1...', '...step 2...'],
245
- * // breakdown: { years: 0, months: 2, days: 5, ... },
246
- * // mode: 'exact',
247
- * // explanation: '...'
248
- * // }
249
- */
250
- explain(): IDurationExplanation;
251
- }
252
- /**
253
- * Duration explanation object for debugging and education
254
- * Provides transparent insight into calculation methodology
255
- * Perfect for: debugging, auditing, educational purposes
256
- *
257
- * @example
258
- * duration.explain()
259
- * // {
260
- * // input: ['2024-01-15', '2024-03-20'],
261
- * // steps: [
262
- * // 'Parsed dates: 2024-01-15 (day 15 of 365) to 2024-03-20 (day 80 of 365)',
263
- * // '2024 is a leap year (366 days)',
264
- * // 'February 2024 has 29 days',
265
- * // 'Month 1: 31 - 15 = 16 days remaining',
266
- * // 'Month 2: 29 days (full leap month)',
267
- * // 'Month 3: 1 - 20 = 20 days',
268
- * // 'Total: 16 + 29 + 20 = 65 days'
269
- * // ],
270
- * // breakdown: { years: 0, months: 2, weeks: 0, days: 5, ... },
271
- * // mode: 'exact',
272
- * // explanation: 'Calculated 2024-01-15 to 2024-03-20 including leap year adjustment'
273
- * // }
274
- */
275
- export interface IDurationExplanation {
276
- /**
277
- * Input dates as array of strings or formatted representations
278
- */
279
- input: string[];
280
- /**
281
- * Step-by-step calculation explanation
282
- * Each step is human-readable and educational
283
- * Useful for debugging complex date calculations
284
- */
285
- steps: string[];
286
- /**
287
- * Duration breakdown by component
288
- * Same as the DurationResult properties
289
- */
290
- breakdown: DurationParts;
291
- /**
292
- * Calculation mode
293
- * - 'exact': Uses Temporal API precise calculations
294
- * - 'estimated': Fallback for edge cases
295
- */
296
- mode: 'exact' | 'estimated';
297
- /**
298
- * Human-readable explanation of the entire calculation
299
- * Summarizes the approach and any special handling
300
- */
301
- explanation: string;
302
- /**
303
- * Locale used for explanation text
304
- * Supports internationalization of step descriptions
305
- */
306
- locale: string;
307
- /**
308
- * Leap year flags if applicable
309
- * Documents which years were leap years in the calculation
310
- */
311
- leapYearFlags?: {
312
- year: number;
313
- isLeap: boolean;
314
- daysInFebruary: number;
315
- }[];
316
- /**
317
- * Performance metadata
318
- * For monitoring calculation complexity
319
- */
320
- metadata?: {
321
- calculationTimeMs: number;
322
- precision: 'nanosecond' | 'microsecond' | 'millisecond' | 'second' | 'day';
323
- };
324
- }
325
- /**
326
- * Calendar system interface
327
- */
328
- export interface ICalendarSystem {
329
- id: string;
330
- name: string;
331
- locale?: string;
332
- getMonthName(month: number, short?: boolean): string;
333
- getWeekdayName(day: number, short?: boolean): string;
334
- isLeapYear(year: number): boolean;
335
- daysInMonth(year: number, month: number): number;
336
- daysInYear(year: number): number;
337
- }
338
- /**
339
- * Calendar manager interface
340
- */
341
- export interface ICalendarManager {
342
- register(calendar: ICalendarSystem): void;
343
- get(id: string): ICalendarSystem | undefined;
344
- list(): string[];
345
- setDefault(id: string): void;
346
- getDefault(): ICalendarSystem;
347
- }
348
- /**
349
- * Locale configuration interface
350
- */
351
- export interface ILocale {
352
- name: string;
353
- months: string[];
354
- monthsShort: string[];
355
- weekdays: string[];
356
- weekdaysShort: string[];
357
- weekdaysMin: string[];
358
- meridiem?: {
359
- am: string;
360
- pm: string;
361
- };
362
- formats?: Record<string, string>;
363
- }
364
- /**
365
- * Configuration options for TimeGuard instance
366
- */
367
- export interface ITimeGuardConfig {
368
- locale?: string;
369
- timezone?: string;
370
- strict?: boolean;
371
- }
372
- /**
373
- * Interface for date/time parsing strategy (Strategy Pattern)
374
- */
375
- export interface IDateParser {
376
- parse(input: unknown): TemporalPlainDateTime | null;
377
- canHandle(input: unknown): boolean;
378
- }
379
- /**
380
- * Interface for date/time formatting (Strategy Pattern)
381
- */
382
- export interface IDateFormatter {
383
- format(date: TemporalPlainDateTime | TemporalZonedDateTime, pattern: string): string;
384
- getPreset(preset: FormatPreset): string;
385
- }
386
- /**
387
- * Interface for locale management (Single Responsibility)
388
- */
389
- export interface ILocaleManager {
390
- setLocale(locale: string, data?: ILocale): void;
391
- getLocale(locale?: string): ILocale;
392
- listLocales(): string[];
393
- }
394
- /**
395
- * Interface for arithmetic operations
396
- */
397
- export interface IDateArithmetic {
398
- add(units: Partial<Record<Unit, number>> | IDuration): TimeGuard;
399
- subtract(units: Partial<Record<Unit, number>> | IDuration): TimeGuard;
400
- diff(other: TimeGuard): IDiffResult;
401
- diff(other: TimeGuard, unit: Unit): number;
402
- until(other: TimeGuard, options?: IDurationOptions): IDurationResult;
403
- since(other: TimeGuard, options?: IDurationOptions): IDurationResult;
404
- round(options: IRoundOptions): TimeGuard;
405
- }
406
- /**
407
- * Interface for query operations
408
- */
409
- export interface IDateQuery {
410
- isBefore(other: TimeGuard): boolean;
411
- isAfter(other: TimeGuard): boolean;
412
- isSame(other: TimeGuard, unit?: Unit): boolean;
413
- isBetween(start: TimeGuard, end: TimeGuard, unit?: Unit, inclusivity?: '[)' | '()' | '[]' | '(]'): boolean;
414
- }
415
- /**
416
- * Interface for manipulation operations
417
- */
418
- export interface IDateManipulation {
419
- clone(): TimeGuard;
420
- startOf(unit: Unit): TimeGuard;
421
- endOf(unit: Unit): TimeGuard;
422
- set(values: Partial<Record<Unit, number>>): TimeGuard;
423
- year(): number;
424
- month(): number;
425
- day(): number;
426
- hour(): number;
427
- minute(): number;
428
- second(): number;
429
- millisecond(): number;
430
- dayOfWeek(): number;
431
- dayOfYear(): number;
432
- weekOfYear(): number;
433
- daysInMonth(): number;
434
- daysInYear(): number;
435
- inLeapYear(): boolean;
436
- }
437
- /**
438
- * Interface for timezone operations
439
- */
440
- export interface ITimezoneAdapter {
441
- toTimezone(date: TemporalPlainDateTime, timezone: string): TemporalZonedDateTime;
442
- fromTimezone(date: TemporalZonedDateTime, targetTimezone: string): TemporalPlainDateTime;
443
- getOffset(timezone: string): number;
444
- }
445
- /**
446
- * Main TimeGuard interface (Facade Pattern)
447
- */
448
- export interface ITimeGuard extends IDateArithmetic, IDateQuery, IDateManipulation {
449
- /**
450
- * Get the underlying Temporal date object
451
- */
452
- toTemporal(): TemporalPlainDateTime | TemporalZonedDateTime;
453
- /**
454
- * Get as JavaScript Date (compatibility)
455
- */
456
- toDate(): Date;
457
- /**
458
- * Get as ISO string
459
- */
460
- toISOString(): string;
461
- /**
462
- * Get as Unix timestamp (milliseconds)
463
- */
464
- valueOf(): number;
465
- /**
466
- * Format the date with pattern or preset
467
- */
468
- format(pattern: string | FormatPreset): string;
469
- /**
470
- * Get accessor for components
471
- */
472
- get(component: Unit): number;
473
- /**
474
- * Locale of this instance
475
- */
476
- locale(): string;
477
- /**
478
- * Clone with new locale
479
- */
480
- locale(locale: string): TimeGuard;
481
- /**
482
- * Timezone info
483
- */
484
- timezone(): string | null;
485
- /**
486
- * Convert to another timezone
487
- */
488
- timezone(timezone: string): TimeGuard;
489
- /**
490
- * Get Unix timestamp in seconds
491
- */
492
- unix(): number;
493
- /**
494
- * Convert to JSON
495
- */
496
- toJSON(): string;
497
- /**
498
- * String representation
499
- */
500
- toString(): string;
501
- /**
502
- * Convert to PlainDate object
503
- */
504
- toPlainDate(): {
505
- year: number;
506
- month: number;
507
- day: number;
508
- dayOfWeek: number;
509
- };
510
- /**
511
- * Convert to PlainTime object
512
- */
513
- toPlainTime(): {
514
- hour: number;
515
- minute: number;
516
- second: number;
517
- millisecond: number;
518
- };
519
- /**
520
- * Get timezone offset (±HH:mm format or Z)
521
- */
522
- getOffset(): string;
523
- /**
524
- * Get timezone offset in nanoseconds
525
- */
526
- getOffsetNanoseconds(): number;
527
- /**
528
- * Get timezone ID
529
- */
530
- getTimeZoneId(): string | null;
531
- /**
532
- * Start of day
533
- */
534
- startOfDay(): TimeGuard;
535
- /**
536
- * End of day
537
- */
538
- endOfDay(): TimeGuard;
539
- /**
540
- * Duration from another date (inverse of until)
541
- */
542
- since(other: TimeGuard, options?: IDurationOptions): IDurationResult;
543
- /**
544
- * ISO 8601 duration string (P1Y2M3DT4H5M6S)
545
- */
546
- toDurationString(other?: TimeGuard): string;
547
- /**
548
- * Check if in past
549
- */
550
- isPast(): boolean;
551
- /**
552
- * Check if in future
553
- */
554
- isFuture(): boolean;
555
- /**
556
- * Check if today
557
- */
558
- isToday(): boolean;
559
- /**
560
- * Check if tomorrow
561
- */
562
- isTomorrow(): boolean;
563
- /**
564
- * Check if yesterday
565
- */
566
- isYesterday(): boolean;
567
- }
568
- /**
569
- * Plugin interface for extending functionality
570
- */
571
- export interface ITimeGuardPlugin {
572
- name: string;
573
- version: string;
574
- install(timeGuard: typeof TimeGuard, config?: unknown): void;
575
- }
576
- /**
577
- * Factory interface
578
- */
579
- export interface ITimeGuardFactory {
580
- create(input?: unknown, config?: ITimeGuardConfig): ITimeGuard;
581
- now(config?: ITimeGuardConfig): ITimeGuard;
582
- fromTemporal(date: TemporalPlainDateTime | TemporalZonedDateTime, config?: ITimeGuardConfig): ITimeGuard;
583
- }
584
- /**
585
- * Forward declaration for TimeGuard class
586
- * Implementation is in ./index.ts, exported via ./index.ts
587
- */
588
- export declare class TimeGuard {
589
- constructor(input?: unknown, config?: ITimeGuardConfig);
590
- }
591
- /**
592
- * Forward declaration for DurationResult class
593
- * Implementation is in ./index.ts, exported via ./index.ts
594
- */
595
- export declare class DurationResult implements IDurationResult {
596
- constructor(parts: DurationParts, locale?: string, metadata?: {
597
- startDate?: string;
598
- endDate?: string;
599
- steps?: string[];
600
- mode?: 'exact' | 'estimated';
601
- leapYearFlags?: Array<{
602
- year: number;
603
- isLeap: boolean;
604
- daysInFebruary: number;
605
- }>;
606
- calculationTimeMs?: number;
607
- });
608
- years: number;
609
- months: number;
610
- weeks: number;
611
- days: number;
612
- hours: number;
613
- minutes: number;
614
- seconds: number;
615
- milliseconds: number;
616
- humanize(options?: {
617
- locale?: string;
618
- fullBreakdown?: boolean;
619
- numeric?: 'always' | 'auto';
620
- }): string;
621
- total(unit: Unit): number;
622
- toString(): string;
623
- toJSON(): Record<string, number>;
624
- explain(): IDurationExplanation;
625
- }
626
- /**
627
- * Forward declaration for TimeRange class
628
- * Fluent API for date range operations with semantic naming
629
- * Implementation is in ./index.ts, exported via ./index.ts
630
- */
631
- export declare class TimeRange {
632
- constructor(start: TimeGuard, end: TimeGuard);
633
- toDuration(): DurationResult;
634
- inMonths(): number;
635
- humanize(options?: {
636
- locale?: string;
637
- fullBreakdown?: boolean;
638
- numeric?: 'always' | 'auto';
639
- }): string;
640
- in(unit: Unit): number;
641
- }
File without changes
File without changes
File without changes
File without changes
File without changes