chronos-ts 2.0.2 → 2.0.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/index.d.ts CHANGED
@@ -1,50 +1,2311 @@
1
1
  /**
2
- * Chronos v2 - A comprehensive TypeScript library for date and time manipulation
3
- *
4
- * @description
5
- * Chronos is a powerful, modern TypeScript library for handling dates, times,
6
- * intervals, periods, and timezones. Inspired by Carbon PHP, it provides an
7
- * intuitive and fluent API for all your time-related needs.
2
+ * Core type definitions for Chronos
3
+ * @module types
4
+ */
5
+ /**
6
+ * All supported time units in the library
7
+ */
8
+ type TimeUnit = 'millisecond' | 'second' | 'minute' | 'hour' | 'day' | 'week' | 'month' | 'quarter' | 'year' | 'decade' | 'century' | 'millennium';
9
+ /**
10
+ * Plural forms of time units
11
+ */
12
+ type TimeUnitPlural = 'milliseconds' | 'seconds' | 'minutes' | 'hours' | 'days' | 'weeks' | 'months' | 'quarters' | 'years' | 'decades' | 'centuries' | 'millennia';
13
+ /**
14
+ * Short forms of time units
15
+ */
16
+ type TimeUnitShort = 'ms' | 's' | 'm' | 'h' | 'd' | 'w' | 'M' | 'Q' | 'y';
17
+ /**
18
+ * Combined time unit type accepting any form
19
+ */
20
+ type AnyTimeUnit = TimeUnit | TimeUnitPlural | TimeUnitShort;
21
+ /**
22
+ * Days of the week (0 = Sunday, 6 = Saturday)
23
+ */
24
+ declare enum DayOfWeek {
25
+ Sunday = 0,
26
+ Monday = 1,
27
+ Tuesday = 2,
28
+ Wednesday = 3,
29
+ Thursday = 4,
30
+ Friday = 5,
31
+ Saturday = 6
32
+ }
33
+ /**
34
+ * Months of the year (1 = January, 12 = December)
35
+ */
36
+ declare enum Month {
37
+ January = 1,
38
+ February = 2,
39
+ March = 3,
40
+ April = 4,
41
+ May = 5,
42
+ June = 6,
43
+ July = 7,
44
+ August = 8,
45
+ September = 9,
46
+ October = 10,
47
+ November = 11,
48
+ December = 12
49
+ }
50
+ /**
51
+ * Valid input types that can be parsed into a Chronos instance
52
+ */
53
+ type DateInput = string | number | Date | ChronosLike | null | undefined;
54
+ /**
55
+ * Interface for Chronos-like objects
56
+ */
57
+ interface ChronosLike {
58
+ toDate(): Date;
59
+ valueOf(): number;
60
+ }
61
+ /**
62
+ * Object representing individual date/time components
63
+ */
64
+ interface DateTimeComponents {
65
+ year?: number;
66
+ month?: number;
67
+ day?: number;
68
+ hour?: number;
69
+ minute?: number;
70
+ second?: number;
71
+ millisecond?: number;
72
+ }
73
+ /**
74
+ * Object for setting date/time parts
75
+ */
76
+ interface DateTimeSetter {
77
+ year?: number;
78
+ month?: number;
79
+ date?: number;
80
+ day?: number;
81
+ hour?: number;
82
+ minute?: number;
83
+ second?: number;
84
+ millisecond?: number;
85
+ }
86
+ /**
87
+ * Duration object for intervals
88
+ */
89
+ interface Duration {
90
+ years?: number;
91
+ months?: number;
92
+ weeks?: number;
93
+ days?: number;
94
+ hours?: number;
95
+ minutes?: number;
96
+ seconds?: number;
97
+ milliseconds?: number;
98
+ }
99
+ /**
100
+ * ISO 8601 duration string pattern
101
+ */
102
+ type ISODuration = string;
103
+ /**
104
+ * Valid timezone input types
105
+ */
106
+ type TimezoneInput = string | number | TimezoneInfo;
107
+ /**
108
+ * Timezone offset information
109
+ */
110
+ interface TimezoneOffset {
111
+ /**
112
+ * Offset in minutes from UTC
113
+ */
114
+ minutes: number;
115
+ /**
116
+ * Offset in hours from UTC
117
+ */
118
+ hours: number;
119
+ /**
120
+ * Offset as string (e.g., "+05:30", "-08:00")
121
+ */
122
+ string: string;
123
+ }
124
+ /**
125
+ * DST transition information
126
+ */
127
+ interface DSTransition {
128
+ /**
129
+ * Date of the DST transition
130
+ */
131
+ date: Date;
132
+ /**
133
+ * Offset before transition (in minutes)
134
+ */
135
+ fromOffset: number;
136
+ /**
137
+ * Offset after transition (in minutes)
138
+ */
139
+ toOffset: number;
140
+ /**
141
+ * Whether this is the start of DST (spring forward)
142
+ */
143
+ isDSTStart: boolean;
144
+ }
145
+ /**
146
+ * Timezone information object
147
+ */
148
+ interface TimezoneInfo {
149
+ /**
150
+ * IANA timezone identifier
151
+ */
152
+ identifier: string;
153
+ /**
154
+ * Display name of the timezone
155
+ */
156
+ name: string;
157
+ /**
158
+ * Timezone abbreviation (e.g., EST, PST)
159
+ */
160
+ abbreviation: string;
161
+ /**
162
+ * Current UTC offset
163
+ */
164
+ offset: TimezoneOffset;
165
+ /**
166
+ * Whether DST is currently in effect
167
+ */
168
+ isDST: boolean;
169
+ /**
170
+ * Whether this timezone observes DST
171
+ */
172
+ observesDST: boolean;
173
+ }
174
+ /**
175
+ * Format token types for custom formatting
176
+ */
177
+ interface FormatTokens {
178
+ [key: string]: ((date: Date) => string) | string;
179
+ }
180
+ /**
181
+ * Predefined format presets
182
+ */
183
+ type FormatPreset = 'date' | 'time' | 'datetime' | 'iso' | 'rfc2822' | 'rfc3339' | 'atom' | 'cookie' | 'rss' | 'w3c';
184
+ /**
185
+ * Comparison operators
186
+ */
187
+ type CompareOperator = '<' | '<=' | '=' | '>=' | '>' | '!=';
188
+ /**
189
+ * Comparison granularity options
190
+ */
191
+ type CompareGranularity = TimeUnit | 'default';
192
+ /**
193
+ * Period options for iteration
194
+ */
195
+ interface PeriodOptions {
196
+ /**
197
+ * Exclude the start date from iteration
198
+ */
199
+ excludeStart?: boolean;
200
+ /**
201
+ * Exclude the end date from iteration
202
+ */
203
+ excludeEnd?: boolean;
204
+ /**
205
+ * Maximum number of iterations
206
+ */
207
+ recurrences?: number;
208
+ /**
209
+ * Whether period modifications return new instances
210
+ */
211
+ immutable?: boolean;
212
+ }
213
+ /**
214
+ * Period boundary options
215
+ */
216
+ declare enum PeriodBoundary {
217
+ Open = "open",
218
+ Closed = "closed",
219
+ OpenStart = "openStart",
220
+ OpenEnd = "openEnd"
221
+ }
222
+ /**
223
+ * Locale configuration
224
+ */
225
+ interface LocaleConfig {
226
+ code: string;
227
+ months: string[];
228
+ monthsShort: string[];
229
+ weekdays: string[];
230
+ weekdaysShort: string[];
231
+ weekdaysMin: string[];
232
+ ordinal: (n: number) => string;
233
+ formats: {
234
+ LT: string;
235
+ LTS: string;
236
+ L: string;
237
+ LL: string;
238
+ LLL: string;
239
+ LLLL: string;
240
+ l?: string;
241
+ ll?: string;
242
+ lll?: string;
243
+ llll?: string;
244
+ };
245
+ relativeTime: {
246
+ future: string;
247
+ past: string;
248
+ s: string;
249
+ ss: string;
250
+ m: string;
251
+ mm: string;
252
+ h: string;
253
+ hh: string;
254
+ d: string;
255
+ dd: string;
256
+ w?: string;
257
+ ww?: string;
258
+ M: string;
259
+ MM: string;
260
+ y: string;
261
+ yy: string;
262
+ };
263
+ meridiem?: (hour: number, minute: number, isLowercase: boolean) => string;
264
+ week?: {
265
+ dow: number;
266
+ doy: number;
267
+ };
268
+ }
269
+ /**
270
+ * Global configuration options
271
+ */
272
+ interface ChronosConfig {
273
+ /**
274
+ * Default timezone
275
+ */
276
+ timezone?: string;
277
+ /**
278
+ * Default locale
279
+ */
280
+ locale?: string;
281
+ /**
282
+ * First day of week (0 = Sunday, 1 = Monday, etc.)
283
+ */
284
+ weekStartsOn?: DayOfWeek;
285
+ /**
286
+ * First week of year contains this date
287
+ */
288
+ firstWeekContainsDate?: 1 | 4;
289
+ /**
290
+ * Strict parsing mode
291
+ */
292
+ strict?: boolean;
293
+ }
294
+ /**
295
+ * Makes all properties optional recursively
296
+ */
297
+ type DeepPartial<T> = {
298
+ [P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P];
299
+ };
300
+ /**
301
+ * Extract numeric keys from an object type
302
+ */
303
+ type NumericKeys<T> = {
304
+ [K in keyof T]: T[K] extends number ? K : never;
305
+ }[keyof T];
306
+ /**
307
+ * Type guard result
308
+ */
309
+ type TypeGuard<T> = (value: unknown) => value is T;
310
+ /**
311
+ * Chainable method return type
312
+ */
313
+ type Chainable<T> = T & {
314
+ clone(): T;
315
+ };
316
+ /**
317
+ * Options for human-readable difference output
318
+ */
319
+ interface HumanDiffOptions {
320
+ /**
321
+ * Use short form (1d vs 1 day)
322
+ */
323
+ short?: boolean;
324
+ /**
325
+ * Number of units to include
326
+ */
327
+ parts?: number;
328
+ /**
329
+ * Use absolute value
330
+ */
331
+ absolute?: boolean;
332
+ /**
333
+ * Separator between parts
334
+ */
335
+ separator?: string;
336
+ /**
337
+ * Conjunction for last part
338
+ */
339
+ conjunction?: string;
340
+ /**
341
+ * Include numeric suffix (st, nd, rd, th)
342
+ */
343
+ ordinal?: boolean;
344
+ }
345
+ /**
346
+ * Diff result with all units
347
+ */
348
+ interface DiffResult {
349
+ years: number;
350
+ months: number;
351
+ weeks: number;
352
+ days: number;
353
+ hours: number;
354
+ minutes: number;
355
+ seconds: number;
356
+ milliseconds: number;
357
+ totalMilliseconds: number;
358
+ }
359
+ /**
360
+ * Serializable representation of a Chronos instance
361
+ */
362
+ interface ChronosSerializable {
363
+ timestamp: number;
364
+ timezone: string;
365
+ offset: number;
366
+ }
367
+ /**
368
+ * JSON representation
369
+ */
370
+ interface ChronosJSON {
371
+ iso: string;
372
+ timestamp: number;
373
+ timezone: string;
374
+ }
375
+ /**
376
+ * Represents a time range/span
377
+ */
378
+ interface TimeRange {
379
+ start: Date;
380
+ end: Date;
381
+ }
382
+ /**
383
+ * Business hours configuration
384
+ */
385
+ interface BusinessHours {
386
+ open: {
387
+ hour: number;
388
+ minute: number;
389
+ };
390
+ close: {
391
+ hour: number;
392
+ minute: number;
393
+ };
394
+ days: DayOfWeek[];
395
+ holidays?: Date[];
396
+ }
397
+ /**
398
+ * Calendar week representation
399
+ */
400
+ interface CalendarWeek {
401
+ weekNumber: number;
402
+ year: number;
403
+ days: Date[];
404
+ }
405
+ /**
406
+ * Calendar month representation
407
+ */
408
+ interface CalendarMonth {
409
+ year: number;
410
+ month: number;
411
+ weeks: CalendarWeek[];
412
+ }
413
+ declare const MILLISECONDS_PER_SECOND = 1000;
414
+ declare const SECONDS_PER_MINUTE = 60;
415
+ declare const MINUTES_PER_HOUR = 60;
416
+ declare const HOURS_PER_DAY = 24;
417
+ declare const DAYS_PER_WEEK = 7;
418
+ declare const MONTHS_PER_YEAR = 12;
419
+ declare const DAYS_PER_YEAR = 365;
420
+ declare const DAYS_PER_LEAP_YEAR = 366;
421
+ declare const MILLISECONDS_PER_MINUTE: number;
422
+ declare const MILLISECONDS_PER_HOUR: number;
423
+ declare const MILLISECONDS_PER_DAY: number;
424
+ declare const MILLISECONDS_PER_WEEK: number;
425
+ declare const AVERAGE_DAYS_PER_MONTH = 30.436875;
426
+ declare const AVERAGE_DAYS_PER_YEAR = 365.2425;
427
+ declare const MILLISECONDS_PER_MONTH: number;
428
+ declare const MILLISECONDS_PER_YEAR: number;
429
+
430
+ /**
431
+ * Chronos - The ultimate TypeScript date/time library
432
+ * @module Chronos
433
+ */
434
+
435
+ /**
436
+ * Chronos - A comprehensive date/time manipulation library
8
437
  *
9
438
  * @example
10
439
  * ```typescript
11
- * import { Chronos, ChronosInterval, ChronosPeriod, ChronosTimezone } from 'chronos-ts';
12
- *
13
- * // Create dates
440
+ * // Create instances
14
441
  * const now = Chronos.now();
442
+ * const date = Chronos.parse('2024-01-15');
15
443
  * const birthday = Chronos.create(1990, 5, 15);
16
444
  *
17
445
  * // Manipulate
18
- * const nextWeek = now.addWeeks(1);
19
- * const endOfMonth = now.endOf('month');
446
+ * const future = now.add(3, 'months').startOf('day');
447
+ * const past = now.subtract(1, 'year').endOf('month');
20
448
  *
21
449
  * // Compare
22
- * if (now.isAfter(birthday)) {
23
- * console.log('Birthday has passed');
24
- * }
450
+ * const isAfter = date.isAfter(birthday);
451
+ * const diff = date.diff(birthday, 'years');
25
452
  *
26
453
  * // Format
27
- * console.log(now.format('MMMM D, YYYY')); // "January 15, 2024"
454
+ * const formatted = now.format('YYYY-MM-DD HH:mm:ss');
455
+ * const relative = birthday.fromNow(); // "34 years ago"
456
+ * ```
457
+ */
458
+ declare class Chronos implements ChronosLike {
459
+ private readonly _date;
460
+ private _locale;
461
+ private _timezone?;
462
+ /**
463
+ * Create a new Chronos instance
464
+ *
465
+ * @param input - Date input (string, number, Date, or Chronos)
466
+ * @param timezone - Optional timezone
467
+ */
468
+ private constructor();
469
+ /**
470
+ * Parse a date string
471
+ */
472
+ private parseString;
473
+ /**
474
+ * Helper to create a date from components in a specific timezone
475
+ */
476
+ private static dateFromComponents;
477
+ /**
478
+ * Create a Chronos instance from various inputs
479
+ *
480
+ * @example
481
+ * ```typescript
482
+ * Chronos.parse('2024-01-15')
483
+ * Chronos.parse(1705276800000)
484
+ * Chronos.parse(new Date())
485
+ * ```
486
+ */
487
+ static parse(input?: DateInput, timezone?: string): Chronos;
488
+ /**
489
+ * Create a Chronos instance for the current moment
490
+ *
491
+ * @example
492
+ * ```typescript
493
+ * const now = Chronos.now();
494
+ * ```
495
+ */
496
+ static now(timezone?: string): Chronos;
497
+ /**
498
+ * Create a Chronos instance for today at midnight
499
+ */
500
+ static today(timezone?: string): Chronos;
501
+ /**
502
+ * Create a Chronos instance for tomorrow at midnight
503
+ */
504
+ static tomorrow(timezone?: string): Chronos;
505
+ /**
506
+ * Create a Chronos instance for yesterday at midnight
507
+ */
508
+ static yesterday(timezone?: string): Chronos;
509
+ /**
510
+ * Create a Chronos instance from individual components
511
+ * Month is 1-12 (like Carbon PHP)
512
+ *
513
+ * @example
514
+ * ```typescript
515
+ * Chronos.create(2024, 1, 15, 10, 30, 0) // Jan 15, 2024 10:30:00
516
+ * ```
517
+ */
518
+ static create(year: number, month?: number, day?: number, hour?: number, minute?: number, second?: number, millisecond?: number, timezone?: string): Chronos;
519
+ /**
520
+ * Create a Chronos instance from a Unix timestamp (seconds)
521
+ */
522
+ static fromUnix(timestamp: number, timezone?: string): Chronos;
523
+ /**
524
+ * Create a Chronos instance from a Unix timestamp (milliseconds)
525
+ */
526
+ static fromMillis(timestamp: number, timezone?: string): Chronos;
527
+ /**
528
+ * Create a Chronos instance from components object
529
+ * Month in components is 1-12 (like Carbon PHP)
530
+ */
531
+ static fromObject(components: DateTimeComponents, timezone?: string): Chronos;
532
+ /**
533
+ * Create a Chronos instance from a format string
534
+ *
535
+ * @example
536
+ * ```typescript
537
+ * Chronos.fromFormat('15-01-2024', 'DD-MM-YYYY')
538
+ * ```
539
+ */
540
+ static fromFormat(input: string, format: string, timezone?: string): Chronos;
541
+ /**
542
+ * Create the minimum possible date
543
+ */
544
+ static min(): Chronos;
545
+ /**
546
+ * Create the maximum possible date
547
+ */
548
+ static max(): Chronos;
549
+ /**
550
+ * Get the earliest of multiple dates
551
+ */
552
+ static earliest(...dates: (DateInput | Chronos)[]): Chronos;
553
+ /**
554
+ * Get the latest of multiple dates
555
+ */
556
+ static latest(...dates: (DateInput | Chronos)[]): Chronos;
557
+ /** Get the year */
558
+ get year(): number;
559
+ /** Get the month (1-12) */
560
+ get month(): number;
561
+ /** Get the day of month (1-31) */
562
+ get date(): number;
563
+ /** Alias for date */
564
+ get day(): number;
565
+ /** Get the day of week (0-6, Sunday = 0) */
566
+ get dayOfWeek(): DayOfWeek;
567
+ /** Get the hour (0-23) */
568
+ get hour(): number;
569
+ /** Get the minute (0-59) */
570
+ get minute(): number;
571
+ /** Get the second (0-59) */
572
+ get second(): number;
573
+ /** Get the millisecond (0-999) */
574
+ get millisecond(): number;
575
+ /** Get Unix timestamp (seconds) */
576
+ get unix(): number;
577
+ /** Get Unix timestamp (milliseconds) */
578
+ get timestamp(): number;
579
+ /** Get the quarter (1-4) */
580
+ get quarter(): number;
581
+ /** Get the day of year (1-366) */
582
+ get dayOfYear(): number;
583
+ /** Get the ISO week number (1-53) */
584
+ get week(): number;
585
+ /** Get the ISO week year */
586
+ get weekYear(): number;
587
+ /** Get the number of days in the current month */
588
+ get daysInMonth(): number;
589
+ /** Get the number of days in the current year */
590
+ get daysInYear(): number;
591
+ /** Get the number of weeks in the current year */
592
+ get weeksInYear(): number;
593
+ /** Check if the year is a leap year */
594
+ get isLeapYear(): boolean;
595
+ /** Get the timezone offset in minutes */
596
+ get offset(): number;
597
+ /** Get the timezone offset as string (+05:30) */
598
+ get offsetString(): string;
599
+ /**
600
+ * Set specific date/time components
601
+ * Returns a new Chronos instance
602
+ */
603
+ /**
604
+ * Set multiple date/time values at once
605
+ * Month is 1-12 (like Carbon PHP)
606
+ */
607
+ set(values: DateTimeSetter): Chronos;
608
+ /** Set the year */
609
+ setYear(year: number): Chronos;
610
+ /** Set the month (1-12) */
611
+ setMonth(month: number): Chronos;
612
+ /** Set the day of month (1-31) */
613
+ setDate(date: number): Chronos;
614
+ /** Set the hour (0-23) */
615
+ setHour(hour: number): Chronos;
616
+ /** Set the minute (0-59) */
617
+ setMinute(minute: number): Chronos;
618
+ /** Set the second (0-59) */
619
+ setSecond(second: number): Chronos;
620
+ /** Set the millisecond (0-999) */
621
+ setMillisecond(millisecond: number): Chronos;
622
+ /**
623
+ * Add time to the date
624
+ *
625
+ * @example
626
+ * ```typescript
627
+ * chronos.add(5, 'days')
628
+ * chronos.add(2, 'months')
629
+ * chronos.add({ years: 1, months: 2 })
630
+ * ```
631
+ */
632
+ add(amount: number | Duration, unit?: AnyTimeUnit): Chronos;
633
+ /**
634
+ * Add an amount of a single unit while respecting the instance timezone.
635
+ * Calendar units (day/week/month/quarter/year/…) preserve the wall-clock time
636
+ * in the zone (DST-safe); absolute units (hour/minute/second/millisecond) add a
637
+ * fixed offset to the instant. Day clamping mirrors the local-time path.
638
+ */
639
+ private addInZone;
640
+ /**
641
+ * Subtract time from the date
642
+ */
643
+ subtract(amount: number | Duration, unit?: AnyTimeUnit): Chronos;
644
+ /**
645
+ * Get the start of a time unit
646
+ *
647
+ * @example
648
+ * ```typescript
649
+ * chronos.startOf('day') // 00:00:00.000
650
+ * chronos.startOf('month') // First day of month
651
+ * chronos.startOf('year') // January 1st
652
+ * ```
653
+ */
654
+ startOf(unit: AnyTimeUnit): Chronos;
655
+ /**
656
+ * Get the end of a time unit
657
+ *
658
+ * @example
659
+ * ```typescript
660
+ * chronos.endOf('day') // 23:59:59.999
661
+ * chronos.endOf('month') // Last day of month
662
+ * chronos.endOf('year') // December 31st
663
+ * ```
664
+ */
665
+ endOf(unit: AnyTimeUnit): Chronos;
666
+ /**
667
+ * Compute the start/end boundary of a unit in the instance timezone.
668
+ * The plain `startOf`/`endOf` helpers operate on local wall-clock fields of the
669
+ * underlying Date, which is wrong when an explicit timezone is attached. Here we
670
+ * read the wall-clock components in the target zone, snap them to the boundary,
671
+ * and rebuild the instant (dateFromComponents handles DST).
672
+ */
673
+ private boundaryInZone;
674
+ addMilliseconds(amount: number): Chronos;
675
+ addSeconds(amount: number): Chronos;
676
+ addMinutes(amount: number): Chronos;
677
+ addHours(amount: number): Chronos;
678
+ addDays(amount: number): Chronos;
679
+ addWeeks(amount: number): Chronos;
680
+ addMonths(amount: number): Chronos;
681
+ addQuarters(amount: number): Chronos;
682
+ addYears(amount: number): Chronos;
683
+ subtractMilliseconds(amount: number): Chronos;
684
+ subtractSeconds(amount: number): Chronos;
685
+ subtractMinutes(amount: number): Chronos;
686
+ subtractHours(amount: number): Chronos;
687
+ subtractDays(amount: number): Chronos;
688
+ subtractWeeks(amount: number): Chronos;
689
+ subtractMonths(amount: number): Chronos;
690
+ subtractQuarters(amount: number): Chronos;
691
+ subtractYears(amount: number): Chronos;
692
+ /**
693
+ * Check if this date is before another
694
+ */
695
+ isBefore(other: DateInput, unit?: AnyTimeUnit): boolean;
696
+ /**
697
+ * Check if this date is after another
698
+ */
699
+ isAfter(other: DateInput, unit?: AnyTimeUnit): boolean;
700
+ /**
701
+ * Check if this date is the same as another
702
+ */
703
+ isSame(other: DateInput, unit?: AnyTimeUnit): boolean;
704
+ /**
705
+ * Check if this date is same or before another
706
+ */
707
+ isSameOrBefore(other: DateInput, unit?: AnyTimeUnit): boolean;
708
+ /**
709
+ * Check if this date is same or after another
710
+ */
711
+ isSameOrAfter(other: DateInput, unit?: AnyTimeUnit): boolean;
712
+ /**
713
+ * Check if this date is between two others
714
+ */
715
+ isBetween(start: DateInput, end: DateInput, unit?: AnyTimeUnit, inclusivity?: '()' | '[]' | '[)' | '(]'): boolean;
716
+ /** Check if this date is today */
717
+ isToday(): boolean;
718
+ /** Check if this date is tomorrow */
719
+ isTomorrow(): boolean;
720
+ /** Check if this date is yesterday */
721
+ isYesterday(): boolean;
722
+ /** Check if this date is in the past */
723
+ isPast(): boolean;
724
+ /** Check if this date is in the future */
725
+ isFuture(): boolean;
726
+ /** Check if this is a weekend (Saturday or Sunday) */
727
+ isWeekend(): boolean;
728
+ /** Check if this is a weekday (Monday-Friday) */
729
+ isWeekday(): boolean;
730
+ isSunday(): boolean;
731
+ isMonday(): boolean;
732
+ isTuesday(): boolean;
733
+ isWednesday(): boolean;
734
+ isThursday(): boolean;
735
+ isFriday(): boolean;
736
+ isSaturday(): boolean;
737
+ /**
738
+ * Get the difference between two dates in a specific unit
739
+ */
740
+ diff(other: DateInput, unit?: AnyTimeUnit, precise?: boolean): number;
741
+ /**
742
+ * Get a detailed diff breakdown
743
+ */
744
+ diffDetailed(other: DateInput): DiffResult;
745
+ /**
746
+ * Get a human-readable relative time string
747
+ *
748
+ * @example
749
+ * ```typescript
750
+ * date.fromNow() // "2 days ago"
751
+ * date.from(other) // "in 3 months"
752
+ * date.fromNow({ short: true }) // "2d ago"
753
+ * ```
754
+ */
755
+ fromNow(options?: HumanDiffOptions): string;
756
+ /**
757
+ * Get relative time from another date
758
+ */
759
+ from(other: DateInput, options?: HumanDiffOptions): string;
760
+ /**
761
+ * Get relative time to another date
762
+ */
763
+ to(other: DateInput, options?: HumanDiffOptions): string;
764
+ /**
765
+ * Get relative time to now
766
+ */
767
+ toNow(options?: HumanDiffOptions): string;
768
+ /**
769
+ * Format the date using a format string
770
+ *
771
+ * Supported tokens:
772
+ * - YYYY: 4-digit year
773
+ * - YY: 2-digit year
774
+ * - MMMM: Full month name
775
+ * - MMM: Short month name
776
+ * - MM: 2-digit month
777
+ * - M: 1-2 digit month
778
+ * - DD: 2-digit day
779
+ * - D: 1-2 digit day
780
+ * - dddd: Full weekday name
781
+ * - ddd: Short weekday name
782
+ * - dd: Min weekday name
783
+ * - d: Day of week number
784
+ * - HH: 2-digit hour (24h)
785
+ * - H: 1-2 digit hour (24h)
786
+ * - hh: 2-digit hour (12h)
787
+ * - h: 1-2 digit hour (12h)
788
+ * - mm: 2-digit minute
789
+ * - m: 1-2 digit minute
790
+ * - ss: 2-digit second
791
+ * - s: 1-2 digit second
792
+ * - SSS: 3-digit millisecond
793
+ * - A: AM/PM
794
+ * - a: am/pm
795
+ * - Z: Timezone offset (+05:00)
796
+ * - ZZ: Timezone offset (+0500)
797
+ */
798
+ format(formatStr?: string): string;
799
+ /** Format as ISO 8601 */
800
+ toISOString(): string;
801
+ /** Format as ISO date (YYYY-MM-DD) */
802
+ toDateString(): string;
803
+ /** Format as time (HH:mm:ss) */
804
+ toTimeString(): string;
805
+ /** Format as datetime (YYYY-MM-DD HH:mm:ss) */
806
+ toDateTimeString(): string;
807
+ /** Format as RFC 2822 */
808
+ toRFC2822(): string;
809
+ /** Format as RFC 3339 */
810
+ toRFC3339(): string;
811
+ /** Format as ATOM */
812
+ toAtomString(): string;
813
+ /** Format as Cookie */
814
+ toCookieString(): string;
815
+ /** Format as RSS */
816
+ toRSSString(): string;
817
+ /** Format as W3C */
818
+ toW3CString(): string;
819
+ /**
820
+ * Convert to a specific timezone
821
+ */
822
+ toTimezone(timezone: string): Chronos;
823
+ /** Convert to native Date object */
824
+ toDate(): Date;
825
+ /** Convert to array [year, month, day, hour, minute, second, millisecond] */
826
+ toArray(): number[];
827
+ /** Convert to object */
828
+ toObject(): DateTimeComponents;
829
+ /** Convert to JSON-serializable object */
830
+ toJSON(): ChronosJSON;
831
+ /** Get primitive value (timestamp) */
832
+ valueOf(): number;
833
+ /** Convert to string */
834
+ toString(): string;
835
+ /**
836
+ * Create a clone of this instance
837
+ */
838
+ clone(): Chronos;
839
+ /**
840
+ * Set the locale for this instance
841
+ */
842
+ locale(code: string): Chronos;
843
+ /**
844
+ * Get the current locale code
845
+ */
846
+ getLocale(): string;
847
+ /**
848
+ * Get the next occurrence of a specific day
849
+ */
850
+ next(day: DayOfWeek): Chronos;
851
+ /**
852
+ * Get the previous occurrence of a specific day
853
+ */
854
+ previous(day: DayOfWeek): Chronos;
855
+ /**
856
+ * Get the closest date (either this or other)
857
+ */
858
+ closest(date1: DateInput, date2: DateInput): Chronos;
859
+ /**
860
+ * Get the farthest date (either this or other)
861
+ */
862
+ farthest(date1: DateInput, date2: DateInput): Chronos;
863
+ /**
864
+ * Set global configuration
865
+ */
866
+ static configure(config: Partial<ChronosConfig>): void;
867
+ /**
868
+ * Get current global configuration
869
+ */
870
+ static getConfig(): ChronosConfig;
871
+ /**
872
+ * Set test time (for testing purposes)
873
+ */
874
+ static setTestNow(date?: DateInput): void;
875
+ /**
876
+ * Check if test mode is active
877
+ */
878
+ static hasTestNow(): boolean;
879
+ /**
880
+ * Get the test time
881
+ */
882
+ static getTestNow(): Chronos | null;
883
+ /**
884
+ * Check if the date is valid
885
+ */
886
+ isValid(): boolean;
887
+ /**
888
+ * Check if this date is the same day as another (regardless of time)
889
+ */
890
+ isSameDay(other: DateInput): boolean;
891
+ /**
892
+ * Check if this date is in the same month as another
893
+ */
894
+ isSameMonth(other: DateInput): boolean;
895
+ /**
896
+ * Check if this date is in the same year as another
897
+ */
898
+ isSameYear(other: DateInput): boolean;
899
+ /**
900
+ * Get calendar output for the current month
901
+ */
902
+ calendar(referenceDate?: DateInput): string;
903
+ }
904
+
905
+ /**
906
+ * ChronosInterval - Duration/Interval handling
907
+ * @module ChronosInterval
908
+ */
909
+
910
+ /**
911
+ * ChronosInterval - Represents a duration/interval of time
912
+ *
913
+ * @example
914
+ * ```typescript
915
+ * // Create intervals
916
+ * const interval = ChronosInterval.create({ days: 5, hours: 3 });
917
+ * const hours = ChronosInterval.hours(24);
918
+ * const fromISO = ChronosInterval.fromISO('P1Y2M3D');
919
+ *
920
+ * // Arithmetic
921
+ * const doubled = interval.multiply(2);
922
+ * const combined = interval.add(hours);
923
+ *
924
+ * // Formatting
925
+ * console.log(interval.forHumans()); // "5 days 3 hours"
926
+ * console.log(interval.toISO()); // "P5DT3H"
927
+ * ```
928
+ */
929
+ declare class ChronosInterval {
930
+ private _years;
931
+ private _months;
932
+ private _weeks;
933
+ private _days;
934
+ private _hours;
935
+ private _minutes;
936
+ private _seconds;
937
+ private _milliseconds;
938
+ private _locale;
939
+ private _inverted;
940
+ private constructor();
941
+ /**
942
+ * Create an interval from a duration object
943
+ */
944
+ static create(duration: Duration): ChronosInterval;
945
+ /**
946
+ * Create an interval from years
947
+ */
948
+ static years(years: number): ChronosInterval;
949
+ /**
950
+ * Create an interval from months
951
+ */
952
+ static months(months: number): ChronosInterval;
953
+ /**
954
+ * Create an interval from weeks
955
+ */
956
+ static weeks(weeks: number): ChronosInterval;
957
+ /**
958
+ * Create an interval from days
959
+ */
960
+ static days(days: number): ChronosInterval;
961
+ /**
962
+ * Create an interval from hours
963
+ */
964
+ static hours(hours: number): ChronosInterval;
965
+ /**
966
+ * Create an interval from minutes
967
+ */
968
+ static minutes(minutes: number): ChronosInterval;
969
+ /**
970
+ * Create an interval from seconds
971
+ */
972
+ static seconds(seconds: number): ChronosInterval;
973
+ /**
974
+ * Create an interval from milliseconds
975
+ */
976
+ static milliseconds(milliseconds: number): ChronosInterval;
977
+ /**
978
+ * Create a single unit interval
979
+ */
980
+ static unit(amount: number, unit: AnyTimeUnit): ChronosInterval;
981
+ /**
982
+ * Create from ISO 8601 duration string (P1Y2M3DT4H5M6S)
983
+ */
984
+ static fromISO(iso: string): ChronosInterval;
985
+ /**
986
+ * Create from a human-readable string
987
+ *
988
+ * @example
989
+ * ```typescript
990
+ * ChronosInterval.fromString('2 days 3 hours')
991
+ * ChronosInterval.fromString('1 year, 6 months')
992
+ * ```
993
+ */
994
+ static fromString(input: string): ChronosInterval;
995
+ /**
996
+ * Create a zero-length interval
997
+ */
998
+ static zero(): ChronosInterval;
999
+ /**
1000
+ * Create an interval from the difference between two dates
1001
+ *
1002
+ * @example
1003
+ * ```typescript
1004
+ * const start = new Date('2024-01-01');
1005
+ * const end = new Date('2024-03-15');
1006
+ * const interval = ChronosInterval.between(start, end);
1007
+ * ```
1008
+ */
1009
+ static between(start: Date | {
1010
+ toDate(): Date;
1011
+ }, end: Date | {
1012
+ toDate(): Date;
1013
+ }): ChronosInterval;
1014
+ get years(): number;
1015
+ get months(): number;
1016
+ get weeks(): number;
1017
+ get days(): number;
1018
+ get hours(): number;
1019
+ get minutes(): number;
1020
+ get seconds(): number;
1021
+ get milliseconds(): number;
1022
+ get inverted(): boolean;
1023
+ /**
1024
+ * Get total duration in a specific unit
1025
+ */
1026
+ total(unit: AnyTimeUnit): number;
1027
+ /**
1028
+ * Get total duration in milliseconds
1029
+ */
1030
+ totalMilliseconds(): number;
1031
+ /**
1032
+ * Get total duration in seconds
1033
+ */
1034
+ totalSeconds(): number;
1035
+ /**
1036
+ * Get total duration in minutes
1037
+ */
1038
+ totalMinutes(): number;
1039
+ /**
1040
+ * Get total duration in hours
1041
+ */
1042
+ totalHours(): number;
1043
+ /**
1044
+ * Get total duration in days
1045
+ */
1046
+ totalDays(): number;
1047
+ /**
1048
+ * Get total duration in weeks
1049
+ */
1050
+ totalWeeks(): number;
1051
+ /**
1052
+ * Get total duration in months (approximate)
1053
+ */
1054
+ totalMonths(): number;
1055
+ /**
1056
+ * Get total duration in years (approximate)
1057
+ */
1058
+ totalYears(): number;
1059
+ /**
1060
+ * Add another interval to this one
1061
+ */
1062
+ add(other: ChronosInterval | Duration): ChronosInterval;
1063
+ /**
1064
+ * Subtract another interval from this one
1065
+ */
1066
+ subtract(other: ChronosInterval | Duration): ChronosInterval;
1067
+ /**
1068
+ * Multiply the interval by a factor
1069
+ */
1070
+ multiply(factor: number): ChronosInterval;
1071
+ /**
1072
+ * Divide the interval by a factor
1073
+ */
1074
+ divide(factor: number): ChronosInterval;
1075
+ /**
1076
+ * Negate the interval
1077
+ */
1078
+ negate(): ChronosInterval;
1079
+ /**
1080
+ * Get absolute value of interval
1081
+ */
1082
+ abs(): ChronosInterval;
1083
+ /**
1084
+ * Check if equal to another interval
1085
+ */
1086
+ equals(other: ChronosInterval): boolean;
1087
+ /**
1088
+ * Check if greater than another interval
1089
+ */
1090
+ greaterThan(other: ChronosInterval): boolean;
1091
+ /**
1092
+ * Check if less than another interval
1093
+ */
1094
+ lessThan(other: ChronosInterval): boolean;
1095
+ /**
1096
+ * Check if greater than or equal to another interval
1097
+ */
1098
+ greaterThanOrEqual(other: ChronosInterval): boolean;
1099
+ /**
1100
+ * Check if less than or equal to another interval
1101
+ */
1102
+ lessThanOrEqual(other: ChronosInterval): boolean;
1103
+ /**
1104
+ * Check if the interval is zero
1105
+ */
1106
+ isZero(): boolean;
1107
+ /**
1108
+ * Check if the interval is positive
1109
+ */
1110
+ isPositive(): boolean;
1111
+ /**
1112
+ * Check if the interval is negative
1113
+ */
1114
+ isNegative(): boolean;
1115
+ /**
1116
+ * Cascade units to proper values (normalize overflow)
1117
+ *
1118
+ * @example
1119
+ * 90 seconds becomes 1 minute 30 seconds
1120
+ */
1121
+ cascade(): ChronosInterval;
1122
+ /**
1123
+ * Cascade without including weeks
1124
+ */
1125
+ cascadeWithoutWeeks(): ChronosInterval;
1126
+ /**
1127
+ * Format as ISO 8601 duration
1128
+ */
1129
+ toISO(): string;
1130
+ /**
1131
+ * Format for human reading
1132
+ *
1133
+ * @example
1134
+ * ```typescript
1135
+ * interval.forHumans() // "2 days 3 hours"
1136
+ * interval.forHumans({ short: true }) // "2d 3h"
1137
+ * interval.forHumans({ parts: 2 }) // "2 days 3 hours" (max 2 parts)
1138
+ * ```
1139
+ */
1140
+ forHumans(options?: {
1141
+ short?: boolean;
1142
+ parts?: number;
1143
+ join?: string;
1144
+ conjunction?: string;
1145
+ }): string;
1146
+ /**
1147
+ * Format using a format string
1148
+ *
1149
+ * Tokens:
1150
+ * - %y: years
1151
+ * - %m: months
1152
+ * - %w: weeks
1153
+ * - %d: days
1154
+ * - %h: hours
1155
+ * - %i: minutes
1156
+ * - %s: seconds
1157
+ * - %f: milliseconds
1158
+ * - %R: +/- sign
1159
+ * - %r: +/- or empty
1160
+ */
1161
+ format(formatStr: string): string;
1162
+ /**
1163
+ * Convert to Duration object
1164
+ */
1165
+ toDuration(): Duration;
1166
+ /**
1167
+ * Convert to array
1168
+ */
1169
+ toArray(): number[];
1170
+ /**
1171
+ * Clone this interval
1172
+ */
1173
+ clone(): ChronosInterval;
1174
+ /**
1175
+ * Set locale for this interval
1176
+ */
1177
+ locale(code: string): ChronosInterval;
1178
+ /**
1179
+ * Get primitive value (total milliseconds)
1180
+ */
1181
+ valueOf(): number;
1182
+ /**
1183
+ * Convert to string
1184
+ */
1185
+ toString(): string;
1186
+ /**
1187
+ * Convert to JSON
1188
+ */
1189
+ toJSON(): Duration & {
1190
+ iso: string;
1191
+ };
1192
+ }
1193
+
1194
+ /**
1195
+ * ChronosPeriod - Date range iteration
1196
+ * @module ChronosPeriod
1197
+ */
1198
+
1199
+ /**
1200
+ * ChronosPeriod - Represents a date range with iteration capabilities
28
1201
  *
29
- * // Intervals
30
- * const duration = ChronosInterval.hours(5).addMinutes(30);
31
- * console.log(duration.forHumans()); // "5 hours 30 minutes"
1202
+ * Inspired by CarbonPeriod, this class provides powerful date range
1203
+ * iteration with support for various interval types, filters, and
1204
+ * recurrence patterns.
32
1205
  *
33
- * // Periods
34
- * const week = ChronosPeriod.currentWeek();
35
- * for (const day of week) {
36
- * console.log(day.format('dddd'));
1206
+ * @example
1207
+ * ```typescript
1208
+ * // Basic iteration
1209
+ * const period = ChronosPeriod.create('2024-01-01', '2024-01-31');
1210
+ * for (const date of period) {
1211
+ * console.log(date.format('YYYY-MM-DD'));
37
1212
  * }
38
1213
  *
39
- * // Timezones
40
- * const tz = ChronosTimezone.create('America/New_York');
41
- * console.log(tz.getOffsetString()); // "-05:00"
1214
+ * // With custom interval
1215
+ * const weekly = ChronosPeriod.create('2024-01-01', '2024-03-31')
1216
+ * .setInterval(ChronosInterval.weeks(1));
1217
+ *
1218
+ * // With filters
1219
+ * const weekdays = period.filter(date => date.dayOfWeek < 6);
1220
+ *
1221
+ * // Recurrence
1222
+ * const recur = ChronosPeriod.recur('2024-01-01')
1223
+ * .every(1, 'month')
1224
+ * .times(12);
1225
+ * ```
1226
+ */
1227
+ declare class ChronosPeriod implements Iterable<Chronos> {
1228
+ private _start;
1229
+ private _end;
1230
+ private _interval;
1231
+ private _recurrences;
1232
+ private _options;
1233
+ private _filters;
1234
+ private _locale;
1235
+ /**
1236
+ * Create a new ChronosPeriod
1237
+ */
1238
+ constructor(start: DateInput, end?: DateInput, interval?: Duration | ChronosInterval, options?: Partial<PeriodOptions>);
1239
+ /**
1240
+ * Create a period between two dates
1241
+ */
1242
+ static create(start: DateInput, end?: DateInput, interval?: Duration | ChronosInterval): ChronosPeriod;
1243
+ /**
1244
+ * Create a period from a start date with recurrences
1245
+ */
1246
+ static recur(start: DateInput, interval?: Duration | ChronosInterval): ChronosPeriod;
1247
+ /**
1248
+ * Create a period for a specific number of days
1249
+ */
1250
+ static days(start: DateInput, count: number): ChronosPeriod;
1251
+ /**
1252
+ * Create a period for a specific number of weeks
1253
+ */
1254
+ static weeks(start: DateInput, count: number): ChronosPeriod;
1255
+ /**
1256
+ * Create a period for a specific number of months
1257
+ */
1258
+ static months(start: DateInput, count: number): ChronosPeriod;
1259
+ /**
1260
+ * Create a period for a specific number of years
1261
+ */
1262
+ static years(start: DateInput, count: number): ChronosPeriod;
1263
+ /**
1264
+ * Create a period for the current month
1265
+ */
1266
+ static currentMonth(): ChronosPeriod;
1267
+ /**
1268
+ * Create a period for the current year
1269
+ */
1270
+ static currentYear(): ChronosPeriod;
1271
+ /**
1272
+ * Create a period for the current week
1273
+ */
1274
+ static currentWeek(): ChronosPeriod;
1275
+ /**
1276
+ * Create a period for the current quarter
1277
+ */
1278
+ static currentQuarter(): ChronosPeriod;
1279
+ /**
1280
+ * Alias for currentWeek()
1281
+ */
1282
+ static thisWeek(): ChronosPeriod;
1283
+ /**
1284
+ * Alias for currentMonth()
1285
+ */
1286
+ static thisMonth(): ChronosPeriod;
1287
+ /**
1288
+ * Alias for currentYear()
1289
+ */
1290
+ static thisYear(): ChronosPeriod;
1291
+ /**
1292
+ * Alias for currentQuarter()
1293
+ */
1294
+ static thisQuarter(): ChronosPeriod;
1295
+ /**
1296
+ * Create a period for the previous week
1297
+ */
1298
+ static lastWeek(): ChronosPeriod;
1299
+ /**
1300
+ * Create a period for the previous month
1301
+ */
1302
+ static lastMonth(): ChronosPeriod;
1303
+ /**
1304
+ * Create a period for the previous year
1305
+ */
1306
+ static lastYear(): ChronosPeriod;
1307
+ /**
1308
+ * Create a period for the previous quarter
1309
+ */
1310
+ static lastQuarter(): ChronosPeriod;
1311
+ /**
1312
+ * Create a period for the next week
1313
+ */
1314
+ static nextWeek(): ChronosPeriod;
1315
+ /**
1316
+ * Create a period for the next month
1317
+ */
1318
+ static nextMonth(): ChronosPeriod;
1319
+ /**
1320
+ * Create a period for the next year
1321
+ */
1322
+ static nextYear(): ChronosPeriod;
1323
+ /**
1324
+ * Create a period for the next quarter
1325
+ */
1326
+ static nextQuarter(): ChronosPeriod;
1327
+ /**
1328
+ * Create a period between two dates (alias for create)
1329
+ */
1330
+ static between(start: DateInput, end: DateInput, interval?: Duration | ChronosInterval): ChronosPeriod;
1331
+ /**
1332
+ * Create a period from an ISO 8601 repeating interval string
1333
+ * @example
1334
+ * ```typescript
1335
+ * ChronosPeriod.fromISO('R5/2024-01-01/P1D') // 5 recurrences, daily from 2024-01-01
1336
+ * ChronosPeriod.fromISO('2024-01-01/2024-01-31') // Date range
1337
+ * ChronosPeriod.fromISO('2024-01-01/P1M') // From date with duration
1338
+ * ```
1339
+ */
1340
+ static fromISO(iso: string): ChronosPeriod;
1341
+ /**
1342
+ * Get the start date
1343
+ */
1344
+ get start(): Chronos;
1345
+ /**
1346
+ * Get the end date
1347
+ */
1348
+ get end(): Chronos | null;
1349
+ /**
1350
+ * Get the interval
1351
+ */
1352
+ get interval(): ChronosInterval;
1353
+ /**
1354
+ * Get the number of recurrences
1355
+ */
1356
+ get recurrences(): number | null;
1357
+ /**
1358
+ * Check if the period includes the start boundary
1359
+ */
1360
+ get includesStart(): boolean;
1361
+ /**
1362
+ * Check if the period includes the end boundary
1363
+ */
1364
+ get includesEnd(): boolean;
1365
+ /**
1366
+ * Check if the period has an end date
1367
+ */
1368
+ get hasEnd(): boolean;
1369
+ /**
1370
+ * Check if the period is unbounded
1371
+ */
1372
+ get isUnbounded(): boolean;
1373
+ /**
1374
+ * Set the start date
1375
+ */
1376
+ setStart(start: DateInput): ChronosPeriod;
1377
+ /**
1378
+ * Set the end date
1379
+ */
1380
+ setEnd(end: DateInput): ChronosPeriod;
1381
+ /**
1382
+ * Set the interval
1383
+ */
1384
+ setInterval(interval: Duration | ChronosInterval): ChronosPeriod;
1385
+ /**
1386
+ * Set the number of recurrences
1387
+ */
1388
+ times(count: number): ChronosPeriod;
1389
+ /**
1390
+ * Set interval by unit
1391
+ */
1392
+ every(amount: number, unit: AnyTimeUnit): ChronosPeriod;
1393
+ /**
1394
+ * Exclude the start boundary
1395
+ */
1396
+ excludeStart(): ChronosPeriod;
1397
+ /**
1398
+ * Exclude the end boundary
1399
+ */
1400
+ excludeEnd(): ChronosPeriod;
1401
+ /**
1402
+ * Include the start boundary
1403
+ */
1404
+ includeStart(): ChronosPeriod;
1405
+ /**
1406
+ * Include the end boundary
1407
+ */
1408
+ includeEnd(): ChronosPeriod;
1409
+ /**
1410
+ * Add a filter function
1411
+ */
1412
+ filter(fn: (date: Chronos, key: number) => boolean): ChronosPeriod;
1413
+ /**
1414
+ * Filter to only include weekdays
1415
+ */
1416
+ weekdays(): ChronosPeriod;
1417
+ /**
1418
+ * Alias for weekdays()
1419
+ */
1420
+ filterWeekdays(): ChronosPeriod;
1421
+ /**
1422
+ * Filter to only include weekends
1423
+ */
1424
+ weekends(): ChronosPeriod;
1425
+ /**
1426
+ * Alias for weekends()
1427
+ */
1428
+ filterWeekends(): ChronosPeriod;
1429
+ /**
1430
+ * Filter to only include specific days of week
1431
+ */
1432
+ onlyDays(...days: number[]): ChronosPeriod;
1433
+ /**
1434
+ * Filter to exclude specific days of week
1435
+ */
1436
+ exceptDays(...days: number[]): ChronosPeriod;
1437
+ /**
1438
+ * Filter to only include specific months
1439
+ */
1440
+ onlyMonths(...months: number[]): ChronosPeriod;
1441
+ /**
1442
+ * Filter to exclude specific months
1443
+ */
1444
+ exceptMonths(...months: number[]): ChronosPeriod;
1445
+ /**
1446
+ * Clear all filters
1447
+ */
1448
+ clearFilters(): ChronosPeriod;
1449
+ /**
1450
+ * Get all dates in the period as an array
1451
+ */
1452
+ toArray(): Chronos[];
1453
+ /**
1454
+ * Iterate over the period
1455
+ */
1456
+ [Symbol.iterator](): Iterator<Chronos>;
1457
+ /**
1458
+ * Apply the interval to a date
1459
+ */
1460
+ private _applyInterval;
1461
+ /**
1462
+ * Check if iteration should continue
1463
+ */
1464
+ private _shouldContinue;
1465
+ /**
1466
+ * Check if a date passes all filters
1467
+ */
1468
+ private _passesFilters;
1469
+ /**
1470
+ * Get count of dates in the period
1471
+ */
1472
+ count(): number;
1473
+ /**
1474
+ * Get the first date in the period
1475
+ */
1476
+ first(): Chronos | null;
1477
+ /**
1478
+ * Get the last date in the period
1479
+ */
1480
+ last(): Chronos | null;
1481
+ /**
1482
+ * Get a date at a specific index
1483
+ */
1484
+ nth(index: number): Chronos | null;
1485
+ /**
1486
+ * Check if a date is within the period
1487
+ */
1488
+ contains(date: DateInput): boolean;
1489
+ /**
1490
+ * For each iteration
1491
+ */
1492
+ forEach(callback: (date: Chronos, index: number) => void): void;
1493
+ /**
1494
+ * Map dates to another type
1495
+ */
1496
+ map<T>(callback: (date: Chronos, index: number) => T): T[];
1497
+ /**
1498
+ * Reduce dates to a single value
1499
+ */
1500
+ reduce<T>(callback: (acc: T, date: Chronos, index: number) => T, initial: T): T;
1501
+ /**
1502
+ * Resolve the effective end of the period.
1503
+ * Returns null for a truly unbounded period (no end and no recurrence limit),
1504
+ * which avoids calling last() — that would iterate until the safety limit and throw.
1505
+ */
1506
+ private _resolvedEnd;
1507
+ /**
1508
+ * Check if two periods overlap
1509
+ */
1510
+ overlaps(other: ChronosPeriod): boolean;
1511
+ /**
1512
+ * Get the intersection of two periods
1513
+ */
1514
+ intersect(other: ChronosPeriod): ChronosPeriod | null;
1515
+ /**
1516
+ * Get the union of two periods
1517
+ */
1518
+ union(other: ChronosPeriod): ChronosPeriod | null;
1519
+ /**
1520
+ * Get the difference between two periods
1521
+ * Returns the parts of this period that don't overlap with the other period
1522
+ */
1523
+ diff(other: ChronosPeriod): ChronosPeriod[];
1524
+ /**
1525
+ * Check if this period is adjacent to another
1526
+ */
1527
+ private _adjacentTo;
1528
+ /**
1529
+ * Get the duration of the period
1530
+ */
1531
+ duration(): ChronosInterval;
1532
+ /**
1533
+ * Get the number of days in the period
1534
+ */
1535
+ days(): number;
1536
+ /**
1537
+ * Get the number of weeks in the period
1538
+ */
1539
+ weeks(): number;
1540
+ /**
1541
+ * Get the number of months in the period
1542
+ */
1543
+ monthCount(): number;
1544
+ /**
1545
+ * Get the number of years in the period
1546
+ */
1547
+ yearCount(): number;
1548
+ /**
1549
+ * Split the period into chunks
1550
+ */
1551
+ split(count: number): ChronosPeriod[];
1552
+ /**
1553
+ * Split by a specific interval
1554
+ */
1555
+ splitBy(interval: Duration | ChronosInterval): ChronosPeriod[];
1556
+ /**
1557
+ * Split the period by a specified number of days
1558
+ */
1559
+ splitByDays(days: number): ChronosPeriod[];
1560
+ /**
1561
+ * Split the period by a specified number of weeks
1562
+ */
1563
+ splitByWeeks(weeks: number): ChronosPeriod[];
1564
+ /**
1565
+ * Split the period by a specified number of months
1566
+ */
1567
+ splitByMonths(months: number): ChronosPeriod[];
1568
+ /**
1569
+ * Split the period by a specified number of years
1570
+ */
1571
+ splitByYears(years: number): ChronosPeriod[];
1572
+ /**
1573
+ * Skip specific dates from the period iteration
1574
+ * @param dates - Dates to exclude from iteration
1575
+ */
1576
+ skip(dates: DateInput[]): ChronosPeriod;
1577
+ /**
1578
+ * Convert to ISO 8601 string
1579
+ */
1580
+ toISO(): string;
1581
+ /**
1582
+ * Convert to string
1583
+ */
1584
+ toString(): string;
1585
+ /**
1586
+ * Convert to human-readable string
1587
+ */
1588
+ forHumans(): string;
1589
+ /**
1590
+ * Convert to JSON
1591
+ */
1592
+ toJSON(): object;
1593
+ /**
1594
+ * Clone this period
1595
+ */
1596
+ clone(): ChronosPeriod;
1597
+ /**
1598
+ * Clone for modification (respects immutable option)
1599
+ */
1600
+ private _cloneForModification;
1601
+ /**
1602
+ * Set locale for this period
1603
+ */
1604
+ locale(code: string): ChronosPeriod;
1605
+ /**
1606
+ * Create a period for a specific month
1607
+ */
1608
+ static month(year: number, month: number): ChronosPeriod;
1609
+ /**
1610
+ * Create a period for a specific year
1611
+ */
1612
+ static year(year: number): ChronosPeriod;
1613
+ /**
1614
+ * Create a period for a specific quarter
1615
+ */
1616
+ static quarter(year: number, quarter: number): ChronosPeriod;
1617
+ /**
1618
+ * Create a period between two dates as weekdays only
1619
+ */
1620
+ static weekdaysBetween(start: DateInput, end: DateInput): ChronosPeriod;
1621
+ /**
1622
+ * Create a period with business days only (weekdays, can add holidays filter)
1623
+ */
1624
+ static businessDays(start: DateInput, end: DateInput, holidays?: DateInput[]): ChronosPeriod;
1625
+ }
1626
+
1627
+ /**
1628
+ * ChronosPeriodCollection - Manage collections of ChronosPeriod
1629
+ * Inspired by spatie/period PHP library
1630
+ * @see https://github.com/spatie/period
1631
+ */
1632
+
1633
+ /**
1634
+ * ChronosPeriodCollection - A collection of periods with powerful operations
1635
+ *
1636
+ * Inspired by spatie/period, this class provides a rich API for working with
1637
+ * collections of time periods including overlap detection, gap analysis,
1638
+ * and set operations.
1639
+ *
1640
+ * @example
1641
+ * ```typescript
1642
+ * const collection = new ChronosPeriodCollection([
1643
+ * ChronosPeriod.create('2024-01-01', '2024-01-15'),
1644
+ * ChronosPeriod.create('2024-01-10', '2024-01-25'),
1645
+ * ChronosPeriod.create('2024-02-01', '2024-02-15'),
1646
+ * ]);
1647
+ *
1648
+ * // Find overlapping periods
1649
+ * const overlapping = collection.overlapAll();
1650
+ *
1651
+ * // Get gaps between periods
1652
+ * const gaps = collection.gaps();
1653
+ *
1654
+ * // Get boundaries
1655
+ * const boundaries = collection.boundaries();
42
1656
  * ```
1657
+ */
1658
+ declare class ChronosPeriodCollection implements Iterable<ChronosPeriod> {
1659
+ private _periods;
1660
+ constructor(periods?: ChronosPeriod[]);
1661
+ /**
1662
+ * Create a new collection from periods
1663
+ */
1664
+ static create(...periods: ChronosPeriod[]): ChronosPeriodCollection;
1665
+ /**
1666
+ * Create an empty collection
1667
+ */
1668
+ static empty(): ChronosPeriodCollection;
1669
+ /**
1670
+ * Create a collection from an array of date pairs
1671
+ */
1672
+ static fromDatePairs(pairs: Array<[DateInput, DateInput]>): ChronosPeriodCollection;
1673
+ /** Add a period to the collection */
1674
+ add(period: ChronosPeriod): this;
1675
+ /** Add multiple periods */
1676
+ addAll(periods: ChronosPeriod[]): this;
1677
+ /** Get a shallow copy of periods */
1678
+ toArray(): ChronosPeriod[];
1679
+ /** Get the number of periods in the collection */
1680
+ get length(): number;
1681
+ /** Check if collection is empty */
1682
+ isEmpty(): boolean;
1683
+ /** Check if collection is not empty */
1684
+ isNotEmpty(): boolean;
1685
+ /** Get a period at a specific index */
1686
+ get(index: number): ChronosPeriod | undefined;
1687
+ /** Get the first period */
1688
+ first(): ChronosPeriod | undefined;
1689
+ /** Get the last period */
1690
+ last(): ChronosPeriod | undefined;
1691
+ /** Clear collection */
1692
+ clear(): this;
1693
+ /** Iterator implementation */
1694
+ [Symbol.iterator](): Iterator<ChronosPeriod>;
1695
+ /** ForEach iteration */
1696
+ forEach(callback: (period: ChronosPeriod, index: number) => void): void;
1697
+ /** Map periods to a new array */
1698
+ map<T>(callback: (period: ChronosPeriod, index: number) => T): T[];
1699
+ /** Filter periods */
1700
+ filter(predicate: (period: ChronosPeriod, index: number) => boolean): ChronosPeriodCollection;
1701
+ /** Reduce periods to a single value */
1702
+ reduce<T>(callback: (acc: T, period: ChronosPeriod, index: number) => T, initial: T): T;
1703
+ /** Find a period matching a predicate */
1704
+ find(predicate: (period: ChronosPeriod, index: number) => boolean): ChronosPeriod | undefined;
1705
+ /** Check if any period matches a predicate */
1706
+ some(predicate: (period: ChronosPeriod, index: number) => boolean): boolean;
1707
+ /** Check if all periods match a predicate */
1708
+ every(predicate: (period: ChronosPeriod, index: number) => boolean): boolean;
1709
+ /**
1710
+ * Get the overall boundaries of the collection
1711
+ * Returns a period from the earliest start to the latest end
1712
+ */
1713
+ boundaries(): ChronosPeriod | null;
1714
+ /**
1715
+ * Get the earliest start date across all periods
1716
+ */
1717
+ start(): Chronos | null;
1718
+ /**
1719
+ * Get the latest end date across all periods
1720
+ */
1721
+ end(): Chronos | null;
1722
+ /** Normalize and merge overlapping/adjacent periods */
1723
+ normalize(): ChronosPeriod[];
1724
+ /** Check if any period overlaps with the provided period */
1725
+ overlaps(period: ChronosPeriod): boolean;
1726
+ /**
1727
+ * Check if any period in the collection overlaps with any other period
1728
+ * in the collection (internal overlaps)
1729
+ */
1730
+ overlapAny(): boolean;
1731
+ /**
1732
+ * Get all overlapping period segments across the collection
1733
+ * Returns periods where two or more periods in the collection overlap
1734
+ */
1735
+ overlapAll(): ChronosPeriodCollection;
1736
+ /** Return intersections between collection and a given period */
1737
+ intersect(period: ChronosPeriod): ChronosPeriodCollection;
1738
+ /**
1739
+ * Get intersection of all periods in the collection
1740
+ * Returns the period where ALL periods overlap (if any)
1741
+ */
1742
+ intersectAll(): ChronosPeriod | null;
1743
+ /** Return the union (merged) of all periods in the collection */
1744
+ union(): ChronosPeriodCollection;
1745
+ /**
1746
+ * Alias for normalize() - returns merged periods
1747
+ * @deprecated Use union() instead
1748
+ */
1749
+ unionAll(): ChronosPeriod[];
1750
+ /** Merge collection into a single union period if contiguous/overlapping */
1751
+ mergeToSingle(): ChronosPeriod | null;
1752
+ /** Return gaps between merged periods */
1753
+ gaps(): ChronosPeriodCollection;
1754
+ /**
1755
+ * Check if there are any gaps between periods
1756
+ */
1757
+ hasGaps(): boolean;
1758
+ /**
1759
+ * Subtract a period from all periods in the collection
1760
+ * Returns periods with the subtracted portion removed
1761
+ */
1762
+ subtract(period: ChronosPeriod): ChronosPeriodCollection;
1763
+ /**
1764
+ * Subtract multiple periods from the collection
1765
+ */
1766
+ subtractAll(periods: ChronosPeriod[]): ChronosPeriodCollection;
1767
+ /**
1768
+ * Check if any period touches (is adjacent to) the given period
1769
+ * Two periods touch if one ends exactly where the other begins
1770
+ */
1771
+ touchesWith(period: ChronosPeriod): boolean;
1772
+ /**
1773
+ * Check if two periods touch (are adjacent)
1774
+ */
1775
+ private _periodsTouch;
1776
+ /**
1777
+ * Get all periods that touch the given period
1778
+ */
1779
+ touchingPeriods(period: ChronosPeriod): ChronosPeriodCollection;
1780
+ /**
1781
+ * Check if a date is contained in any period of the collection
1782
+ */
1783
+ contains(date: DateInput): boolean;
1784
+ /**
1785
+ * Check if a period is fully contained in any period of the collection
1786
+ */
1787
+ containsPeriod(period: ChronosPeriod): boolean;
1788
+ /**
1789
+ * Check if two collections are equal (same periods)
1790
+ */
1791
+ equals(other: ChronosPeriodCollection): boolean;
1792
+ /**
1793
+ * Get periods sorted by start date
1794
+ */
1795
+ private _sortedByStart;
1796
+ /**
1797
+ * Sort periods by start date (ascending)
1798
+ */
1799
+ sortByStart(): ChronosPeriodCollection;
1800
+ /**
1801
+ * Sort periods by end date (ascending)
1802
+ */
1803
+ sortByEnd(): ChronosPeriodCollection;
1804
+ /**
1805
+ * Sort periods by duration (ascending)
1806
+ */
1807
+ sortByDuration(): ChronosPeriodCollection;
1808
+ /**
1809
+ * Reverse the order of periods
1810
+ */
1811
+ reverse(): ChronosPeriodCollection;
1812
+ /**
1813
+ * Convert to JSON
1814
+ */
1815
+ toJSON(): object[];
1816
+ /**
1817
+ * Convert to string
1818
+ */
1819
+ toString(): string;
1820
+ /**
1821
+ * Get total duration across all periods (in days)
1822
+ * Note: Overlapping portions may be counted multiple times
1823
+ */
1824
+ totalDays(): number;
1825
+ /**
1826
+ * Get total unique duration (merged periods, no double-counting)
1827
+ */
1828
+ uniqueDays(): number;
1829
+ }
1830
+
1831
+ /**
1832
+ * ChronosTimezone - Timezone handling and conversions
1833
+ * @module ChronosTimezone
1834
+ */
1835
+
1836
+ /**
1837
+ * Common timezone identifiers
1838
+ */
1839
+ declare const TIMEZONES: {
1840
+ readonly UTC: "UTC";
1841
+ readonly GMT: "GMT";
1842
+ readonly 'America/New_York': "America/New_York";
1843
+ readonly 'America/Chicago': "America/Chicago";
1844
+ readonly 'America/Denver': "America/Denver";
1845
+ readonly 'America/Los_Angeles': "America/Los_Angeles";
1846
+ readonly 'America/Phoenix': "America/Phoenix";
1847
+ readonly 'America/Anchorage': "America/Anchorage";
1848
+ readonly 'America/Toronto': "America/Toronto";
1849
+ readonly 'America/Vancouver': "America/Vancouver";
1850
+ readonly 'America/Mexico_City': "America/Mexico_City";
1851
+ readonly 'America/Sao_Paulo': "America/Sao_Paulo";
1852
+ readonly 'America/Buenos_Aires': "America/Buenos_Aires";
1853
+ readonly 'America/Lima': "America/Lima";
1854
+ readonly 'America/Bogota': "America/Bogota";
1855
+ readonly 'Europe/London': "Europe/London";
1856
+ readonly 'Europe/Paris': "Europe/Paris";
1857
+ readonly 'Europe/Berlin': "Europe/Berlin";
1858
+ readonly 'Europe/Madrid': "Europe/Madrid";
1859
+ readonly 'Europe/Rome': "Europe/Rome";
1860
+ readonly 'Europe/Amsterdam': "Europe/Amsterdam";
1861
+ readonly 'Europe/Brussels': "Europe/Brussels";
1862
+ readonly 'Europe/Vienna': "Europe/Vienna";
1863
+ readonly 'Europe/Warsaw': "Europe/Warsaw";
1864
+ readonly 'Europe/Prague': "Europe/Prague";
1865
+ readonly 'Europe/Moscow': "Europe/Moscow";
1866
+ readonly 'Europe/Istanbul': "Europe/Istanbul";
1867
+ readonly 'Europe/Athens': "Europe/Athens";
1868
+ readonly 'Europe/Helsinki': "Europe/Helsinki";
1869
+ readonly 'Europe/Stockholm': "Europe/Stockholm";
1870
+ readonly 'Europe/Oslo': "Europe/Oslo";
1871
+ readonly 'Europe/Copenhagen': "Europe/Copenhagen";
1872
+ readonly 'Europe/Dublin': "Europe/Dublin";
1873
+ readonly 'Europe/Zurich': "Europe/Zurich";
1874
+ readonly 'Asia/Tokyo': "Asia/Tokyo";
1875
+ readonly 'Asia/Shanghai': "Asia/Shanghai";
1876
+ readonly 'Asia/Hong_Kong': "Asia/Hong_Kong";
1877
+ readonly 'Asia/Singapore': "Asia/Singapore";
1878
+ readonly 'Asia/Seoul': "Asia/Seoul";
1879
+ readonly 'Asia/Taipei': "Asia/Taipei";
1880
+ readonly 'Asia/Bangkok': "Asia/Bangkok";
1881
+ readonly 'Asia/Jakarta': "Asia/Jakarta";
1882
+ readonly 'Asia/Manila': "Asia/Manila";
1883
+ readonly 'Asia/Kuala_Lumpur': "Asia/Kuala_Lumpur";
1884
+ readonly 'Asia/Ho_Chi_Minh': "Asia/Ho_Chi_Minh";
1885
+ readonly 'Asia/Dubai': "Asia/Dubai";
1886
+ readonly 'Asia/Kolkata': "Asia/Kolkata";
1887
+ readonly 'Asia/Mumbai': "Asia/Mumbai";
1888
+ readonly 'Asia/Karachi': "Asia/Karachi";
1889
+ readonly 'Asia/Dhaka': "Asia/Dhaka";
1890
+ readonly 'Asia/Tehran': "Asia/Tehran";
1891
+ readonly 'Asia/Riyadh': "Asia/Riyadh";
1892
+ readonly 'Asia/Jerusalem': "Asia/Jerusalem";
1893
+ readonly 'Australia/Sydney': "Australia/Sydney";
1894
+ readonly 'Australia/Melbourne': "Australia/Melbourne";
1895
+ readonly 'Australia/Brisbane': "Australia/Brisbane";
1896
+ readonly 'Australia/Perth': "Australia/Perth";
1897
+ readonly 'Australia/Adelaide': "Australia/Adelaide";
1898
+ readonly 'Pacific/Auckland': "Pacific/Auckland";
1899
+ readonly 'Pacific/Fiji': "Pacific/Fiji";
1900
+ readonly 'Pacific/Honolulu': "Pacific/Honolulu";
1901
+ readonly 'Africa/Cairo': "Africa/Cairo";
1902
+ readonly 'Africa/Johannesburg': "Africa/Johannesburg";
1903
+ readonly 'Africa/Lagos': "Africa/Lagos";
1904
+ readonly 'Africa/Nairobi': "Africa/Nairobi";
1905
+ readonly 'Africa/Casablanca': "Africa/Casablanca";
1906
+ };
1907
+ type TimezoneId = keyof typeof TIMEZONES | string;
1908
+ /**
1909
+ * ChronosTimezone - Handles timezone operations and conversions
1910
+ *
1911
+ * This class provides comprehensive timezone handling including:
1912
+ * - Timezone information retrieval
1913
+ * - Offset calculations
1914
+ * - DST detection
1915
+ * - Timezone conversions
1916
+ *
1917
+ * @example
1918
+ * ```typescript
1919
+ * // Get timezone info
1920
+ * const tz = ChronosTimezone.create('America/New_York');
1921
+ * console.log(tz.offset); // -5 or -4 depending on DST
1922
+ *
1923
+ * // Check DST
1924
+ * console.log(tz.isDST(new Date())); // true/false
43
1925
  *
44
- * @packageDocumentation
1926
+ * // Convert between timezones
1927
+ * const utcDate = new Date();
1928
+ * const localDate = ChronosTimezone.convert(utcDate, 'UTC', 'America/New_York');
1929
+ * ```
1930
+ */
1931
+ declare class ChronosTimezone {
1932
+ private _identifier;
1933
+ private _originalOffset;
1934
+ private _extraMinutes;
1935
+ private _cachedOffset;
1936
+ private _cachedDate;
1937
+ /**
1938
+ * Create a new ChronosTimezone
1939
+ */
1940
+ constructor(identifier?: TimezoneId);
1941
+ /**
1942
+ * Normalize timezone identifier
1943
+ */
1944
+ private _normalizeIdentifier;
1945
+ /**
1946
+ * Parse offset string to hours
1947
+ */
1948
+ private _parseOffsetString;
1949
+ /**
1950
+ * Create a timezone instance
1951
+ */
1952
+ static create(identifier?: TimezoneId): ChronosTimezone;
1953
+ /**
1954
+ * Create UTC timezone
1955
+ */
1956
+ static utc(): ChronosTimezone;
1957
+ /**
1958
+ * Create timezone from local system timezone
1959
+ */
1960
+ static local(): ChronosTimezone;
1961
+ /**
1962
+ * Create timezone from offset in hours
1963
+ */
1964
+ static fromOffset(offsetHours: number): ChronosTimezone;
1965
+ /**
1966
+ * Get the local system timezone identifier
1967
+ */
1968
+ static localIdentifier(): string;
1969
+ /**
1970
+ * Get timezone identifier
1971
+ * Returns the original offset string if created from an offset, otherwise returns the IANA identifier
1972
+ */
1973
+ get identifier(): string;
1974
+ /**
1975
+ * Get the internal IANA timezone identifier (used for Intl operations)
1976
+ */
1977
+ get ianaIdentifier(): string;
1978
+ /**
1979
+ * Get timezone name (alias for identifier)
1980
+ */
1981
+ get name(): string;
1982
+ /**
1983
+ * Get timezone abbreviation for a given date
1984
+ */
1985
+ getAbbreviation(date?: Date): string;
1986
+ /**
1987
+ * Get full timezone name for a given date
1988
+ */
1989
+ getFullName(date?: Date): string;
1990
+ /**
1991
+ * Get UTC offset in minutes for a given date
1992
+ */
1993
+ getOffsetMinutes(date?: Date): number;
1994
+ /**
1995
+ * Parse Intl formatter parts to components
1996
+ */
1997
+ private _parseIntlParts;
1998
+ /**
1999
+ * Get UTC offset in hours for a given date
2000
+ */
2001
+ getOffsetHours(date?: Date): number;
2002
+ /**
2003
+ * Get UTC offset as string (e.g., "+05:30", "-08:00")
2004
+ */
2005
+ getOffsetString(date?: Date): string;
2006
+ /**
2007
+ * Get complete offset information
2008
+ */
2009
+ getOffset(date?: Date): TimezoneOffset;
2010
+ /**
2011
+ * Check if DST is in effect for a given date
2012
+ */
2013
+ isDST(date?: Date): boolean;
2014
+ /**
2015
+ * Check if timezone observes DST
2016
+ */
2017
+ observesDST(): boolean;
2018
+ /**
2019
+ * Get the next DST transition
2020
+ */
2021
+ getNextDSTTransition(from?: Date): DSTransition | null;
2022
+ /**
2023
+ * Binary search to find exact DST transition time
2024
+ */
2025
+ private _findExactTransition;
2026
+ /**
2027
+ * Convert a date to this timezone (returns formatted string)
2028
+ */
2029
+ format(date: Date, formatOptions?: Intl.DateTimeFormatOptions): string;
2030
+ /**
2031
+ * Get date components in this timezone
2032
+ */
2033
+ getComponents(date: Date): {
2034
+ year: number;
2035
+ month: number;
2036
+ day: number;
2037
+ hour: number;
2038
+ minute: number;
2039
+ second: number;
2040
+ dayOfWeek: number;
2041
+ };
2042
+ /**
2043
+ * Convert a date from one timezone to another
2044
+ */
2045
+ static convert(date: Date, from: TimezoneId, to: TimezoneId): Date;
2046
+ /**
2047
+ * Convert a UTC date to this timezone
2048
+ */
2049
+ fromUTC(date: Date): Date;
2050
+ /**
2051
+ * Convert a date in this timezone to UTC
2052
+ */
2053
+ toUTC(date: Date): Date;
2054
+ /**
2055
+ * Get comprehensive timezone information
2056
+ */
2057
+ getInfo(date?: Date): TimezoneInfo;
2058
+ /**
2059
+ * Check if two timezones are equivalent at a given moment
2060
+ */
2061
+ equals(other: ChronosTimezone | string, date?: Date): boolean;
2062
+ /**
2063
+ * Check if this is the same timezone identifier
2064
+ */
2065
+ isSame(other: ChronosTimezone | string): boolean;
2066
+ /**
2067
+ * Get all available timezone identifiers
2068
+ * Note: This returns common timezones. Use Intl.supportedValuesOf('timeZone') for all.
2069
+ */
2070
+ static getAvailableTimezones(): string[];
2071
+ /**
2072
+ * Check if a timezone identifier is valid
2073
+ */
2074
+ static isValid(identifier: string): boolean;
2075
+ /**
2076
+ * Get timezones grouped by region
2077
+ */
2078
+ static getTimezonesByRegion(): Record<string, string[]>;
2079
+ /**
2080
+ * Find timezones that match a given offset
2081
+ */
2082
+ static findByOffset(offsetHours: number, date?: Date): ChronosTimezone[];
2083
+ /**
2084
+ * Get current time in a specific timezone
2085
+ */
2086
+ static now(identifier: TimezoneId): Date;
2087
+ /**
2088
+ * Convert to string
2089
+ */
2090
+ toString(): string;
2091
+ /**
2092
+ * Convert to JSON
2093
+ */
2094
+ toJSON(): object;
2095
+ /**
2096
+ * Get primitive value
2097
+ */
2098
+ valueOf(): string;
2099
+ }
2100
+ /**
2101
+ * Pre-created timezone instances for common timezones
2102
+ */
2103
+ declare const Timezones: {
2104
+ readonly UTC: ChronosTimezone;
2105
+ readonly Local: ChronosTimezone;
2106
+ readonly Eastern: ChronosTimezone;
2107
+ readonly Central: ChronosTimezone;
2108
+ readonly Mountain: ChronosTimezone;
2109
+ readonly Pacific: ChronosTimezone;
2110
+ readonly London: ChronosTimezone;
2111
+ readonly Paris: ChronosTimezone;
2112
+ readonly Berlin: ChronosTimezone;
2113
+ readonly Tokyo: ChronosTimezone;
2114
+ readonly Shanghai: ChronosTimezone;
2115
+ readonly Singapore: ChronosTimezone;
2116
+ readonly Dubai: ChronosTimezone;
2117
+ readonly Mumbai: ChronosTimezone;
2118
+ readonly Sydney: ChronosTimezone;
2119
+ readonly Auckland: ChronosTimezone;
2120
+ };
2121
+
2122
+ /**
2123
+ * Utility functions for Chronos
2124
+ * @module utils
2125
+ */
2126
+
2127
+ /**
2128
+ * Check if value is a Date object
2129
+ */
2130
+ declare function isDate(value: unknown): value is Date;
2131
+ /**
2132
+ * Check if value is a valid date input
2133
+ */
2134
+ declare function isValidDateInput(value: unknown): value is DateInput;
2135
+ /**
2136
+ * Check if value implements ChronosLike interface
2137
+ */
2138
+ declare function isChronosLike(value: unknown): value is ChronosLike;
2139
+ /**
2140
+ * Check if value is a Duration object
2141
+ */
2142
+ declare function isDuration(value: unknown): value is Duration;
2143
+ /**
2144
+ * Check if value is a valid ISO 8601 duration string
2145
+ */
2146
+ declare function isISODuration(value: unknown): value is string;
2147
+ /**
2148
+ * Check if a year is a leap year
2149
+ */
2150
+ declare function isLeapYear(year: number): boolean;
2151
+ /**
2152
+ * Normalize a time unit to its canonical form
2153
+ */
2154
+ declare function normalizeUnit(unit: AnyTimeUnit | string): TimeUnit;
2155
+ /**
2156
+ * Get the plural form of a time unit
2157
+ */
2158
+ declare function pluralizeUnit(unit: TimeUnit, count: number): string;
2159
+ /**
2160
+ * Get milliseconds for a given time unit
2161
+ */
2162
+ declare function getMillisecondsPerUnit(unit: TimeUnit): number;
2163
+ /**
2164
+ * Get the number of days in a specific month
2165
+ */
2166
+ declare function getDaysInMonth(year: number, month: number): number;
2167
+ /**
2168
+ * Get the number of days in a year
2169
+ */
2170
+ declare function getDaysInYear(year: number): number;
2171
+ /**
2172
+ * Get the day of year (1-366)
2173
+ */
2174
+ declare function getDayOfYear(date: Date): number;
2175
+ /**
2176
+ * Get the ISO week number (1-53)
2177
+ */
2178
+ declare function getISOWeek(date: Date): number;
2179
+ /**
2180
+ * Get the ISO week year
2181
+ */
2182
+ declare function getISOWeekYear(date: Date): number;
2183
+ /**
2184
+ * Get the quarter (1-4)
2185
+ */
2186
+ declare function getQuarter(date: Date): number;
2187
+ /**
2188
+ * Get start of a time unit
2189
+ */
2190
+ declare function startOf(date: Date, unit: TimeUnit): Date;
2191
+ /**
2192
+ * Get end of a time unit
2193
+ */
2194
+ declare function endOf(date: Date, unit: TimeUnit): Date;
2195
+ /**
2196
+ * Add a duration to a date
2197
+ * Handles month overflow by clamping to the last day of the month
2198
+ */
2199
+ declare function addDuration(date: Date, duration: Duration): Date;
2200
+ /**
2201
+ * Subtract a duration from a date
2202
+ */
2203
+ declare function subtractDuration(date: Date, duration: Duration): Date;
2204
+ /**
2205
+ * Add a specific number of units to a date
2206
+ */
2207
+ declare function addUnits(date: Date, amount: number, unit: TimeUnit): Date;
2208
+ /**
2209
+ * Calculate the difference between two dates in a specific unit
2210
+ */
2211
+ declare function diffInUnits(date1: Date, date2: Date, unit: TimeUnit): number;
2212
+ /**
2213
+ * Parse an ISO 8601 duration string
2214
+ */
2215
+ declare function parseISODuration(duration: string): Duration;
2216
+ /**
2217
+ * Convert a duration to ISO 8601 format
2218
+ */
2219
+ declare function durationToISO(duration: Duration): string;
2220
+ /**
2221
+ * Compare two dates at a specific granularity
2222
+ */
2223
+ declare function compareAtGranularity(date1: Date, date2: Date, unit: TimeUnit): number;
2224
+ /**
2225
+ * Check if two dates are the same at a specific granularity
2226
+ */
2227
+ declare function isSameAt(date1: Date, date2: Date, unit: TimeUnit): boolean;
2228
+ /**
2229
+ * Create a deep clone of a date
2230
+ */
2231
+ declare function cloneDate(date: Date): Date;
2232
+ /**
2233
+ * Check if a date is valid
2234
+ */
2235
+ declare function isValidDate(date: Date): boolean;
2236
+ /**
2237
+ * Ensure a value is within bounds
2238
+ */
2239
+ declare function clamp(value: number, min: number, max: number): number;
2240
+ /**
2241
+ * Get ordinal suffix for a number (1st, 2nd, 3rd, etc.)
2242
+ */
2243
+ declare function ordinalSuffix(n: number): string;
2244
+ /**
2245
+ * Pad a number with leading zeros
2246
+ */
2247
+ declare function padStart(value: number | string, length: number, char?: string): string;
2248
+
2249
+ /**
2250
+ * Locale configuration for Chronos
2251
+ * @module locales
2252
+ */
2253
+
2254
+ /**
2255
+ * English (US) locale configuration
2256
+ */
2257
+ declare const en: LocaleConfig;
2258
+ /**
2259
+ * French locale configuration
2260
+ */
2261
+ declare const fr: LocaleConfig;
2262
+ /**
2263
+ * Spanish locale configuration
2264
+ */
2265
+ declare const es: LocaleConfig;
2266
+ /**
2267
+ * Italian locale configuration
2268
+ */
2269
+ declare const it: LocaleConfig;
2270
+ /**
2271
+ * Arabic locale configuration (Modern Standard Arabic)
2272
+ */
2273
+ declare const ar: LocaleConfig;
2274
+ /**
2275
+ * Russian locale configuration
2276
+ */
2277
+ declare const ru: LocaleConfig;
2278
+ /**
2279
+ * German locale configuration
2280
+ */
2281
+ declare const de: LocaleConfig;
2282
+ /**
2283
+ * Japanese locale configuration
2284
+ */
2285
+ declare const ja: LocaleConfig;
2286
+ /**
2287
+ * Chinese (Simplified) locale configuration
2288
+ */
2289
+ declare const zh: LocaleConfig;
2290
+ /**
2291
+ * Portuguese (Brazil) locale configuration
2292
+ */
2293
+ declare const pt: LocaleConfig;
2294
+ /**
2295
+ * Default locale
2296
+ */
2297
+ declare const defaultLocale: LocaleConfig;
2298
+ /**
2299
+ * Get a locale by code
2300
+ */
2301
+ declare function getLocale(code: string): LocaleConfig;
2302
+ /**
2303
+ * Register a new locale
2304
+ */
2305
+ declare function registerLocale(config: LocaleConfig): void;
2306
+ /**
2307
+ * Get available locale codes
45
2308
  */
46
- export { Chronos, ChronosInterval, ChronosPeriod, ChronosPeriodCollection, ChronosTimezone, TIMEZONES, Timezones, type TimezoneId, } from './core';
47
- export { DayOfWeek, Month, PeriodBoundary, type TimeUnit, type TimeUnitPlural, type TimeUnitShort, type AnyTimeUnit, type Duration, type DateInput, type ChronosLike, type ChronosConfig, type DateTimeComponents, type DateTimeSetter, type ISODuration, type FormatTokens, type FormatPreset, type CompareOperator, type CompareGranularity, type PeriodOptions, type TimezoneInput, type TimezoneInfo, type TimezoneOffset, type DSTransition, type LocaleConfig, type HumanDiffOptions, type DiffResult, type ChronosSerializable, type ChronosJSON, type TimeRange, type BusinessHours, type CalendarWeek, type CalendarMonth, type DeepPartial, type NumericKeys, type TypeGuard, type Chainable, MILLISECONDS_PER_SECOND, MILLISECONDS_PER_MINUTE, MILLISECONDS_PER_HOUR, MILLISECONDS_PER_DAY, MILLISECONDS_PER_WEEK, MILLISECONDS_PER_MONTH, MILLISECONDS_PER_YEAR, SECONDS_PER_MINUTE, MINUTES_PER_HOUR, HOURS_PER_DAY, DAYS_PER_WEEK, MONTHS_PER_YEAR, DAYS_PER_YEAR, DAYS_PER_LEAP_YEAR, AVERAGE_DAYS_PER_MONTH, AVERAGE_DAYS_PER_YEAR, } from './types';
48
- export { isDate, isValidDateInput, isChronosLike, isDuration, isISODuration, isLeapYear, isValidDate, normalizeUnit, pluralizeUnit, getMillisecondsPerUnit, getDaysInMonth, getDaysInYear, getDayOfYear, getISOWeek, getISOWeekYear, getQuarter, startOf, endOf, addDuration, subtractDuration, addUnits, diffInUnits, parseISODuration, durationToISO, compareAtGranularity, isSameAt, cloneDate, clamp, ordinalSuffix, padStart, } from './utils';
49
- export { getLocale, registerLocale, getAvailableLocales, defaultLocale, en, es, fr, de, ja, zh, pt, it, ar, ru, } from './locales';
50
- export { Chronos as default } from './core';
2309
+ declare function getAvailableLocales(): string[];
2310
+
2311
+ export { AVERAGE_DAYS_PER_MONTH, AVERAGE_DAYS_PER_YEAR, type AnyTimeUnit, type BusinessHours, type CalendarMonth, type CalendarWeek, type Chainable, Chronos, type ChronosConfig, ChronosInterval, type ChronosJSON, type ChronosLike, ChronosPeriod, ChronosPeriodCollection, type ChronosSerializable, ChronosTimezone, type CompareGranularity, type CompareOperator, DAYS_PER_LEAP_YEAR, DAYS_PER_WEEK, DAYS_PER_YEAR, type DSTransition, type DateInput, type DateTimeComponents, type DateTimeSetter, DayOfWeek, type DeepPartial, type DiffResult, type Duration, type FormatPreset, type FormatTokens, HOURS_PER_DAY, type HumanDiffOptions, type ISODuration, type LocaleConfig, MILLISECONDS_PER_DAY, MILLISECONDS_PER_HOUR, MILLISECONDS_PER_MINUTE, MILLISECONDS_PER_MONTH, MILLISECONDS_PER_SECOND, MILLISECONDS_PER_WEEK, MILLISECONDS_PER_YEAR, MINUTES_PER_HOUR, MONTHS_PER_YEAR, Month, type NumericKeys, PeriodBoundary, type PeriodOptions, SECONDS_PER_MINUTE, TIMEZONES, type TimeRange, type TimeUnit, type TimeUnitPlural, type TimeUnitShort, type TimezoneId, type TimezoneInfo, type TimezoneInput, type TimezoneOffset, Timezones, type TypeGuard, addDuration, addUnits, ar, clamp, cloneDate, compareAtGranularity, de, Chronos as default, defaultLocale, diffInUnits, durationToISO, en, endOf, es, fr, getAvailableLocales, getDayOfYear, getDaysInMonth, getDaysInYear, getISOWeek, getISOWeekYear, getLocale, getMillisecondsPerUnit, getQuarter, isChronosLike, isDate, isDuration, isISODuration, isLeapYear, isSameAt, isValidDate, isValidDateInput, it, ja, normalizeUnit, ordinalSuffix, padStart, parseISODuration, pluralizeUnit, pt, registerLocale, ru, startOf, subtractDuration, zh };