chronos-ts 2.0.2 → 2.0.3

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,2291 @@
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
+ * Subtract time from the date
635
+ */
636
+ subtract(amount: number | Duration, unit?: AnyTimeUnit): Chronos;
637
+ /**
638
+ * Get the start of a time unit
639
+ *
640
+ * @example
641
+ * ```typescript
642
+ * chronos.startOf('day') // 00:00:00.000
643
+ * chronos.startOf('month') // First day of month
644
+ * chronos.startOf('year') // January 1st
645
+ * ```
646
+ */
647
+ startOf(unit: AnyTimeUnit): Chronos;
648
+ /**
649
+ * Get the end of a time unit
650
+ *
651
+ * @example
652
+ * ```typescript
653
+ * chronos.endOf('day') // 23:59:59.999
654
+ * chronos.endOf('month') // Last day of month
655
+ * chronos.endOf('year') // December 31st
656
+ * ```
657
+ */
658
+ endOf(unit: AnyTimeUnit): Chronos;
659
+ addMilliseconds(amount: number): Chronos;
660
+ addSeconds(amount: number): Chronos;
661
+ addMinutes(amount: number): Chronos;
662
+ addHours(amount: number): Chronos;
663
+ addDays(amount: number): Chronos;
664
+ addWeeks(amount: number): Chronos;
665
+ addMonths(amount: number): Chronos;
666
+ addQuarters(amount: number): Chronos;
667
+ addYears(amount: number): Chronos;
668
+ subtractMilliseconds(amount: number): Chronos;
669
+ subtractSeconds(amount: number): Chronos;
670
+ subtractMinutes(amount: number): Chronos;
671
+ subtractHours(amount: number): Chronos;
672
+ subtractDays(amount: number): Chronos;
673
+ subtractWeeks(amount: number): Chronos;
674
+ subtractMonths(amount: number): Chronos;
675
+ subtractQuarters(amount: number): Chronos;
676
+ subtractYears(amount: number): Chronos;
677
+ /**
678
+ * Check if this date is before another
679
+ */
680
+ isBefore(other: DateInput, unit?: AnyTimeUnit): boolean;
681
+ /**
682
+ * Check if this date is after another
683
+ */
684
+ isAfter(other: DateInput, unit?: AnyTimeUnit): boolean;
685
+ /**
686
+ * Check if this date is the same as another
687
+ */
688
+ isSame(other: DateInput, unit?: AnyTimeUnit): boolean;
689
+ /**
690
+ * Check if this date is same or before another
691
+ */
692
+ isSameOrBefore(other: DateInput, unit?: AnyTimeUnit): boolean;
693
+ /**
694
+ * Check if this date is same or after another
695
+ */
696
+ isSameOrAfter(other: DateInput, unit?: AnyTimeUnit): boolean;
697
+ /**
698
+ * Check if this date is between two others
699
+ */
700
+ isBetween(start: DateInput, end: DateInput, unit?: AnyTimeUnit, inclusivity?: '()' | '[]' | '[)' | '(]'): boolean;
701
+ /** Check if this date is today */
702
+ isToday(): boolean;
703
+ /** Check if this date is tomorrow */
704
+ isTomorrow(): boolean;
705
+ /** Check if this date is yesterday */
706
+ isYesterday(): boolean;
707
+ /** Check if this date is in the past */
708
+ isPast(): boolean;
709
+ /** Check if this date is in the future */
710
+ isFuture(): boolean;
711
+ /** Check if this is a weekend (Saturday or Sunday) */
712
+ isWeekend(): boolean;
713
+ /** Check if this is a weekday (Monday-Friday) */
714
+ isWeekday(): boolean;
715
+ isSunday(): boolean;
716
+ isMonday(): boolean;
717
+ isTuesday(): boolean;
718
+ isWednesday(): boolean;
719
+ isThursday(): boolean;
720
+ isFriday(): boolean;
721
+ isSaturday(): boolean;
722
+ /**
723
+ * Get the difference between two dates in a specific unit
724
+ */
725
+ diff(other: DateInput, unit?: AnyTimeUnit, precise?: boolean): number;
726
+ /**
727
+ * Get a detailed diff breakdown
728
+ */
729
+ diffDetailed(other: DateInput): DiffResult;
730
+ /**
731
+ * Get a human-readable relative time string
732
+ *
733
+ * @example
734
+ * ```typescript
735
+ * date.fromNow() // "2 days ago"
736
+ * date.from(other) // "in 3 months"
737
+ * date.fromNow({ short: true }) // "2d ago"
738
+ * ```
739
+ */
740
+ fromNow(options?: HumanDiffOptions): string;
741
+ /**
742
+ * Get relative time from another date
743
+ */
744
+ from(other: DateInput, options?: HumanDiffOptions): string;
745
+ /**
746
+ * Get relative time to another date
747
+ */
748
+ to(other: DateInput, options?: HumanDiffOptions): string;
749
+ /**
750
+ * Get relative time to now
751
+ */
752
+ toNow(options?: HumanDiffOptions): string;
753
+ /**
754
+ * Format the date using a format string
755
+ *
756
+ * Supported tokens:
757
+ * - YYYY: 4-digit year
758
+ * - YY: 2-digit year
759
+ * - MMMM: Full month name
760
+ * - MMM: Short month name
761
+ * - MM: 2-digit month
762
+ * - M: 1-2 digit month
763
+ * - DD: 2-digit day
764
+ * - D: 1-2 digit day
765
+ * - dddd: Full weekday name
766
+ * - ddd: Short weekday name
767
+ * - dd: Min weekday name
768
+ * - d: Day of week number
769
+ * - HH: 2-digit hour (24h)
770
+ * - H: 1-2 digit hour (24h)
771
+ * - hh: 2-digit hour (12h)
772
+ * - h: 1-2 digit hour (12h)
773
+ * - mm: 2-digit minute
774
+ * - m: 1-2 digit minute
775
+ * - ss: 2-digit second
776
+ * - s: 1-2 digit second
777
+ * - SSS: 3-digit millisecond
778
+ * - A: AM/PM
779
+ * - a: am/pm
780
+ * - Z: Timezone offset (+05:00)
781
+ * - ZZ: Timezone offset (+0500)
782
+ */
783
+ format(formatStr?: string): string;
784
+ /** Format as ISO 8601 */
785
+ toISOString(): string;
786
+ /** Format as ISO date (YYYY-MM-DD) */
787
+ toDateString(): string;
788
+ /** Format as time (HH:mm:ss) */
789
+ toTimeString(): string;
790
+ /** Format as datetime (YYYY-MM-DD HH:mm:ss) */
791
+ toDateTimeString(): string;
792
+ /** Format as RFC 2822 */
793
+ toRFC2822(): string;
794
+ /** Format as RFC 3339 */
795
+ toRFC3339(): string;
796
+ /** Format as ATOM */
797
+ toAtomString(): string;
798
+ /** Format as Cookie */
799
+ toCookieString(): string;
800
+ /** Format as RSS */
801
+ toRSSString(): string;
802
+ /** Format as W3C */
803
+ toW3CString(): string;
804
+ /**
805
+ * Convert to a specific timezone
806
+ */
807
+ toTimezone(timezone: string): Chronos;
808
+ /** Convert to native Date object */
809
+ toDate(): Date;
810
+ /** Convert to array [year, month, day, hour, minute, second, millisecond] */
811
+ toArray(): number[];
812
+ /** Convert to object */
813
+ toObject(): DateTimeComponents;
814
+ /** Convert to JSON-serializable object */
815
+ toJSON(): ChronosJSON;
816
+ /** Get primitive value (timestamp) */
817
+ valueOf(): number;
818
+ /** Convert to string */
819
+ toString(): string;
820
+ /**
821
+ * Create a clone of this instance
822
+ */
823
+ clone(): Chronos;
824
+ /**
825
+ * Set the locale for this instance
826
+ */
827
+ locale(code: string): Chronos;
828
+ /**
829
+ * Get the current locale code
830
+ */
831
+ getLocale(): string;
832
+ /**
833
+ * Get the next occurrence of a specific day
834
+ */
835
+ next(day: DayOfWeek): Chronos;
836
+ /**
837
+ * Get the previous occurrence of a specific day
838
+ */
839
+ previous(day: DayOfWeek): Chronos;
840
+ /**
841
+ * Get the closest date (either this or other)
842
+ */
843
+ closest(date1: DateInput, date2: DateInput): Chronos;
844
+ /**
845
+ * Get the farthest date (either this or other)
846
+ */
847
+ farthest(date1: DateInput, date2: DateInput): Chronos;
848
+ /**
849
+ * Set global configuration
850
+ */
851
+ static configure(config: Partial<ChronosConfig>): void;
852
+ /**
853
+ * Get current global configuration
854
+ */
855
+ static getConfig(): ChronosConfig;
856
+ /**
857
+ * Set test time (for testing purposes)
858
+ */
859
+ static setTestNow(date?: DateInput): void;
860
+ /**
861
+ * Check if test mode is active
862
+ */
863
+ static hasTestNow(): boolean;
864
+ /**
865
+ * Get the test time
866
+ */
867
+ static getTestNow(): Chronos | null;
868
+ /**
869
+ * Check if the date is valid
870
+ */
871
+ isValid(): boolean;
872
+ /**
873
+ * Check if this date is the same day as another (regardless of time)
874
+ */
875
+ isSameDay(other: DateInput): boolean;
876
+ /**
877
+ * Check if this date is in the same month as another
878
+ */
879
+ isSameMonth(other: DateInput): boolean;
880
+ /**
881
+ * Check if this date is in the same year as another
882
+ */
883
+ isSameYear(other: DateInput): boolean;
884
+ /**
885
+ * Get calendar output for the current month
886
+ */
887
+ calendar(referenceDate?: DateInput): string;
888
+ }
889
+
890
+ /**
891
+ * ChronosInterval - Duration/Interval handling
892
+ * @module ChronosInterval
893
+ */
894
+
895
+ /**
896
+ * ChronosInterval - Represents a duration/interval of time
897
+ *
898
+ * @example
899
+ * ```typescript
900
+ * // Create intervals
901
+ * const interval = ChronosInterval.create({ days: 5, hours: 3 });
902
+ * const hours = ChronosInterval.hours(24);
903
+ * const fromISO = ChronosInterval.fromISO('P1Y2M3D');
904
+ *
905
+ * // Arithmetic
906
+ * const doubled = interval.multiply(2);
907
+ * const combined = interval.add(hours);
908
+ *
909
+ * // Formatting
910
+ * console.log(interval.forHumans()); // "5 days 3 hours"
911
+ * console.log(interval.toISO()); // "P5DT3H"
912
+ * ```
913
+ */
914
+ declare class ChronosInterval {
915
+ private _years;
916
+ private _months;
917
+ private _weeks;
918
+ private _days;
919
+ private _hours;
920
+ private _minutes;
921
+ private _seconds;
922
+ private _milliseconds;
923
+ private _locale;
924
+ private _inverted;
925
+ private constructor();
926
+ /**
927
+ * Create an interval from a duration object
928
+ */
929
+ static create(duration: Duration): ChronosInterval;
930
+ /**
931
+ * Create an interval from years
932
+ */
933
+ static years(years: number): ChronosInterval;
934
+ /**
935
+ * Create an interval from months
936
+ */
937
+ static months(months: number): ChronosInterval;
938
+ /**
939
+ * Create an interval from weeks
940
+ */
941
+ static weeks(weeks: number): ChronosInterval;
942
+ /**
943
+ * Create an interval from days
944
+ */
945
+ static days(days: number): ChronosInterval;
946
+ /**
947
+ * Create an interval from hours
948
+ */
949
+ static hours(hours: number): ChronosInterval;
950
+ /**
951
+ * Create an interval from minutes
952
+ */
953
+ static minutes(minutes: number): ChronosInterval;
954
+ /**
955
+ * Create an interval from seconds
956
+ */
957
+ static seconds(seconds: number): ChronosInterval;
958
+ /**
959
+ * Create an interval from milliseconds
960
+ */
961
+ static milliseconds(milliseconds: number): ChronosInterval;
962
+ /**
963
+ * Create a single unit interval
964
+ */
965
+ static unit(amount: number, unit: AnyTimeUnit): ChronosInterval;
966
+ /**
967
+ * Create from ISO 8601 duration string (P1Y2M3DT4H5M6S)
968
+ */
969
+ static fromISO(iso: string): ChronosInterval;
970
+ /**
971
+ * Create from a human-readable string
972
+ *
973
+ * @example
974
+ * ```typescript
975
+ * ChronosInterval.fromString('2 days 3 hours')
976
+ * ChronosInterval.fromString('1 year, 6 months')
977
+ * ```
978
+ */
979
+ static fromString(input: string): ChronosInterval;
980
+ /**
981
+ * Create a zero-length interval
982
+ */
983
+ static zero(): ChronosInterval;
984
+ /**
985
+ * Create an interval from the difference between two dates
986
+ *
987
+ * @example
988
+ * ```typescript
989
+ * const start = new Date('2024-01-01');
990
+ * const end = new Date('2024-03-15');
991
+ * const interval = ChronosInterval.between(start, end);
992
+ * ```
993
+ */
994
+ static between(start: Date | {
995
+ toDate(): Date;
996
+ }, end: Date | {
997
+ toDate(): Date;
998
+ }): ChronosInterval;
999
+ get years(): number;
1000
+ get months(): number;
1001
+ get weeks(): number;
1002
+ get days(): number;
1003
+ get hours(): number;
1004
+ get minutes(): number;
1005
+ get seconds(): number;
1006
+ get milliseconds(): number;
1007
+ get inverted(): boolean;
1008
+ /**
1009
+ * Get total duration in a specific unit
1010
+ */
1011
+ total(unit: AnyTimeUnit): number;
1012
+ /**
1013
+ * Get total duration in milliseconds
1014
+ */
1015
+ totalMilliseconds(): number;
1016
+ /**
1017
+ * Get total duration in seconds
1018
+ */
1019
+ totalSeconds(): number;
1020
+ /**
1021
+ * Get total duration in minutes
1022
+ */
1023
+ totalMinutes(): number;
1024
+ /**
1025
+ * Get total duration in hours
1026
+ */
1027
+ totalHours(): number;
1028
+ /**
1029
+ * Get total duration in days
1030
+ */
1031
+ totalDays(): number;
1032
+ /**
1033
+ * Get total duration in weeks
1034
+ */
1035
+ totalWeeks(): number;
1036
+ /**
1037
+ * Get total duration in months (approximate)
1038
+ */
1039
+ totalMonths(): number;
1040
+ /**
1041
+ * Get total duration in years (approximate)
1042
+ */
1043
+ totalYears(): number;
1044
+ /**
1045
+ * Add another interval to this one
1046
+ */
1047
+ add(other: ChronosInterval | Duration): ChronosInterval;
1048
+ /**
1049
+ * Subtract another interval from this one
1050
+ */
1051
+ subtract(other: ChronosInterval | Duration): ChronosInterval;
1052
+ /**
1053
+ * Multiply the interval by a factor
1054
+ */
1055
+ multiply(factor: number): ChronosInterval;
1056
+ /**
1057
+ * Divide the interval by a factor
1058
+ */
1059
+ divide(factor: number): ChronosInterval;
1060
+ /**
1061
+ * Negate the interval
1062
+ */
1063
+ negate(): ChronosInterval;
1064
+ /**
1065
+ * Get absolute value of interval
1066
+ */
1067
+ abs(): ChronosInterval;
1068
+ /**
1069
+ * Check if equal to another interval
1070
+ */
1071
+ equals(other: ChronosInterval): boolean;
1072
+ /**
1073
+ * Check if greater than another interval
1074
+ */
1075
+ greaterThan(other: ChronosInterval): boolean;
1076
+ /**
1077
+ * Check if less than another interval
1078
+ */
1079
+ lessThan(other: ChronosInterval): boolean;
1080
+ /**
1081
+ * Check if greater than or equal to another interval
1082
+ */
1083
+ greaterThanOrEqual(other: ChronosInterval): boolean;
1084
+ /**
1085
+ * Check if less than or equal to another interval
1086
+ */
1087
+ lessThanOrEqual(other: ChronosInterval): boolean;
1088
+ /**
1089
+ * Check if the interval is zero
1090
+ */
1091
+ isZero(): boolean;
1092
+ /**
1093
+ * Check if the interval is positive
1094
+ */
1095
+ isPositive(): boolean;
1096
+ /**
1097
+ * Check if the interval is negative
1098
+ */
1099
+ isNegative(): boolean;
1100
+ /**
1101
+ * Cascade units to proper values (normalize overflow)
1102
+ *
1103
+ * @example
1104
+ * 90 seconds becomes 1 minute 30 seconds
1105
+ */
1106
+ cascade(): ChronosInterval;
1107
+ /**
1108
+ * Cascade without including weeks
1109
+ */
1110
+ cascadeWithoutWeeks(): ChronosInterval;
1111
+ /**
1112
+ * Format as ISO 8601 duration
1113
+ */
1114
+ toISO(): string;
1115
+ /**
1116
+ * Format for human reading
1117
+ *
1118
+ * @example
1119
+ * ```typescript
1120
+ * interval.forHumans() // "2 days 3 hours"
1121
+ * interval.forHumans({ short: true }) // "2d 3h"
1122
+ * interval.forHumans({ parts: 2 }) // "2 days 3 hours" (max 2 parts)
1123
+ * ```
1124
+ */
1125
+ forHumans(options?: {
1126
+ short?: boolean;
1127
+ parts?: number;
1128
+ join?: string;
1129
+ conjunction?: string;
1130
+ }): string;
1131
+ /**
1132
+ * Format using a format string
1133
+ *
1134
+ * Tokens:
1135
+ * - %y: years
1136
+ * - %m: months
1137
+ * - %w: weeks
1138
+ * - %d: days
1139
+ * - %h: hours
1140
+ * - %i: minutes
1141
+ * - %s: seconds
1142
+ * - %f: milliseconds
1143
+ * - %R: +/- sign
1144
+ * - %r: +/- or empty
1145
+ */
1146
+ format(formatStr: string): string;
1147
+ /**
1148
+ * Convert to Duration object
1149
+ */
1150
+ toDuration(): Duration;
1151
+ /**
1152
+ * Convert to array
1153
+ */
1154
+ toArray(): number[];
1155
+ /**
1156
+ * Clone this interval
1157
+ */
1158
+ clone(): ChronosInterval;
1159
+ /**
1160
+ * Set locale for this interval
1161
+ */
1162
+ locale(code: string): ChronosInterval;
1163
+ /**
1164
+ * Get primitive value (total milliseconds)
1165
+ */
1166
+ valueOf(): number;
1167
+ /**
1168
+ * Convert to string
1169
+ */
1170
+ toString(): string;
1171
+ /**
1172
+ * Convert to JSON
1173
+ */
1174
+ toJSON(): Duration & {
1175
+ iso: string;
1176
+ };
1177
+ }
1178
+
1179
+ /**
1180
+ * ChronosPeriod - Date range iteration
1181
+ * @module ChronosPeriod
1182
+ */
1183
+
1184
+ /**
1185
+ * ChronosPeriod - Represents a date range with iteration capabilities
28
1186
  *
29
- * // Intervals
30
- * const duration = ChronosInterval.hours(5).addMinutes(30);
31
- * console.log(duration.forHumans()); // "5 hours 30 minutes"
1187
+ * Inspired by CarbonPeriod, this class provides powerful date range
1188
+ * iteration with support for various interval types, filters, and
1189
+ * recurrence patterns.
32
1190
  *
33
- * // Periods
34
- * const week = ChronosPeriod.currentWeek();
35
- * for (const day of week) {
36
- * console.log(day.format('dddd'));
1191
+ * @example
1192
+ * ```typescript
1193
+ * // Basic iteration
1194
+ * const period = ChronosPeriod.create('2024-01-01', '2024-01-31');
1195
+ * for (const date of period) {
1196
+ * console.log(date.format('YYYY-MM-DD'));
37
1197
  * }
38
1198
  *
39
- * // Timezones
40
- * const tz = ChronosTimezone.create('America/New_York');
41
- * console.log(tz.getOffsetString()); // "-05:00"
1199
+ * // With custom interval
1200
+ * const weekly = ChronosPeriod.create('2024-01-01', '2024-03-31')
1201
+ * .setInterval(ChronosInterval.weeks(1));
1202
+ *
1203
+ * // With filters
1204
+ * const weekdays = period.filter(date => date.dayOfWeek < 6);
1205
+ *
1206
+ * // Recurrence
1207
+ * const recur = ChronosPeriod.recur('2024-01-01')
1208
+ * .every(1, 'month')
1209
+ * .times(12);
1210
+ * ```
1211
+ */
1212
+ declare class ChronosPeriod implements Iterable<Chronos> {
1213
+ private _start;
1214
+ private _end;
1215
+ private _interval;
1216
+ private _recurrences;
1217
+ private _options;
1218
+ private _filters;
1219
+ private _current;
1220
+ private _locale;
1221
+ /**
1222
+ * Create a new ChronosPeriod
1223
+ */
1224
+ constructor(start: DateInput, end?: DateInput, interval?: Duration | ChronosInterval, options?: Partial<PeriodOptions>);
1225
+ /**
1226
+ * Create a period between two dates
1227
+ */
1228
+ static create(start: DateInput, end?: DateInput, interval?: Duration | ChronosInterval): ChronosPeriod;
1229
+ /**
1230
+ * Create a period from a start date with recurrences
1231
+ */
1232
+ static recur(start: DateInput, interval?: Duration | ChronosInterval): ChronosPeriod;
1233
+ /**
1234
+ * Create a period for a specific number of days
1235
+ */
1236
+ static days(start: DateInput, count: number): ChronosPeriod;
1237
+ /**
1238
+ * Create a period for a specific number of weeks
1239
+ */
1240
+ static weeks(start: DateInput, count: number): ChronosPeriod;
1241
+ /**
1242
+ * Create a period for a specific number of months
1243
+ */
1244
+ static months(start: DateInput, count: number): ChronosPeriod;
1245
+ /**
1246
+ * Create a period for a specific number of years
1247
+ */
1248
+ static years(start: DateInput, count: number): ChronosPeriod;
1249
+ /**
1250
+ * Create a period for the current month
1251
+ */
1252
+ static currentMonth(): ChronosPeriod;
1253
+ /**
1254
+ * Create a period for the current year
1255
+ */
1256
+ static currentYear(): ChronosPeriod;
1257
+ /**
1258
+ * Create a period for the current week
1259
+ */
1260
+ static currentWeek(): ChronosPeriod;
1261
+ /**
1262
+ * Create a period for the current quarter
1263
+ */
1264
+ static currentQuarter(): ChronosPeriod;
1265
+ /**
1266
+ * Alias for currentWeek()
1267
+ */
1268
+ static thisWeek(): ChronosPeriod;
1269
+ /**
1270
+ * Alias for currentMonth()
1271
+ */
1272
+ static thisMonth(): ChronosPeriod;
1273
+ /**
1274
+ * Alias for currentYear()
1275
+ */
1276
+ static thisYear(): ChronosPeriod;
1277
+ /**
1278
+ * Alias for currentQuarter()
1279
+ */
1280
+ static thisQuarter(): ChronosPeriod;
1281
+ /**
1282
+ * Create a period for the previous week
1283
+ */
1284
+ static lastWeek(): ChronosPeriod;
1285
+ /**
1286
+ * Create a period for the previous month
1287
+ */
1288
+ static lastMonth(): ChronosPeriod;
1289
+ /**
1290
+ * Create a period for the previous year
1291
+ */
1292
+ static lastYear(): ChronosPeriod;
1293
+ /**
1294
+ * Create a period for the previous quarter
1295
+ */
1296
+ static lastQuarter(): ChronosPeriod;
1297
+ /**
1298
+ * Create a period for the next week
1299
+ */
1300
+ static nextWeek(): ChronosPeriod;
1301
+ /**
1302
+ * Create a period for the next month
1303
+ */
1304
+ static nextMonth(): ChronosPeriod;
1305
+ /**
1306
+ * Create a period for the next year
1307
+ */
1308
+ static nextYear(): ChronosPeriod;
1309
+ /**
1310
+ * Create a period for the next quarter
1311
+ */
1312
+ static nextQuarter(): ChronosPeriod;
1313
+ /**
1314
+ * Create a period between two dates (alias for create)
1315
+ */
1316
+ static between(start: DateInput, end: DateInput, interval?: Duration | ChronosInterval): ChronosPeriod;
1317
+ /**
1318
+ * Create a period from an ISO 8601 repeating interval string
1319
+ * @example
1320
+ * ```typescript
1321
+ * ChronosPeriod.fromISO('R5/2024-01-01/P1D') // 5 recurrences, daily from 2024-01-01
1322
+ * ChronosPeriod.fromISO('2024-01-01/2024-01-31') // Date range
1323
+ * ChronosPeriod.fromISO('2024-01-01/P1M') // From date with duration
1324
+ * ```
1325
+ */
1326
+ static fromISO(iso: string): ChronosPeriod;
1327
+ /**
1328
+ * Get the start date
1329
+ */
1330
+ get start(): Chronos;
1331
+ /**
1332
+ * Get the end date
1333
+ */
1334
+ get end(): Chronos | null;
1335
+ /**
1336
+ * Get the interval
1337
+ */
1338
+ get interval(): ChronosInterval;
1339
+ /**
1340
+ * Get the number of recurrences
1341
+ */
1342
+ get recurrences(): number | null;
1343
+ /**
1344
+ * Check if the period includes the start boundary
1345
+ */
1346
+ get includesStart(): boolean;
1347
+ /**
1348
+ * Check if the period includes the end boundary
1349
+ */
1350
+ get includesEnd(): boolean;
1351
+ /**
1352
+ * Check if the period has an end date
1353
+ */
1354
+ get hasEnd(): boolean;
1355
+ /**
1356
+ * Check if the period is unbounded
1357
+ */
1358
+ get isUnbounded(): boolean;
1359
+ /**
1360
+ * Set the start date
1361
+ */
1362
+ setStart(start: DateInput): ChronosPeriod;
1363
+ /**
1364
+ * Set the end date
1365
+ */
1366
+ setEnd(end: DateInput): ChronosPeriod;
1367
+ /**
1368
+ * Set the interval
1369
+ */
1370
+ setInterval(interval: Duration | ChronosInterval): ChronosPeriod;
1371
+ /**
1372
+ * Set the number of recurrences
1373
+ */
1374
+ times(count: number): ChronosPeriod;
1375
+ /**
1376
+ * Set interval by unit
1377
+ */
1378
+ every(amount: number, unit: AnyTimeUnit): ChronosPeriod;
1379
+ /**
1380
+ * Exclude the start boundary
1381
+ */
1382
+ excludeStart(): ChronosPeriod;
1383
+ /**
1384
+ * Exclude the end boundary
1385
+ */
1386
+ excludeEnd(): ChronosPeriod;
1387
+ /**
1388
+ * Include the start boundary
1389
+ */
1390
+ includeStart(): ChronosPeriod;
1391
+ /**
1392
+ * Include the end boundary
1393
+ */
1394
+ includeEnd(): ChronosPeriod;
1395
+ /**
1396
+ * Add a filter function
1397
+ */
1398
+ filter(fn: (date: Chronos, key: number) => boolean): ChronosPeriod;
1399
+ /**
1400
+ * Filter to only include weekdays
1401
+ */
1402
+ weekdays(): ChronosPeriod;
1403
+ /**
1404
+ * Alias for weekdays()
1405
+ */
1406
+ filterWeekdays(): ChronosPeriod;
1407
+ /**
1408
+ * Filter to only include weekends
1409
+ */
1410
+ weekends(): ChronosPeriod;
1411
+ /**
1412
+ * Alias for weekends()
1413
+ */
1414
+ filterWeekends(): ChronosPeriod;
1415
+ /**
1416
+ * Filter to only include specific days of week
1417
+ */
1418
+ onlyDays(...days: number[]): ChronosPeriod;
1419
+ /**
1420
+ * Filter to exclude specific days of week
1421
+ */
1422
+ exceptDays(...days: number[]): ChronosPeriod;
1423
+ /**
1424
+ * Filter to only include specific months
1425
+ */
1426
+ onlyMonths(...months: number[]): ChronosPeriod;
1427
+ /**
1428
+ * Filter to exclude specific months
1429
+ */
1430
+ exceptMonths(...months: number[]): ChronosPeriod;
1431
+ /**
1432
+ * Clear all filters
1433
+ */
1434
+ clearFilters(): ChronosPeriod;
1435
+ /**
1436
+ * Get all dates in the period as an array
1437
+ */
1438
+ toArray(): Chronos[];
1439
+ /**
1440
+ * Iterate over the period
1441
+ */
1442
+ [Symbol.iterator](): Iterator<Chronos>;
1443
+ /**
1444
+ * Apply the interval to a date
1445
+ */
1446
+ private _applyInterval;
1447
+ /**
1448
+ * Check if iteration should continue
1449
+ */
1450
+ private _shouldContinue;
1451
+ /**
1452
+ * Check if a date passes all filters
1453
+ */
1454
+ private _passesFilters;
1455
+ /**
1456
+ * Get count of dates in the period
1457
+ */
1458
+ count(): number;
1459
+ /**
1460
+ * Get the first date in the period
1461
+ */
1462
+ first(): Chronos | null;
1463
+ /**
1464
+ * Get the last date in the period
1465
+ */
1466
+ last(): Chronos | null;
1467
+ /**
1468
+ * Get a date at a specific index
1469
+ */
1470
+ nth(index: number): Chronos | null;
1471
+ /**
1472
+ * Check if a date is within the period
1473
+ */
1474
+ contains(date: DateInput): boolean;
1475
+ /**
1476
+ * For each iteration
1477
+ */
1478
+ forEach(callback: (date: Chronos, index: number) => void): void;
1479
+ /**
1480
+ * Map dates to another type
1481
+ */
1482
+ map<T>(callback: (date: Chronos, index: number) => T): T[];
1483
+ /**
1484
+ * Reduce dates to a single value
1485
+ */
1486
+ reduce<T>(callback: (acc: T, date: Chronos, index: number) => T, initial: T): T;
1487
+ /**
1488
+ * Check if two periods overlap
1489
+ */
1490
+ overlaps(other: ChronosPeriod): boolean;
1491
+ /**
1492
+ * Get the intersection of two periods
1493
+ */
1494
+ intersect(other: ChronosPeriod): ChronosPeriod | null;
1495
+ /**
1496
+ * Get the union of two periods
1497
+ */
1498
+ union(other: ChronosPeriod): ChronosPeriod | null;
1499
+ /**
1500
+ * Get the difference between two periods
1501
+ * Returns the parts of this period that don't overlap with the other period
1502
+ */
1503
+ diff(other: ChronosPeriod): ChronosPeriod[];
1504
+ /**
1505
+ * Check if this period is adjacent to another
1506
+ */
1507
+ private _adjacentTo;
1508
+ /**
1509
+ * Get the duration of the period
1510
+ */
1511
+ duration(): ChronosInterval;
1512
+ /**
1513
+ * Get the number of days in the period
1514
+ */
1515
+ days(): number;
1516
+ /**
1517
+ * Get the number of weeks in the period
1518
+ */
1519
+ weeks(): number;
1520
+ /**
1521
+ * Get the number of months in the period
1522
+ */
1523
+ monthCount(): number;
1524
+ /**
1525
+ * Get the number of years in the period
1526
+ */
1527
+ yearCount(): number;
1528
+ /**
1529
+ * Split the period into chunks
1530
+ */
1531
+ split(count: number): ChronosPeriod[];
1532
+ /**
1533
+ * Split by a specific interval
1534
+ */
1535
+ splitBy(interval: Duration | ChronosInterval): ChronosPeriod[];
1536
+ /**
1537
+ * Split the period by a specified number of days
1538
+ */
1539
+ splitByDays(days: number): ChronosPeriod[];
1540
+ /**
1541
+ * Split the period by a specified number of weeks
1542
+ */
1543
+ splitByWeeks(weeks: number): ChronosPeriod[];
1544
+ /**
1545
+ * Split the period by a specified number of months
1546
+ */
1547
+ splitByMonths(months: number): ChronosPeriod[];
1548
+ /**
1549
+ * Split the period by a specified number of years
1550
+ */
1551
+ splitByYears(years: number): ChronosPeriod[];
1552
+ /**
1553
+ * Skip specific dates from the period iteration
1554
+ * @param dates - Dates to exclude from iteration
1555
+ */
1556
+ skip(dates: DateInput[]): ChronosPeriod;
1557
+ /**
1558
+ * Convert to ISO 8601 string
1559
+ */
1560
+ toISO(): string;
1561
+ /**
1562
+ * Convert to string
1563
+ */
1564
+ toString(): string;
1565
+ /**
1566
+ * Convert to human-readable string
1567
+ */
1568
+ forHumans(): string;
1569
+ /**
1570
+ * Convert to JSON
1571
+ */
1572
+ toJSON(): object;
1573
+ /**
1574
+ * Clone this period
1575
+ */
1576
+ clone(): ChronosPeriod;
1577
+ /**
1578
+ * Clone for modification (respects immutable option)
1579
+ */
1580
+ private _cloneForModification;
1581
+ /**
1582
+ * Set locale for this period
1583
+ */
1584
+ locale(code: string): ChronosPeriod;
1585
+ /**
1586
+ * Create a period for a specific month
1587
+ */
1588
+ static month(year: number, month: number): ChronosPeriod;
1589
+ /**
1590
+ * Create a period for a specific year
1591
+ */
1592
+ static year(year: number): ChronosPeriod;
1593
+ /**
1594
+ * Create a period for a specific quarter
1595
+ */
1596
+ static quarter(year: number, quarter: number): ChronosPeriod;
1597
+ /**
1598
+ * Create a period between two dates as weekdays only
1599
+ */
1600
+ static weekdaysBetween(start: DateInput, end: DateInput): ChronosPeriod;
1601
+ /**
1602
+ * Create a period with business days only (weekdays, can add holidays filter)
1603
+ */
1604
+ static businessDays(start: DateInput, end: DateInput, holidays?: DateInput[]): ChronosPeriod;
1605
+ }
1606
+
1607
+ /**
1608
+ * ChronosPeriodCollection - Manage collections of ChronosPeriod
1609
+ * Inspired by spatie/period PHP library
1610
+ * @see https://github.com/spatie/period
1611
+ */
1612
+
1613
+ /**
1614
+ * ChronosPeriodCollection - A collection of periods with powerful operations
1615
+ *
1616
+ * Inspired by spatie/period, this class provides a rich API for working with
1617
+ * collections of time periods including overlap detection, gap analysis,
1618
+ * and set operations.
1619
+ *
1620
+ * @example
1621
+ * ```typescript
1622
+ * const collection = new ChronosPeriodCollection([
1623
+ * ChronosPeriod.create('2024-01-01', '2024-01-15'),
1624
+ * ChronosPeriod.create('2024-01-10', '2024-01-25'),
1625
+ * ChronosPeriod.create('2024-02-01', '2024-02-15'),
1626
+ * ]);
1627
+ *
1628
+ * // Find overlapping periods
1629
+ * const overlapping = collection.overlapAll();
1630
+ *
1631
+ * // Get gaps between periods
1632
+ * const gaps = collection.gaps();
1633
+ *
1634
+ * // Get boundaries
1635
+ * const boundaries = collection.boundaries();
42
1636
  * ```
1637
+ */
1638
+ declare class ChronosPeriodCollection implements Iterable<ChronosPeriod> {
1639
+ private _periods;
1640
+ constructor(periods?: ChronosPeriod[]);
1641
+ /**
1642
+ * Create a new collection from periods
1643
+ */
1644
+ static create(...periods: ChronosPeriod[]): ChronosPeriodCollection;
1645
+ /**
1646
+ * Create an empty collection
1647
+ */
1648
+ static empty(): ChronosPeriodCollection;
1649
+ /**
1650
+ * Create a collection from an array of date pairs
1651
+ */
1652
+ static fromDatePairs(pairs: Array<[DateInput, DateInput]>): ChronosPeriodCollection;
1653
+ /** Add a period to the collection */
1654
+ add(period: ChronosPeriod): this;
1655
+ /** Add multiple periods */
1656
+ addAll(periods: ChronosPeriod[]): this;
1657
+ /** Get a shallow copy of periods */
1658
+ toArray(): ChronosPeriod[];
1659
+ /** Get the number of periods in the collection */
1660
+ get length(): number;
1661
+ /** Check if collection is empty */
1662
+ isEmpty(): boolean;
1663
+ /** Check if collection is not empty */
1664
+ isNotEmpty(): boolean;
1665
+ /** Get a period at a specific index */
1666
+ get(index: number): ChronosPeriod | undefined;
1667
+ /** Get the first period */
1668
+ first(): ChronosPeriod | undefined;
1669
+ /** Get the last period */
1670
+ last(): ChronosPeriod | undefined;
1671
+ /** Clear collection */
1672
+ clear(): this;
1673
+ /** Iterator implementation */
1674
+ [Symbol.iterator](): Iterator<ChronosPeriod>;
1675
+ /** ForEach iteration */
1676
+ forEach(callback: (period: ChronosPeriod, index: number) => void): void;
1677
+ /** Map periods to a new array */
1678
+ map<T>(callback: (period: ChronosPeriod, index: number) => T): T[];
1679
+ /** Filter periods */
1680
+ filter(predicate: (period: ChronosPeriod, index: number) => boolean): ChronosPeriodCollection;
1681
+ /** Reduce periods to a single value */
1682
+ reduce<T>(callback: (acc: T, period: ChronosPeriod, index: number) => T, initial: T): T;
1683
+ /** Find a period matching a predicate */
1684
+ find(predicate: (period: ChronosPeriod, index: number) => boolean): ChronosPeriod | undefined;
1685
+ /** Check if any period matches a predicate */
1686
+ some(predicate: (period: ChronosPeriod, index: number) => boolean): boolean;
1687
+ /** Check if all periods match a predicate */
1688
+ every(predicate: (period: ChronosPeriod, index: number) => boolean): boolean;
1689
+ /**
1690
+ * Get the overall boundaries of the collection
1691
+ * Returns a period from the earliest start to the latest end
1692
+ */
1693
+ boundaries(): ChronosPeriod | null;
1694
+ /**
1695
+ * Get the earliest start date across all periods
1696
+ */
1697
+ start(): Chronos | null;
1698
+ /**
1699
+ * Get the latest end date across all periods
1700
+ */
1701
+ end(): Chronos | null;
1702
+ /** Normalize and merge overlapping/adjacent periods */
1703
+ normalize(): ChronosPeriod[];
1704
+ /** Check if any period overlaps with the provided period */
1705
+ overlaps(period: ChronosPeriod): boolean;
1706
+ /**
1707
+ * Check if any period in the collection overlaps with any other period
1708
+ * in the collection (internal overlaps)
1709
+ */
1710
+ overlapAny(): boolean;
1711
+ /**
1712
+ * Get all overlapping period segments across the collection
1713
+ * Returns periods where two or more periods in the collection overlap
1714
+ */
1715
+ overlapAll(): ChronosPeriodCollection;
1716
+ /** Return intersections between collection and a given period */
1717
+ intersect(period: ChronosPeriod): ChronosPeriodCollection;
1718
+ /**
1719
+ * Get intersection of all periods in the collection
1720
+ * Returns the period where ALL periods overlap (if any)
1721
+ */
1722
+ intersectAll(): ChronosPeriod | null;
1723
+ /** Return the union (merged) of all periods in the collection */
1724
+ union(): ChronosPeriodCollection;
1725
+ /**
1726
+ * Alias for normalize() - returns merged periods
1727
+ * @deprecated Use union() instead
1728
+ */
1729
+ unionAll(): ChronosPeriod[];
1730
+ /** Merge collection into a single union period if contiguous/overlapping */
1731
+ mergeToSingle(): ChronosPeriod | null;
1732
+ /** Return gaps between merged periods */
1733
+ gaps(): ChronosPeriodCollection;
1734
+ /**
1735
+ * Check if there are any gaps between periods
1736
+ */
1737
+ hasGaps(): boolean;
1738
+ /**
1739
+ * Subtract a period from all periods in the collection
1740
+ * Returns periods with the subtracted portion removed
1741
+ */
1742
+ subtract(period: ChronosPeriod): ChronosPeriodCollection;
1743
+ /**
1744
+ * Subtract multiple periods from the collection
1745
+ */
1746
+ subtractAll(periods: ChronosPeriod[]): ChronosPeriodCollection;
1747
+ /**
1748
+ * Check if any period touches (is adjacent to) the given period
1749
+ * Two periods touch if one ends exactly where the other begins
1750
+ */
1751
+ touchesWith(period: ChronosPeriod): boolean;
1752
+ /**
1753
+ * Check if two periods touch (are adjacent)
1754
+ */
1755
+ private _periodsTouch;
1756
+ /**
1757
+ * Get all periods that touch the given period
1758
+ */
1759
+ touchingPeriods(period: ChronosPeriod): ChronosPeriodCollection;
1760
+ /**
1761
+ * Check if a date is contained in any period of the collection
1762
+ */
1763
+ contains(date: DateInput): boolean;
1764
+ /**
1765
+ * Check if a period is fully contained in any period of the collection
1766
+ */
1767
+ containsPeriod(period: ChronosPeriod): boolean;
1768
+ /**
1769
+ * Check if two collections are equal (same periods)
1770
+ */
1771
+ equals(other: ChronosPeriodCollection): boolean;
1772
+ /**
1773
+ * Get periods sorted by start date
1774
+ */
1775
+ private _sortedByStart;
1776
+ /**
1777
+ * Sort periods by start date (ascending)
1778
+ */
1779
+ sortByStart(): ChronosPeriodCollection;
1780
+ /**
1781
+ * Sort periods by end date (ascending)
1782
+ */
1783
+ sortByEnd(): ChronosPeriodCollection;
1784
+ /**
1785
+ * Sort periods by duration (ascending)
1786
+ */
1787
+ sortByDuration(): ChronosPeriodCollection;
1788
+ /**
1789
+ * Reverse the order of periods
1790
+ */
1791
+ reverse(): ChronosPeriodCollection;
1792
+ /**
1793
+ * Convert to JSON
1794
+ */
1795
+ toJSON(): object[];
1796
+ /**
1797
+ * Convert to string
1798
+ */
1799
+ toString(): string;
1800
+ /**
1801
+ * Get total duration across all periods (in days)
1802
+ * Note: Overlapping portions may be counted multiple times
1803
+ */
1804
+ totalDays(): number;
1805
+ /**
1806
+ * Get total unique duration (merged periods, no double-counting)
1807
+ */
1808
+ uniqueDays(): number;
1809
+ }
1810
+
1811
+ /**
1812
+ * ChronosTimezone - Timezone handling and conversions
1813
+ * @module ChronosTimezone
1814
+ */
1815
+
1816
+ /**
1817
+ * Common timezone identifiers
1818
+ */
1819
+ declare const TIMEZONES: {
1820
+ readonly UTC: "UTC";
1821
+ readonly GMT: "GMT";
1822
+ readonly 'America/New_York': "America/New_York";
1823
+ readonly 'America/Chicago': "America/Chicago";
1824
+ readonly 'America/Denver': "America/Denver";
1825
+ readonly 'America/Los_Angeles': "America/Los_Angeles";
1826
+ readonly 'America/Phoenix': "America/Phoenix";
1827
+ readonly 'America/Anchorage': "America/Anchorage";
1828
+ readonly 'America/Toronto': "America/Toronto";
1829
+ readonly 'America/Vancouver': "America/Vancouver";
1830
+ readonly 'America/Mexico_City': "America/Mexico_City";
1831
+ readonly 'America/Sao_Paulo': "America/Sao_Paulo";
1832
+ readonly 'America/Buenos_Aires': "America/Buenos_Aires";
1833
+ readonly 'America/Lima': "America/Lima";
1834
+ readonly 'America/Bogota': "America/Bogota";
1835
+ readonly 'Europe/London': "Europe/London";
1836
+ readonly 'Europe/Paris': "Europe/Paris";
1837
+ readonly 'Europe/Berlin': "Europe/Berlin";
1838
+ readonly 'Europe/Madrid': "Europe/Madrid";
1839
+ readonly 'Europe/Rome': "Europe/Rome";
1840
+ readonly 'Europe/Amsterdam': "Europe/Amsterdam";
1841
+ readonly 'Europe/Brussels': "Europe/Brussels";
1842
+ readonly 'Europe/Vienna': "Europe/Vienna";
1843
+ readonly 'Europe/Warsaw': "Europe/Warsaw";
1844
+ readonly 'Europe/Prague': "Europe/Prague";
1845
+ readonly 'Europe/Moscow': "Europe/Moscow";
1846
+ readonly 'Europe/Istanbul': "Europe/Istanbul";
1847
+ readonly 'Europe/Athens': "Europe/Athens";
1848
+ readonly 'Europe/Helsinki': "Europe/Helsinki";
1849
+ readonly 'Europe/Stockholm': "Europe/Stockholm";
1850
+ readonly 'Europe/Oslo': "Europe/Oslo";
1851
+ readonly 'Europe/Copenhagen': "Europe/Copenhagen";
1852
+ readonly 'Europe/Dublin': "Europe/Dublin";
1853
+ readonly 'Europe/Zurich': "Europe/Zurich";
1854
+ readonly 'Asia/Tokyo': "Asia/Tokyo";
1855
+ readonly 'Asia/Shanghai': "Asia/Shanghai";
1856
+ readonly 'Asia/Hong_Kong': "Asia/Hong_Kong";
1857
+ readonly 'Asia/Singapore': "Asia/Singapore";
1858
+ readonly 'Asia/Seoul': "Asia/Seoul";
1859
+ readonly 'Asia/Taipei': "Asia/Taipei";
1860
+ readonly 'Asia/Bangkok': "Asia/Bangkok";
1861
+ readonly 'Asia/Jakarta': "Asia/Jakarta";
1862
+ readonly 'Asia/Manila': "Asia/Manila";
1863
+ readonly 'Asia/Kuala_Lumpur': "Asia/Kuala_Lumpur";
1864
+ readonly 'Asia/Ho_Chi_Minh': "Asia/Ho_Chi_Minh";
1865
+ readonly 'Asia/Dubai': "Asia/Dubai";
1866
+ readonly 'Asia/Kolkata': "Asia/Kolkata";
1867
+ readonly 'Asia/Mumbai': "Asia/Mumbai";
1868
+ readonly 'Asia/Karachi': "Asia/Karachi";
1869
+ readonly 'Asia/Dhaka': "Asia/Dhaka";
1870
+ readonly 'Asia/Tehran': "Asia/Tehran";
1871
+ readonly 'Asia/Riyadh': "Asia/Riyadh";
1872
+ readonly 'Asia/Jerusalem': "Asia/Jerusalem";
1873
+ readonly 'Australia/Sydney': "Australia/Sydney";
1874
+ readonly 'Australia/Melbourne': "Australia/Melbourne";
1875
+ readonly 'Australia/Brisbane': "Australia/Brisbane";
1876
+ readonly 'Australia/Perth': "Australia/Perth";
1877
+ readonly 'Australia/Adelaide': "Australia/Adelaide";
1878
+ readonly 'Pacific/Auckland': "Pacific/Auckland";
1879
+ readonly 'Pacific/Fiji': "Pacific/Fiji";
1880
+ readonly 'Pacific/Honolulu': "Pacific/Honolulu";
1881
+ readonly 'Africa/Cairo': "Africa/Cairo";
1882
+ readonly 'Africa/Johannesburg': "Africa/Johannesburg";
1883
+ readonly 'Africa/Lagos': "Africa/Lagos";
1884
+ readonly 'Africa/Nairobi': "Africa/Nairobi";
1885
+ readonly 'Africa/Casablanca': "Africa/Casablanca";
1886
+ };
1887
+ type TimezoneId = keyof typeof TIMEZONES | string;
1888
+ /**
1889
+ * ChronosTimezone - Handles timezone operations and conversions
1890
+ *
1891
+ * This class provides comprehensive timezone handling including:
1892
+ * - Timezone information retrieval
1893
+ * - Offset calculations
1894
+ * - DST detection
1895
+ * - Timezone conversions
1896
+ *
1897
+ * @example
1898
+ * ```typescript
1899
+ * // Get timezone info
1900
+ * const tz = ChronosTimezone.create('America/New_York');
1901
+ * console.log(tz.offset); // -5 or -4 depending on DST
1902
+ *
1903
+ * // Check DST
1904
+ * console.log(tz.isDST(new Date())); // true/false
43
1905
  *
44
- * @packageDocumentation
1906
+ * // Convert between timezones
1907
+ * const utcDate = new Date();
1908
+ * const localDate = ChronosTimezone.convert(utcDate, 'UTC', 'America/New_York');
1909
+ * ```
1910
+ */
1911
+ declare class ChronosTimezone {
1912
+ private _identifier;
1913
+ private _originalOffset;
1914
+ private _extraMinutes;
1915
+ private _cachedOffset;
1916
+ private _cachedDate;
1917
+ /**
1918
+ * Create a new ChronosTimezone
1919
+ */
1920
+ constructor(identifier?: TimezoneId);
1921
+ /**
1922
+ * Normalize timezone identifier
1923
+ */
1924
+ private _normalizeIdentifier;
1925
+ /**
1926
+ * Parse offset string to hours
1927
+ */
1928
+ private _parseOffsetString;
1929
+ /**
1930
+ * Create a timezone instance
1931
+ */
1932
+ static create(identifier?: TimezoneId): ChronosTimezone;
1933
+ /**
1934
+ * Create UTC timezone
1935
+ */
1936
+ static utc(): ChronosTimezone;
1937
+ /**
1938
+ * Create timezone from local system timezone
1939
+ */
1940
+ static local(): ChronosTimezone;
1941
+ /**
1942
+ * Create timezone from offset in hours
1943
+ */
1944
+ static fromOffset(offsetHours: number): ChronosTimezone;
1945
+ /**
1946
+ * Get the local system timezone identifier
1947
+ */
1948
+ static localIdentifier(): string;
1949
+ /**
1950
+ * Get timezone identifier
1951
+ * Returns the original offset string if created from an offset, otherwise returns the IANA identifier
1952
+ */
1953
+ get identifier(): string;
1954
+ /**
1955
+ * Get the internal IANA timezone identifier (used for Intl operations)
1956
+ */
1957
+ get ianaIdentifier(): string;
1958
+ /**
1959
+ * Get timezone name (alias for identifier)
1960
+ */
1961
+ get name(): string;
1962
+ /**
1963
+ * Get timezone abbreviation for a given date
1964
+ */
1965
+ getAbbreviation(date?: Date): string;
1966
+ /**
1967
+ * Get full timezone name for a given date
1968
+ */
1969
+ getFullName(date?: Date): string;
1970
+ /**
1971
+ * Get UTC offset in minutes for a given date
1972
+ */
1973
+ getOffsetMinutes(date?: Date): number;
1974
+ /**
1975
+ * Parse Intl formatter parts to components
1976
+ */
1977
+ private _parseIntlParts;
1978
+ /**
1979
+ * Get UTC offset in hours for a given date
1980
+ */
1981
+ getOffsetHours(date?: Date): number;
1982
+ /**
1983
+ * Get UTC offset as string (e.g., "+05:30", "-08:00")
1984
+ */
1985
+ getOffsetString(date?: Date): string;
1986
+ /**
1987
+ * Get complete offset information
1988
+ */
1989
+ getOffset(date?: Date): TimezoneOffset;
1990
+ /**
1991
+ * Check if DST is in effect for a given date
1992
+ */
1993
+ isDST(date?: Date): boolean;
1994
+ /**
1995
+ * Check if timezone observes DST
1996
+ */
1997
+ observesDST(): boolean;
1998
+ /**
1999
+ * Get the next DST transition
2000
+ */
2001
+ getNextDSTTransition(from?: Date): DSTransition | null;
2002
+ /**
2003
+ * Binary search to find exact DST transition time
2004
+ */
2005
+ private _findExactTransition;
2006
+ /**
2007
+ * Convert a date to this timezone (returns formatted string)
2008
+ */
2009
+ format(date: Date, formatOptions?: Intl.DateTimeFormatOptions): string;
2010
+ /**
2011
+ * Get date components in this timezone
2012
+ */
2013
+ getComponents(date: Date): {
2014
+ year: number;
2015
+ month: number;
2016
+ day: number;
2017
+ hour: number;
2018
+ minute: number;
2019
+ second: number;
2020
+ dayOfWeek: number;
2021
+ };
2022
+ /**
2023
+ * Convert a date from one timezone to another
2024
+ */
2025
+ static convert(date: Date, from: TimezoneId, to: TimezoneId): Date;
2026
+ /**
2027
+ * Convert a UTC date to this timezone
2028
+ */
2029
+ fromUTC(date: Date): Date;
2030
+ /**
2031
+ * Convert a date in this timezone to UTC
2032
+ */
2033
+ toUTC(date: Date): Date;
2034
+ /**
2035
+ * Get comprehensive timezone information
2036
+ */
2037
+ getInfo(date?: Date): TimezoneInfo;
2038
+ /**
2039
+ * Check if two timezones are equivalent at a given moment
2040
+ */
2041
+ equals(other: ChronosTimezone | string, date?: Date): boolean;
2042
+ /**
2043
+ * Check if this is the same timezone identifier
2044
+ */
2045
+ isSame(other: ChronosTimezone | string): boolean;
2046
+ /**
2047
+ * Get all available timezone identifiers
2048
+ * Note: This returns common timezones. Use Intl.supportedValuesOf('timeZone') for all.
2049
+ */
2050
+ static getAvailableTimezones(): string[];
2051
+ /**
2052
+ * Check if a timezone identifier is valid
2053
+ */
2054
+ static isValid(identifier: string): boolean;
2055
+ /**
2056
+ * Get timezones grouped by region
2057
+ */
2058
+ static getTimezonesByRegion(): Record<string, string[]>;
2059
+ /**
2060
+ * Find timezones that match a given offset
2061
+ */
2062
+ static findByOffset(offsetHours: number, date?: Date): ChronosTimezone[];
2063
+ /**
2064
+ * Get current time in a specific timezone
2065
+ */
2066
+ static now(identifier: TimezoneId): Date;
2067
+ /**
2068
+ * Convert to string
2069
+ */
2070
+ toString(): string;
2071
+ /**
2072
+ * Convert to JSON
2073
+ */
2074
+ toJSON(): object;
2075
+ /**
2076
+ * Get primitive value
2077
+ */
2078
+ valueOf(): string;
2079
+ }
2080
+ /**
2081
+ * Pre-created timezone instances for common timezones
2082
+ */
2083
+ declare const Timezones: {
2084
+ readonly UTC: ChronosTimezone;
2085
+ readonly Local: ChronosTimezone;
2086
+ readonly Eastern: ChronosTimezone;
2087
+ readonly Central: ChronosTimezone;
2088
+ readonly Mountain: ChronosTimezone;
2089
+ readonly Pacific: ChronosTimezone;
2090
+ readonly London: ChronosTimezone;
2091
+ readonly Paris: ChronosTimezone;
2092
+ readonly Berlin: ChronosTimezone;
2093
+ readonly Tokyo: ChronosTimezone;
2094
+ readonly Shanghai: ChronosTimezone;
2095
+ readonly Singapore: ChronosTimezone;
2096
+ readonly Dubai: ChronosTimezone;
2097
+ readonly Mumbai: ChronosTimezone;
2098
+ readonly Sydney: ChronosTimezone;
2099
+ readonly Auckland: ChronosTimezone;
2100
+ };
2101
+
2102
+ /**
2103
+ * Utility functions for Chronos
2104
+ * @module utils
2105
+ */
2106
+
2107
+ /**
2108
+ * Check if value is a Date object
2109
+ */
2110
+ declare function isDate(value: unknown): value is Date;
2111
+ /**
2112
+ * Check if value is a valid date input
2113
+ */
2114
+ declare function isValidDateInput(value: unknown): value is DateInput;
2115
+ /**
2116
+ * Check if value implements ChronosLike interface
2117
+ */
2118
+ declare function isChronosLike(value: unknown): value is ChronosLike;
2119
+ /**
2120
+ * Check if value is a Duration object
2121
+ */
2122
+ declare function isDuration(value: unknown): value is Duration;
2123
+ /**
2124
+ * Check if value is a valid ISO 8601 duration string
2125
+ */
2126
+ declare function isISODuration(value: unknown): value is string;
2127
+ /**
2128
+ * Check if a year is a leap year
2129
+ */
2130
+ declare function isLeapYear(year: number): boolean;
2131
+ /**
2132
+ * Normalize a time unit to its canonical form
2133
+ */
2134
+ declare function normalizeUnit(unit: AnyTimeUnit | string): TimeUnit;
2135
+ /**
2136
+ * Get the plural form of a time unit
2137
+ */
2138
+ declare function pluralizeUnit(unit: TimeUnit, count: number): string;
2139
+ /**
2140
+ * Get milliseconds for a given time unit
2141
+ */
2142
+ declare function getMillisecondsPerUnit(unit: TimeUnit): number;
2143
+ /**
2144
+ * Get the number of days in a specific month
2145
+ */
2146
+ declare function getDaysInMonth(year: number, month: number): number;
2147
+ /**
2148
+ * Get the number of days in a year
2149
+ */
2150
+ declare function getDaysInYear(year: number): number;
2151
+ /**
2152
+ * Get the day of year (1-366)
2153
+ */
2154
+ declare function getDayOfYear(date: Date): number;
2155
+ /**
2156
+ * Get the ISO week number (1-53)
2157
+ */
2158
+ declare function getISOWeek(date: Date): number;
2159
+ /**
2160
+ * Get the ISO week year
2161
+ */
2162
+ declare function getISOWeekYear(date: Date): number;
2163
+ /**
2164
+ * Get the quarter (1-4)
2165
+ */
2166
+ declare function getQuarter(date: Date): number;
2167
+ /**
2168
+ * Get start of a time unit
2169
+ */
2170
+ declare function startOf(date: Date, unit: TimeUnit): Date;
2171
+ /**
2172
+ * Get end of a time unit
2173
+ */
2174
+ declare function endOf(date: Date, unit: TimeUnit): Date;
2175
+ /**
2176
+ * Add a duration to a date
2177
+ * Handles month overflow by clamping to the last day of the month
2178
+ */
2179
+ declare function addDuration(date: Date, duration: Duration): Date;
2180
+ /**
2181
+ * Subtract a duration from a date
2182
+ */
2183
+ declare function subtractDuration(date: Date, duration: Duration): Date;
2184
+ /**
2185
+ * Add a specific number of units to a date
2186
+ */
2187
+ declare function addUnits(date: Date, amount: number, unit: TimeUnit): Date;
2188
+ /**
2189
+ * Calculate the difference between two dates in a specific unit
2190
+ */
2191
+ declare function diffInUnits(date1: Date, date2: Date, unit: TimeUnit): number;
2192
+ /**
2193
+ * Parse an ISO 8601 duration string
2194
+ */
2195
+ declare function parseISODuration(duration: string): Duration;
2196
+ /**
2197
+ * Convert a duration to ISO 8601 format
2198
+ */
2199
+ declare function durationToISO(duration: Duration): string;
2200
+ /**
2201
+ * Compare two dates at a specific granularity
2202
+ */
2203
+ declare function compareAtGranularity(date1: Date, date2: Date, unit: TimeUnit): number;
2204
+ /**
2205
+ * Check if two dates are the same at a specific granularity
2206
+ */
2207
+ declare function isSameAt(date1: Date, date2: Date, unit: TimeUnit): boolean;
2208
+ /**
2209
+ * Create a deep clone of a date
2210
+ */
2211
+ declare function cloneDate(date: Date): Date;
2212
+ /**
2213
+ * Check if a date is valid
2214
+ */
2215
+ declare function isValidDate(date: Date): boolean;
2216
+ /**
2217
+ * Ensure a value is within bounds
2218
+ */
2219
+ declare function clamp(value: number, min: number, max: number): number;
2220
+ /**
2221
+ * Get ordinal suffix for a number (1st, 2nd, 3rd, etc.)
2222
+ */
2223
+ declare function ordinalSuffix(n: number): string;
2224
+ /**
2225
+ * Pad a number with leading zeros
2226
+ */
2227
+ declare function padStart(value: number | string, length: number, char?: string): string;
2228
+
2229
+ /**
2230
+ * Locale configuration for Chronos
2231
+ * @module locales
2232
+ */
2233
+
2234
+ /**
2235
+ * English (US) locale configuration
2236
+ */
2237
+ declare const en: LocaleConfig;
2238
+ /**
2239
+ * French locale configuration
2240
+ */
2241
+ declare const fr: LocaleConfig;
2242
+ /**
2243
+ * Spanish locale configuration
2244
+ */
2245
+ declare const es: LocaleConfig;
2246
+ /**
2247
+ * Italian locale configuration
2248
+ */
2249
+ declare const it: LocaleConfig;
2250
+ /**
2251
+ * Arabic locale configuration (Modern Standard Arabic)
2252
+ */
2253
+ declare const ar: LocaleConfig;
2254
+ /**
2255
+ * Russian locale configuration
2256
+ */
2257
+ declare const ru: LocaleConfig;
2258
+ /**
2259
+ * German locale configuration
2260
+ */
2261
+ declare const de: LocaleConfig;
2262
+ /**
2263
+ * Japanese locale configuration
2264
+ */
2265
+ declare const ja: LocaleConfig;
2266
+ /**
2267
+ * Chinese (Simplified) locale configuration
2268
+ */
2269
+ declare const zh: LocaleConfig;
2270
+ /**
2271
+ * Portuguese (Brazil) locale configuration
2272
+ */
2273
+ declare const pt: LocaleConfig;
2274
+ /**
2275
+ * Default locale
2276
+ */
2277
+ declare const defaultLocale: LocaleConfig;
2278
+ /**
2279
+ * Get a locale by code
2280
+ */
2281
+ declare function getLocale(code: string): LocaleConfig;
2282
+ /**
2283
+ * Register a new locale
2284
+ */
2285
+ declare function registerLocale(config: LocaleConfig): void;
2286
+ /**
2287
+ * Get available locale codes
45
2288
  */
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';
2289
+ declare function getAvailableLocales(): string[];
2290
+
2291
+ 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 };