@timestamp-js/core 0.1.0-rc.2 → 0.1.0-rc.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/README.md +1 -1
- package/dist/calendar.d.ts +50 -0
- package/dist/calendar.d.ts.map +1 -1
- package/dist/calendar.js +45 -0
- package/dist/calendar.js.map +1 -1
- package/dist/index.d.ts +451 -68
- package/dist/index.d.ts.map +1 -1
- package/dist/index.global.js +404 -117
- package/dist/index.global.min.js +1 -1
- package/dist/index.js +634 -167
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,55 @@
|
|
|
1
|
-
import type { CalendarDateParts, CalendarId, CalendarSystem } from './calendar.js';
|
|
2
|
-
export {
|
|
3
|
-
export type { CalendarDateParts, CalendarId, CalendarSystem } from './calendar.js';
|
|
1
|
+
import type { CalendarDateParts, CalendarDirection, CalendarId, CalendarSystem } from './calendar.js';
|
|
2
|
+
export { gregorianCalendar } from './calendar.js';
|
|
3
|
+
export type { CalendarDateParts, CalendarDirection, CalendarId, CalendarSystem, } from './calendar.js';
|
|
4
|
+
/**
|
|
5
|
+
* Formats calendar fields using Timestamp's fixed `YYYY-MM-DD` date format.
|
|
6
|
+
*
|
|
7
|
+
* @param date Plain calendar date fields.
|
|
8
|
+
* @returns Date string in `YYYY-MM-DD` form.
|
|
9
|
+
* @category calendar
|
|
10
|
+
*/
|
|
11
|
+
export declare function formatCalendarDate(date: CalendarDateParts): string;
|
|
12
|
+
/**
|
|
13
|
+
* Returns the recommended locale for a calendar system.
|
|
14
|
+
*
|
|
15
|
+
* Calendar adapters can use this to publish their normal display locale. Callers can still pass
|
|
16
|
+
* an explicit locale when an application needs a different language or numbering presentation.
|
|
17
|
+
*
|
|
18
|
+
* @param {CalendarSystem=} calendar Calendar system to read. Defaults to Gregorian.
|
|
19
|
+
* @returns {string} BCP 47 locale, defaulting to `en-US`.
|
|
20
|
+
* @category calendar
|
|
21
|
+
*/
|
|
22
|
+
export declare function getCalendarLocale(calendar?: CalendarSystem): string;
|
|
23
|
+
/**
|
|
24
|
+
* Returns the recommended text direction for a calendar system.
|
|
25
|
+
*
|
|
26
|
+
* Calendar adapters can use this to publish their normal left-to-right or right-to-left
|
|
27
|
+
* presentation. Callers can still pass an explicit direction when an application needs one.
|
|
28
|
+
*
|
|
29
|
+
* @param {CalendarSystem=} calendar Calendar system to read. Defaults to Gregorian.
|
|
30
|
+
* @returns {CalendarDirection} `ltr` or `rtl`, defaulting to `ltr`.
|
|
31
|
+
* @category calendar
|
|
32
|
+
*/
|
|
33
|
+
export declare function getCalendarDirection(calendar?: CalendarSystem): CalendarDirection;
|
|
34
|
+
/**
|
|
35
|
+
* Returns true when a calendar system recommends right-to-left presentation.
|
|
36
|
+
*
|
|
37
|
+
* @param {CalendarSystem=} calendar Calendar system to read. Defaults to Gregorian.
|
|
38
|
+
* @returns {boolean} True when the recommended direction is `rtl`.
|
|
39
|
+
* @category calendar
|
|
40
|
+
*/
|
|
41
|
+
export declare function isCalendarRTL(calendar?: CalendarSystem): boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Returns the recommended visible weekday order for a calendar system.
|
|
44
|
+
*
|
|
45
|
+
* Calendar adapters can use this to publish their normal visible week. Callers can still pass an
|
|
46
|
+
* explicit weekday list for application-specific layouts such as a five-day work week.
|
|
47
|
+
*
|
|
48
|
+
* @param {CalendarSystem=} calendar Calendar system to read. Defaults to Gregorian.
|
|
49
|
+
* @returns {number[]} Weekday numbers where Sunday is `0` and Saturday is `6`.
|
|
50
|
+
* @category calendar
|
|
51
|
+
*/
|
|
52
|
+
export declare function getCalendarWeekdays(calendar?: CalendarSystem): number[];
|
|
4
53
|
/**
|
|
5
54
|
* Matches supported date and date-time input.
|
|
6
55
|
*
|
|
@@ -458,6 +507,182 @@ export interface CalendarDayListOptions {
|
|
|
458
507
|
*/
|
|
459
508
|
readonly min?: number;
|
|
460
509
|
}
|
|
510
|
+
/**
|
|
511
|
+
* Calendar-aware disabled-day options.
|
|
512
|
+
*/
|
|
513
|
+
export interface CalendarDisabledOptions {
|
|
514
|
+
/**
|
|
515
|
+
* Disable days before this calendar date string.
|
|
516
|
+
*/
|
|
517
|
+
readonly disabledBefore?: string;
|
|
518
|
+
/**
|
|
519
|
+
* Disable days after this calendar date string.
|
|
520
|
+
*/
|
|
521
|
+
readonly disabledAfter?: string;
|
|
522
|
+
/**
|
|
523
|
+
* Weekday numbers to mark disabled.
|
|
524
|
+
*/
|
|
525
|
+
readonly disabledWeekdays?: number[];
|
|
526
|
+
/**
|
|
527
|
+
* Specific dates or date ranges to mark disabled.
|
|
528
|
+
*/
|
|
529
|
+
readonly disabledDays?: DisabledDays;
|
|
530
|
+
}
|
|
531
|
+
/**
|
|
532
|
+
* Collection of adapter-native date strings.
|
|
533
|
+
*/
|
|
534
|
+
export type CalendarDateCollection = string[] | Set<string>;
|
|
535
|
+
/**
|
|
536
|
+
* Calendar-aware selected-date options.
|
|
537
|
+
*/
|
|
538
|
+
export interface CalendarSelectionOptions {
|
|
539
|
+
/**
|
|
540
|
+
* Adapter-native date strings to mark as selected.
|
|
541
|
+
*/
|
|
542
|
+
readonly selectedDates?: CalendarDateCollection;
|
|
543
|
+
/**
|
|
544
|
+
* Two adapter-native date strings marking an inclusive selected range.
|
|
545
|
+
*/
|
|
546
|
+
readonly selectedStartEndDates?: string[];
|
|
547
|
+
}
|
|
548
|
+
/**
|
|
549
|
+
* Selection state for one calendar date.
|
|
550
|
+
*/
|
|
551
|
+
export interface CalendarSelectionState {
|
|
552
|
+
/**
|
|
553
|
+
* True when the date is explicitly selected.
|
|
554
|
+
*/
|
|
555
|
+
readonly selectedDate: boolean;
|
|
556
|
+
/**
|
|
557
|
+
* True when the date is the selected range start.
|
|
558
|
+
*/
|
|
559
|
+
readonly rangeFirst: boolean;
|
|
560
|
+
/**
|
|
561
|
+
* True when the date is inside, but not at either edge of, the selected range.
|
|
562
|
+
*/
|
|
563
|
+
readonly range: boolean;
|
|
564
|
+
/**
|
|
565
|
+
* True when the date is the selected range end.
|
|
566
|
+
*/
|
|
567
|
+
readonly rangeLast: boolean;
|
|
568
|
+
/**
|
|
569
|
+
* True when any selected-date or selected-range state applies.
|
|
570
|
+
*/
|
|
571
|
+
readonly selected: boolean;
|
|
572
|
+
}
|
|
573
|
+
/**
|
|
574
|
+
* Fully resolved state for one calendar date in a view.
|
|
575
|
+
*/
|
|
576
|
+
export interface CalendarDateState extends CalendarSelectionState {
|
|
577
|
+
/**
|
|
578
|
+
* Adapter-native timestamp for the rendered date.
|
|
579
|
+
*/
|
|
580
|
+
readonly timestamp: Timestamp;
|
|
581
|
+
/**
|
|
582
|
+
* Stable native/Gregorian identity for the rendered date.
|
|
583
|
+
*/
|
|
584
|
+
readonly identity: CalendarDateIdentity;
|
|
585
|
+
/**
|
|
586
|
+
* True when the date is outside the reference adapter month.
|
|
587
|
+
*/
|
|
588
|
+
readonly outside: boolean;
|
|
589
|
+
/**
|
|
590
|
+
* True when the date is disabled by calendar-aware disabled options.
|
|
591
|
+
*/
|
|
592
|
+
readonly disabled: boolean;
|
|
593
|
+
}
|
|
594
|
+
/**
|
|
595
|
+
* Options used when resolving one calendar date's state.
|
|
596
|
+
*/
|
|
597
|
+
export interface CalendarDateStateOptions extends CalendarDisabledOptions, CalendarSelectionOptions {
|
|
598
|
+
/**
|
|
599
|
+
* Explicit outside-month state. When omitted, referenceMonth is used.
|
|
600
|
+
*/
|
|
601
|
+
readonly outside?: boolean;
|
|
602
|
+
/**
|
|
603
|
+
* Reference date whose adapter month defines outside-month state.
|
|
604
|
+
*/
|
|
605
|
+
readonly referenceMonth?: Timestamp;
|
|
606
|
+
}
|
|
607
|
+
/**
|
|
608
|
+
* Options used when creating a calendar month view.
|
|
609
|
+
*/
|
|
610
|
+
export interface CalendarMonthViewOptions extends CalendarDisabledOptions, CalendarSelectionOptions {
|
|
611
|
+
/**
|
|
612
|
+
* Weekday numbers to include, from `0` Sunday to `6` Saturday.
|
|
613
|
+
*/
|
|
614
|
+
readonly weekdays?: number[];
|
|
615
|
+
/**
|
|
616
|
+
* Maximum number of days to return.
|
|
617
|
+
*/
|
|
618
|
+
readonly max?: number;
|
|
619
|
+
/**
|
|
620
|
+
* Minimum number of days to return.
|
|
621
|
+
*/
|
|
622
|
+
readonly min?: number;
|
|
623
|
+
}
|
|
624
|
+
/**
|
|
625
|
+
* Resolved calendar month view data.
|
|
626
|
+
*/
|
|
627
|
+
export interface CalendarMonthView {
|
|
628
|
+
/**
|
|
629
|
+
* Reference timestamp normalized through the calendar adapter.
|
|
630
|
+
*/
|
|
631
|
+
readonly reference: Timestamp;
|
|
632
|
+
/**
|
|
633
|
+
* First date of the reference adapter month.
|
|
634
|
+
*/
|
|
635
|
+
readonly start: Timestamp;
|
|
636
|
+
/**
|
|
637
|
+
* Last date of the reference adapter month.
|
|
638
|
+
*/
|
|
639
|
+
readonly end: Timestamp;
|
|
640
|
+
/**
|
|
641
|
+
* First rendered date in the month grid.
|
|
642
|
+
*/
|
|
643
|
+
readonly visibleStart: Timestamp;
|
|
644
|
+
/**
|
|
645
|
+
* Last rendered date in the month grid.
|
|
646
|
+
*/
|
|
647
|
+
readonly visibleEnd: Timestamp;
|
|
648
|
+
/**
|
|
649
|
+
* Rendered adapter-native day states.
|
|
650
|
+
*/
|
|
651
|
+
readonly days: CalendarDateState[];
|
|
652
|
+
}
|
|
653
|
+
/**
|
|
654
|
+
* Stable native and interop identity for a calendar date.
|
|
655
|
+
*
|
|
656
|
+
* Calendar-native APIs can use `nativeDate`, `native`, and `calendarId` while
|
|
657
|
+
* storage, sorting, cross-calendar joins, and legacy interop can use
|
|
658
|
+
* `epochDay` and `gregorianDate`.
|
|
659
|
+
*/
|
|
660
|
+
export interface CalendarDateIdentity {
|
|
661
|
+
/**
|
|
662
|
+
* Calendar id for the native date fields.
|
|
663
|
+
*/
|
|
664
|
+
readonly calendarId: CalendarId;
|
|
665
|
+
/**
|
|
666
|
+
* Native calendar date string in `YYYY-MM-DD` form.
|
|
667
|
+
*/
|
|
668
|
+
readonly nativeDate: string;
|
|
669
|
+
/**
|
|
670
|
+
* Native calendar date fields.
|
|
671
|
+
*/
|
|
672
|
+
readonly native: CalendarDateParts;
|
|
673
|
+
/**
|
|
674
|
+
* Canonical Gregorian date string for the same serial day.
|
|
675
|
+
*/
|
|
676
|
+
readonly gregorianDate: string;
|
|
677
|
+
/**
|
|
678
|
+
* Canonical Gregorian date fields for the same serial day.
|
|
679
|
+
*/
|
|
680
|
+
readonly gregorian: CalendarDateParts;
|
|
681
|
+
/**
|
|
682
|
+
* Stable serial day shared across calendar systems.
|
|
683
|
+
*/
|
|
684
|
+
readonly epochDay: number;
|
|
685
|
+
}
|
|
461
686
|
/**
|
|
462
687
|
* Options for formatting a TimestampDuration.
|
|
463
688
|
*/
|
|
@@ -517,10 +742,11 @@ export declare function parsed(input: string): Timestamp | null;
|
|
|
517
742
|
* with UTC getters instead of host-local getters.
|
|
518
743
|
*
|
|
519
744
|
* @param {Date} date JavaScript Date to convert.
|
|
745
|
+
* @param {CalendarSystem=} calendar Calendar system to use. Defaults to Gregorian; pass an adapter such as islamicCivilCalendar for native calendar fields.
|
|
520
746
|
* @returns {Timestamp} Formatted Timestamp object, or `null` for invalid input.
|
|
521
747
|
* @category parsing
|
|
522
748
|
*/
|
|
523
|
-
export declare function parseDate(date: Date): Timestamp | null;
|
|
749
|
+
export declare function parseDate(date: Date, calendar?: CalendarSystem): Timestamp | null;
|
|
524
750
|
/**
|
|
525
751
|
* Converts a JavaScript Date into a formatted Timestamp using UTC fields.
|
|
526
752
|
*
|
|
@@ -528,10 +754,11 @@ export declare function parseDate(date: Date): Timestamp | null;
|
|
|
528
754
|
* and time fields for a native Date instant.
|
|
529
755
|
*
|
|
530
756
|
* @param {Date} date JavaScript Date to convert.
|
|
757
|
+
* @param {CalendarSystem=} calendar Calendar system to use. Defaults to Gregorian; pass an adapter such as islamicCivilCalendar for native calendar fields.
|
|
531
758
|
* @returns {Timestamp} Formatted Timestamp object, or `null` for invalid input.
|
|
532
759
|
* @category parsing
|
|
533
760
|
*/
|
|
534
|
-
export declare function parseDateUTC(date: Date): Timestamp | null;
|
|
761
|
+
export declare function parseDateUTC(date: Date, calendar?: CalendarSystem): Timestamp | null;
|
|
535
762
|
/**
|
|
536
763
|
* Pads a number to a requested string length.
|
|
537
764
|
*
|
|
@@ -545,57 +772,65 @@ export declare function padNumber(x: number, length: number): string;
|
|
|
545
772
|
/**
|
|
546
773
|
* Returns if the passed year is a leap year
|
|
547
774
|
* @param {number} year The year to check (ie: 1999, 2020)
|
|
775
|
+
* @param {CalendarSystem=} calendar Calendar system to use. Defaults to Gregorian; pass an adapter such as islamicCivilCalendar for native calendar fields.
|
|
548
776
|
* @returns {boolean} True if the year is a leap year
|
|
549
777
|
* @category calendar
|
|
550
778
|
*/
|
|
551
|
-
export declare function isLeapYear(year: number): boolean;
|
|
779
|
+
export declare function isLeapYear(year: number, calendar?: CalendarSystem): boolean;
|
|
552
780
|
/**
|
|
553
781
|
* Returns the days of the specified month in a year
|
|
554
782
|
* @param {number} year The year (ie: 1999, 2020)
|
|
555
|
-
* @param {number} month The
|
|
783
|
+
* @param {number} month The month number in the selected calendar, where January is `1` for Gregorian.
|
|
784
|
+
* @param {CalendarSystem=} calendar Calendar system to use. Defaults to Gregorian; pass an adapter such as islamicCivilCalendar for native calendar fields.
|
|
556
785
|
* @returns {number} The number of days in the month (corrected for leap years)
|
|
557
786
|
* @category calendar
|
|
558
787
|
*/
|
|
559
|
-
export declare function daysInMonth(year: number, month: number): number;
|
|
788
|
+
export declare function daysInMonth(year: number, month: number, calendar?: CalendarSystem): number;
|
|
560
789
|
/**
|
|
561
790
|
* Returns a new Timestamp for the next calendar day.
|
|
562
791
|
*
|
|
563
792
|
* @param {Timestamp} timestamp Base Timestamp object.
|
|
793
|
+
* @param {CalendarSystem=} calendar Calendar system to use. Defaults to Gregorian; pass an adapter such as islamicCivilCalendar for native calendar fields.
|
|
564
794
|
* @returns {Timestamp} New Timestamp representing the next day.
|
|
565
795
|
* @category arithmetic
|
|
566
796
|
*/
|
|
567
|
-
export declare function nextDay(timestamp: Timestamp): Timestamp;
|
|
797
|
+
export declare function nextDay(timestamp: Timestamp, calendar?: CalendarSystem): Timestamp;
|
|
568
798
|
/**
|
|
569
799
|
* Returns a new Timestamp for the previous calendar day.
|
|
570
800
|
*
|
|
571
801
|
* @param {Timestamp} timestamp Base Timestamp object.
|
|
802
|
+
* @param {CalendarSystem=} calendar Calendar system to use. Defaults to Gregorian; pass an adapter such as islamicCivilCalendar for native calendar fields.
|
|
572
803
|
* @returns {Timestamp} New Timestamp representing the previous day.
|
|
573
804
|
* @category arithmetic
|
|
574
805
|
*/
|
|
575
|
-
export declare function prevDay(timestamp: Timestamp): Timestamp;
|
|
806
|
+
export declare function prevDay(timestamp: Timestamp, calendar?: CalendarSystem): Timestamp;
|
|
576
807
|
/**
|
|
577
808
|
* Returns today's date using the host runtime timezone.
|
|
578
809
|
*
|
|
579
810
|
* For SSR or static rendering, server and client runtimes can produce different
|
|
580
811
|
* values when they run in different timezones. Use todayUTC() when the app
|
|
581
|
-
* wants a stable UTC calendar date instead.
|
|
812
|
+
* wants a stable UTC calendar date instead. Pass a calendar system to return
|
|
813
|
+
* today's date in that calendar's native `YYYY-MM-DD` fields.
|
|
582
814
|
*
|
|
815
|
+
* @param {CalendarSystem=} calendar Calendar system to use. Defaults to Gregorian; pass an adapter such as islamicCivilCalendar for native calendar fields.
|
|
583
816
|
* @returns {string} Date string in the form `YYYY-MM-DD`
|
|
584
817
|
* @category state
|
|
585
818
|
*/
|
|
586
|
-
export declare function today(): string;
|
|
819
|
+
export declare function today(calendar?: CalendarSystem): string;
|
|
587
820
|
/**
|
|
588
821
|
* Returns today's date using UTC calendar fields.
|
|
589
822
|
*
|
|
590
823
|
* Pass a Date fixture to make SSR, tests, and hydration-sensitive render paths
|
|
591
824
|
* deterministic. This helper reads UTC fields only; it does not convert an
|
|
592
|
-
* existing Timestamp or timezone-suffixed string.
|
|
825
|
+
* existing Timestamp or timezone-suffixed string. Pass a calendar system to
|
|
826
|
+
* return today's UTC date in that calendar's native `YYYY-MM-DD` fields.
|
|
593
827
|
*
|
|
594
828
|
* @param {Date} date Date source to read. Defaults to the current Date.
|
|
829
|
+
* @param {CalendarSystem=} calendar Calendar system to use. Defaults to Gregorian; pass an adapter such as islamicCivilCalendar for native calendar fields.
|
|
595
830
|
* @returns {string} UTC date string in the form `YYYY-MM-DD`
|
|
596
831
|
* @category state
|
|
597
832
|
*/
|
|
598
|
-
export declare function todayUTC(date?: Date): string;
|
|
833
|
+
export declare function todayUTC(date?: Date, calendar?: CalendarSystem): string;
|
|
599
834
|
/**
|
|
600
835
|
* Returns the current date-time as an immutable Timestamp using UTC fields.
|
|
601
836
|
*
|
|
@@ -604,17 +839,19 @@ export declare function todayUTC(date?: Date): string;
|
|
|
604
839
|
* caller instead of allowing each runtime to create its own current Date.
|
|
605
840
|
*
|
|
606
841
|
* @param {Date} date Date source to read. Defaults to the current Date.
|
|
842
|
+
* @param {CalendarSystem=} calendar Calendar system to use. Defaults to Gregorian; pass an adapter such as islamicCivilCalendar for native calendar fields.
|
|
607
843
|
* @returns {Timestamp} Immutable Timestamp built from UTC fields.
|
|
608
844
|
* @category state
|
|
609
845
|
*/
|
|
610
|
-
export declare function nowUTC(date?: Date): Timestamp;
|
|
846
|
+
export declare function nowUTC(date?: Date, calendar?: CalendarSystem): Timestamp;
|
|
611
847
|
/**
|
|
612
848
|
* Takes a date string ('YYYY-MM-DD') and validates if it is today's date
|
|
613
849
|
* @param {string} date Date string in the form 'YYYY-MM-DD'
|
|
850
|
+
* @param {CalendarSystem=} calendar Calendar system to use. Defaults to Gregorian; pass an adapter such as islamicCivilCalendar for native calendar fields.
|
|
614
851
|
* @returns {boolean} True if the date is today's date
|
|
615
852
|
* @category comparison
|
|
616
853
|
*/
|
|
617
|
-
export declare function isToday(date: string): boolean;
|
|
854
|
+
export declare function isToday(date: string, calendar?: CalendarSystem): boolean;
|
|
618
855
|
/**
|
|
619
856
|
* Checks whether a date string matches today's UTC date.
|
|
620
857
|
*
|
|
@@ -623,44 +860,49 @@ export declare function isToday(date: string): boolean;
|
|
|
623
860
|
*
|
|
624
861
|
* @param {string} date Date string in the form `YYYY-MM-DD`.
|
|
625
862
|
* @param {Date} now Date source to read. Defaults to the current Date.
|
|
863
|
+
* @param {CalendarSystem=} calendar Calendar system to use. Defaults to Gregorian; pass an adapter such as islamicCivilCalendar for native calendar fields.
|
|
626
864
|
* @returns {boolean} True when the date matches the UTC date.
|
|
627
865
|
* @category comparison
|
|
628
866
|
*/
|
|
629
|
-
export declare function isTodayUTC(date: string, now?: Date): boolean;
|
|
867
|
+
export declare function isTodayUTC(date: string, now?: Date, calendar?: CalendarSystem): boolean;
|
|
630
868
|
/**
|
|
631
869
|
* Returns the start of the week for a Timestamp and weekday set.
|
|
632
870
|
* If a current Timestamp is provided, the returned Timestamp includes updated relative information.
|
|
633
871
|
* @param {Timestamp} timestamp The Timestamp to use to find the start of the week
|
|
634
872
|
* @param {number[]} weekdays The array is [0,1,2,3,4,5,6] where 0=Sunday and 6=Saturday
|
|
635
873
|
* @param {Timestamp=} today Current timestamp used to update relative information
|
|
874
|
+
* @param {CalendarSystem=} calendar Calendar system to use. Defaults to Gregorian; pass an adapter such as islamicCivilCalendar for native calendar fields.
|
|
636
875
|
* @returns {Timestamp} A new Timestamp representing the start of the week
|
|
637
876
|
* @category ranges
|
|
638
877
|
*/
|
|
639
|
-
export declare function getStartOfWeek(timestamp: Timestamp, weekdays: number[], today: Timestamp): Timestamp;
|
|
878
|
+
export declare function getStartOfWeek(timestamp: Timestamp, weekdays: number[], today: Timestamp, calendar?: CalendarSystem): Timestamp;
|
|
640
879
|
/**
|
|
641
880
|
* Returns the end of the week for a Timestamp and weekday set.
|
|
642
881
|
* If a current Timestamp is provided, the returned Timestamp includes updated relative information.
|
|
643
882
|
* @param {Timestamp} timestamp The Timestamp to use to find the end of the week
|
|
644
883
|
* @param {number[]} weekdays The array is [0,1,2,3,4,5,6] where 0=Sunday and 6=Saturday
|
|
645
884
|
* @param {Timestamp=} today Current timestamp used to update relative information
|
|
885
|
+
* @param {CalendarSystem=} calendar Calendar system to use. Defaults to Gregorian; pass an adapter such as islamicCivilCalendar for native calendar fields.
|
|
646
886
|
* @returns {Timestamp} A new Timestamp representing the end of the week
|
|
647
887
|
* @category ranges
|
|
648
888
|
*/
|
|
649
|
-
export declare function getEndOfWeek(timestamp: Timestamp, weekdays: number[], today: Timestamp): Timestamp;
|
|
889
|
+
export declare function getEndOfWeek(timestamp: Timestamp, weekdays: number[], today: Timestamp, calendar?: CalendarSystem): Timestamp;
|
|
650
890
|
/**
|
|
651
891
|
* Finds the start of the month based on the passed in Timestamp
|
|
652
892
|
* @param {Timestamp} timestamp The Timestamp to use to find the start of the month
|
|
893
|
+
* @param {CalendarSystem=} calendar Calendar system to use. Defaults to Gregorian; pass an adapter such as islamicCivilCalendar for native calendar fields.
|
|
653
894
|
* @returns {Timestamp} A Timestamp of the start of the month
|
|
654
895
|
* @category ranges
|
|
655
896
|
*/
|
|
656
|
-
export declare function getStartOfMonth(timestamp: Timestamp): Timestamp;
|
|
897
|
+
export declare function getStartOfMonth(timestamp: Timestamp, calendar?: CalendarSystem): Timestamp;
|
|
657
898
|
/**
|
|
658
899
|
* Finds the end of the month based on the passed in Timestamp
|
|
659
900
|
* @param {Timestamp} timestamp The Timestamp to use to find the end of the month
|
|
901
|
+
* @param {CalendarSystem=} calendar Calendar system to use. Defaults to Gregorian; pass an adapter such as islamicCivilCalendar for native calendar fields.
|
|
660
902
|
* @returns {Timestamp} A Timestamp of the end of the month
|
|
661
903
|
* @category ranges
|
|
662
904
|
*/
|
|
663
|
-
export declare function getEndOfMonth(timestamp: Timestamp): Timestamp;
|
|
905
|
+
export declare function getEndOfMonth(timestamp: Timestamp, calendar?: CalendarSystem): Timestamp;
|
|
664
906
|
/**
|
|
665
907
|
* Converts time input into minutes since midnight.
|
|
666
908
|
*
|
|
@@ -739,7 +981,7 @@ export declare function getDayIdentifier(timestamp: Timestamp): number;
|
|
|
739
981
|
* same serial day space so ranges and comparisons can be calendar-agnostic.
|
|
740
982
|
*
|
|
741
983
|
* @param {Timestamp} timestamp Timestamp object to read.
|
|
742
|
-
* @param {CalendarSystem=} calendar Calendar
|
|
984
|
+
* @param {CalendarSystem=} calendar Calendar system to use. Defaults to Gregorian; pass an adapter such as islamicCivilCalendar for native calendar fields.
|
|
743
985
|
* @returns {number} Stable serial day.
|
|
744
986
|
* @category conversion
|
|
745
987
|
*/
|
|
@@ -751,16 +993,29 @@ export declare function getEpochDay(timestamp: Timestamp, calendar?: CalendarSys
|
|
|
751
993
|
* range comparisons, or virtualized day rows across different calendar adapters.
|
|
752
994
|
*
|
|
753
995
|
* @param timestamp Timestamp object to read.
|
|
754
|
-
* @param calendar Calendar
|
|
996
|
+
* @param calendar Calendar system to use. Defaults to Gregorian; pass an adapter such as islamicCivilCalendar for native calendar fields.
|
|
755
997
|
* @returns Stable serial day.
|
|
756
998
|
* @category calendar
|
|
757
999
|
*/
|
|
758
1000
|
export declare function getCalendarDayIdentifier(timestamp: Timestamp, calendar?: CalendarSystem): number;
|
|
1001
|
+
/**
|
|
1002
|
+
* Creates stable native and Gregorian identities for a calendar timestamp.
|
|
1003
|
+
*
|
|
1004
|
+
* Use this when component APIs need to expose adapter-native values while also
|
|
1005
|
+
* preserving a canonical Gregorian key for storage, comparisons, or interop
|
|
1006
|
+
* with existing data.
|
|
1007
|
+
*
|
|
1008
|
+
* @param timestamp Timestamp object to identify.
|
|
1009
|
+
* @param calendar Calendar system to use. Defaults to Gregorian; pass an adapter such as islamicCivilCalendar for native calendar fields.
|
|
1010
|
+
* @returns Calendar-native date, Gregorian interop date, and shared epoch day.
|
|
1011
|
+
* @category calendar
|
|
1012
|
+
*/
|
|
1013
|
+
export declare function getCalendarDateIdentity(timestamp: Timestamp, calendar?: CalendarSystem): CalendarDateIdentity;
|
|
759
1014
|
/**
|
|
760
1015
|
* Returns true when calendar date fields are valid for a calendar system.
|
|
761
1016
|
*
|
|
762
1017
|
* @param date Calendar date fields to validate.
|
|
763
|
-
* @param calendar Calendar
|
|
1018
|
+
* @param calendar Calendar system to use. Defaults to Gregorian; pass an adapter such as islamicCivilCalendar for native calendar fields.
|
|
764
1019
|
* @returns True when year, month, and day can exist in the calendar.
|
|
765
1020
|
* @category calendar
|
|
766
1021
|
*/
|
|
@@ -772,7 +1027,7 @@ export declare function isValidCalendarDate(date: CalendarDateParts, calendar?:
|
|
|
772
1027
|
* `calendarId`, and derives weekday/day-of-year values from the adapter.
|
|
773
1028
|
*
|
|
774
1029
|
* @param date Calendar date fields.
|
|
775
|
-
* @param calendar Calendar
|
|
1030
|
+
* @param calendar Calendar system to use. Defaults to Gregorian; pass an adapter such as islamicCivilCalendar for native calendar fields.
|
|
776
1031
|
* @param options Optional time and relative comparison settings.
|
|
777
1032
|
* @returns Timestamp-shaped calendar value.
|
|
778
1033
|
* @category calendar
|
|
@@ -785,17 +1040,30 @@ export declare function createCalendarTimestamp(date: CalendarDateParts, calenda
|
|
|
785
1040
|
* calendar and derives weekday/day-of-year values through the adapter.
|
|
786
1041
|
*
|
|
787
1042
|
* @param input Date or date-time string.
|
|
788
|
-
* @param calendar Calendar
|
|
1043
|
+
* @param calendar Calendar system to use. Defaults to Gregorian; pass an adapter such as islamicCivilCalendar for native calendar fields.
|
|
789
1044
|
* @param now Optional comparison timestamp from the same calendar system.
|
|
790
1045
|
* @returns Calendar timestamp, or `null` when the input cannot be parsed or validated.
|
|
791
1046
|
* @category calendar
|
|
792
1047
|
*/
|
|
793
1048
|
export declare function parseCalendarTimestamp(input: string, calendar?: CalendarSystem, now?: Timestamp | null): Timestamp | null;
|
|
1049
|
+
/**
|
|
1050
|
+
* Validates whether an input string can be parsed as a calendar adapter timestamp.
|
|
1051
|
+
*
|
|
1052
|
+
* The default Gregorian calendar preserves existing Timestamp semantics. When
|
|
1053
|
+
* an alternate calendar is supplied, `YYYY-MM-DD` is interpreted as native to
|
|
1054
|
+
* that adapter.
|
|
1055
|
+
*
|
|
1056
|
+
* @param input Date or date-time string.
|
|
1057
|
+
* @param calendar Calendar system to use. Defaults to Gregorian; pass an adapter such as islamicCivilCalendar for native calendar fields.
|
|
1058
|
+
* @returns True when the string can be parsed and exists in the calendar.
|
|
1059
|
+
* @category calendar
|
|
1060
|
+
*/
|
|
1061
|
+
export declare function validateCalendarTimestamp(input: string, calendar?: CalendarSystem): boolean;
|
|
794
1062
|
/**
|
|
795
1063
|
* Creates a calendar timestamp from a stable serial day.
|
|
796
1064
|
*
|
|
797
1065
|
* @param epochDay Stable serial day.
|
|
798
|
-
* @param calendar Calendar
|
|
1066
|
+
* @param calendar Calendar system to use. Defaults to Gregorian; pass an adapter such as islamicCivilCalendar for native calendar fields.
|
|
799
1067
|
* @param options Optional time and relative comparison settings.
|
|
800
1068
|
* @returns Timestamp-shaped calendar value.
|
|
801
1069
|
* @category calendar
|
|
@@ -805,7 +1073,7 @@ export declare function createCalendarTimestampFromEpochDay(epochDay: number, ca
|
|
|
805
1073
|
* Updates formatted calendar metadata on a timestamp-shaped value.
|
|
806
1074
|
*
|
|
807
1075
|
* @param timestamp Timestamp object to transform.
|
|
808
|
-
* @param calendar Calendar
|
|
1076
|
+
* @param calendar Calendar system to use. Defaults to Gregorian; pass an adapter such as islamicCivilCalendar for native calendar fields.
|
|
809
1077
|
* @returns Timestamp with adapter date formatting and metadata.
|
|
810
1078
|
* @category calendar
|
|
811
1079
|
*/
|
|
@@ -815,7 +1083,7 @@ export declare function updateCalendarFormatted(timestamp: Timestamp, calendar?:
|
|
|
815
1083
|
*
|
|
816
1084
|
* @param timestamp Timestamp object to update.
|
|
817
1085
|
* @param now Timestamp representing the comparison point in the same calendar.
|
|
818
|
-
* @param calendar Calendar
|
|
1086
|
+
* @param calendar Calendar system to use. Defaults to Gregorian; pass an adapter such as islamicCivilCalendar for native calendar fields.
|
|
819
1087
|
* @param time Include time-of-day in the comparison when true.
|
|
820
1088
|
* @returns New Timestamp object with relative flags.
|
|
821
1089
|
* @category calendar
|
|
@@ -825,7 +1093,7 @@ export declare function updateCalendarRelative(timestamp: Timestamp, now: Timest
|
|
|
825
1093
|
* Returns a calendar timestamp for the next day.
|
|
826
1094
|
*
|
|
827
1095
|
* @param timestamp Base timestamp.
|
|
828
|
-
* @param calendar Calendar
|
|
1096
|
+
* @param calendar Calendar system to use. Defaults to Gregorian; pass an adapter such as islamicCivilCalendar for native calendar fields.
|
|
829
1097
|
* @returns New timestamp for the next adapter day.
|
|
830
1098
|
* @category calendar
|
|
831
1099
|
*/
|
|
@@ -834,7 +1102,7 @@ export declare function nextCalendarDay(timestamp: Timestamp, calendar?: Calenda
|
|
|
834
1102
|
* Returns a calendar timestamp for the previous day.
|
|
835
1103
|
*
|
|
836
1104
|
* @param timestamp Base timestamp.
|
|
837
|
-
* @param calendar Calendar
|
|
1105
|
+
* @param calendar Calendar system to use. Defaults to Gregorian; pass an adapter such as islamicCivilCalendar for native calendar fields.
|
|
838
1106
|
* @returns New timestamp for the previous adapter day.
|
|
839
1107
|
* @category calendar
|
|
840
1108
|
*/
|
|
@@ -844,7 +1112,7 @@ export declare function prevCalendarDay(timestamp: Timestamp, calendar?: Calenda
|
|
|
844
1112
|
*
|
|
845
1113
|
* @param timestamp Base timestamp.
|
|
846
1114
|
* @param amount Number of days to move.
|
|
847
|
-
* @param calendar Calendar
|
|
1115
|
+
* @param calendar Calendar system to use. Defaults to Gregorian; pass an adapter such as islamicCivilCalendar for native calendar fields.
|
|
848
1116
|
* @returns New timestamp after moving.
|
|
849
1117
|
* @category calendar
|
|
850
1118
|
*/
|
|
@@ -854,7 +1122,7 @@ export declare function addCalendarDays(timestamp: Timestamp, amount: number, ca
|
|
|
854
1122
|
*
|
|
855
1123
|
* @param timestamp Base timestamp.
|
|
856
1124
|
* @param amount Number of calendar months to move.
|
|
857
|
-
* @param calendar Calendar
|
|
1125
|
+
* @param calendar Calendar system to use. Defaults to Gregorian; pass an adapter such as islamicCivilCalendar for native calendar fields.
|
|
858
1126
|
* @returns New timestamp after moving.
|
|
859
1127
|
* @category calendar
|
|
860
1128
|
*/
|
|
@@ -864,7 +1132,7 @@ export declare function addCalendarMonths(timestamp: Timestamp, amount: number,
|
|
|
864
1132
|
*
|
|
865
1133
|
* @param timestamp Base timestamp.
|
|
866
1134
|
* @param amount Number of calendar years to move.
|
|
867
|
-
* @param calendar Calendar
|
|
1135
|
+
* @param calendar Calendar system to use. Defaults to Gregorian; pass an adapter such as islamicCivilCalendar for native calendar fields.
|
|
868
1136
|
* @returns New timestamp after moving.
|
|
869
1137
|
* @category calendar
|
|
870
1138
|
*/
|
|
@@ -873,7 +1141,7 @@ export declare function addCalendarYears(timestamp: Timestamp, amount: number, c
|
|
|
873
1141
|
* Returns the start of the calendar month for a timestamp.
|
|
874
1142
|
*
|
|
875
1143
|
* @param timestamp Base timestamp.
|
|
876
|
-
* @param calendar Calendar
|
|
1144
|
+
* @param calendar Calendar system to use. Defaults to Gregorian; pass an adapter such as islamicCivilCalendar for native calendar fields.
|
|
877
1145
|
* @returns First day of the adapter month.
|
|
878
1146
|
* @category calendar
|
|
879
1147
|
*/
|
|
@@ -882,7 +1150,7 @@ export declare function getCalendarStartOfMonth(timestamp: Timestamp, calendar?:
|
|
|
882
1150
|
* Returns the end of the calendar month for a timestamp.
|
|
883
1151
|
*
|
|
884
1152
|
* @param timestamp Base timestamp.
|
|
885
|
-
* @param calendar Calendar
|
|
1153
|
+
* @param calendar Calendar system to use. Defaults to Gregorian; pass an adapter such as islamicCivilCalendar for native calendar fields.
|
|
886
1154
|
* @returns Last day of the adapter month.
|
|
887
1155
|
* @category calendar
|
|
888
1156
|
*/
|
|
@@ -891,7 +1159,7 @@ export declare function getCalendarEndOfMonth(timestamp: Timestamp, calendar?: C
|
|
|
891
1159
|
* Returns the start of the calendar year for a timestamp.
|
|
892
1160
|
*
|
|
893
1161
|
* @param timestamp Base timestamp.
|
|
894
|
-
* @param calendar Calendar
|
|
1162
|
+
* @param calendar Calendar system to use. Defaults to Gregorian; pass an adapter such as islamicCivilCalendar for native calendar fields.
|
|
895
1163
|
* @returns First day of the adapter year.
|
|
896
1164
|
* @category calendar
|
|
897
1165
|
*/
|
|
@@ -900,7 +1168,7 @@ export declare function getCalendarStartOfYear(timestamp: Timestamp, calendar?:
|
|
|
900
1168
|
* Returns the end of the calendar year for a timestamp.
|
|
901
1169
|
*
|
|
902
1170
|
* @param timestamp Base timestamp.
|
|
903
|
-
* @param calendar Calendar
|
|
1171
|
+
* @param calendar Calendar system to use. Defaults to Gregorian; pass an adapter such as islamicCivilCalendar for native calendar fields.
|
|
904
1172
|
* @returns Last day of the adapter year.
|
|
905
1173
|
* @category calendar
|
|
906
1174
|
*/
|
|
@@ -910,7 +1178,7 @@ export declare function getCalendarEndOfYear(timestamp: Timestamp, calendar?: Ca
|
|
|
910
1178
|
*
|
|
911
1179
|
* @param timestamp Base timestamp.
|
|
912
1180
|
* @param weekday Weekday number to find.
|
|
913
|
-
* @param calendar Calendar
|
|
1181
|
+
* @param calendar Calendar system to use. Defaults to Gregorian; pass an adapter such as islamicCivilCalendar for native calendar fields.
|
|
914
1182
|
* @param direction Direction to search.
|
|
915
1183
|
* @param maxDays Maximum days to inspect.
|
|
916
1184
|
* @returns Matching timestamp, or the last inspected timestamp.
|
|
@@ -922,7 +1190,7 @@ export declare function findCalendarWeekday(timestamp: Timestamp, weekday: numbe
|
|
|
922
1190
|
*
|
|
923
1191
|
* @param timestamp Base timestamp.
|
|
924
1192
|
* @param weekdays Weekday numbers to include, from `0` Sunday to `6` Saturday.
|
|
925
|
-
* @param calendar Calendar
|
|
1193
|
+
* @param calendar Calendar system to use. Defaults to Gregorian; pass an adapter such as islamicCivilCalendar for native calendar fields.
|
|
926
1194
|
* @param now Optional comparison timestamp from the same calendar.
|
|
927
1195
|
* @returns Start of the adapter week.
|
|
928
1196
|
* @category calendar
|
|
@@ -933,7 +1201,7 @@ export declare function getCalendarStartOfWeek(timestamp: Timestamp, weekdays: n
|
|
|
933
1201
|
*
|
|
934
1202
|
* @param timestamp Base timestamp.
|
|
935
1203
|
* @param weekdays Weekday numbers to include, from `0` Sunday to `6` Saturday.
|
|
936
|
-
* @param calendar Calendar
|
|
1204
|
+
* @param calendar Calendar system to use. Defaults to Gregorian; pass an adapter such as islamicCivilCalendar for native calendar fields.
|
|
937
1205
|
* @param now Optional comparison timestamp from the same calendar.
|
|
938
1206
|
* @returns End of the adapter week.
|
|
939
1207
|
* @category calendar
|
|
@@ -945,12 +1213,22 @@ export declare function getCalendarEndOfWeek(timestamp: Timestamp, weekdays: num
|
|
|
945
1213
|
* @param start First day in the list.
|
|
946
1214
|
* @param end Last day boundary for the list.
|
|
947
1215
|
* @param now Timestamp used to calculate relative flags.
|
|
948
|
-
* @param calendar Calendar
|
|
1216
|
+
* @param calendar Calendar system to use. Defaults to Gregorian; pass an adapter such as islamicCivilCalendar for native calendar fields.
|
|
949
1217
|
* @param options Optional weekday, disabled, and size filters.
|
|
950
1218
|
* @returns Timestamp days for the adapter calendar.
|
|
951
1219
|
* @category calendar
|
|
952
1220
|
*/
|
|
953
1221
|
export declare function createCalendarDayList(start: Timestamp, end: Timestamp, now: Timestamp, calendar?: CalendarSystem, options?: CalendarDayListOptions): Timestamp[];
|
|
1222
|
+
/**
|
|
1223
|
+
* Returns true when a timestamp falls outside the reference timestamp's adapter month.
|
|
1224
|
+
*
|
|
1225
|
+
* @param timestamp Timestamp to test.
|
|
1226
|
+
* @param reference Timestamp whose month defines the inside range.
|
|
1227
|
+
* @param calendar Calendar system to use. Defaults to Gregorian; pass an adapter such as islamicCivilCalendar for native calendar fields.
|
|
1228
|
+
* @returns True when timestamp is outside reference's calendar month.
|
|
1229
|
+
* @category calendar
|
|
1230
|
+
*/
|
|
1231
|
+
export declare function isOutsideCalendarMonth(timestamp: Timestamp, reference: Timestamp, calendar?: CalendarSystem): boolean;
|
|
954
1232
|
/**
|
|
955
1233
|
* Converts a Timestamp time into a sortable numeric identifier.
|
|
956
1234
|
*
|
|
@@ -986,10 +1264,11 @@ export declare function diffTimestamp(ts1: Timestamp, ts2: Timestamp, strict?: b
|
|
|
986
1264
|
* @param {Timestamp} timestamp Timestamp object to update.
|
|
987
1265
|
* @param {Timestamp} now Timestamp representing the comparison point.
|
|
988
1266
|
* @param {boolean=} time Include time-of-day in the comparison when true.
|
|
1267
|
+
* @param {CalendarSystem=} calendar Calendar system to use. Defaults to Gregorian; pass an adapter such as islamicCivilCalendar for native calendar fields.
|
|
989
1268
|
* @returns {Timestamp} New Timestamp object with relative flags.
|
|
990
1269
|
* @category state
|
|
991
1270
|
*/
|
|
992
|
-
export declare function updateRelative(timestamp: Timestamp, now: Timestamp, time?: boolean): Timestamp;
|
|
1271
|
+
export declare function updateRelative(timestamp: Timestamp, now: Timestamp, time?: boolean, calendar?: CalendarSystem): Timestamp;
|
|
993
1272
|
/**
|
|
994
1273
|
* Returns a timestamp set to a number of minutes past midnight.
|
|
995
1274
|
*
|
|
@@ -999,31 +1278,35 @@ export declare function updateRelative(timestamp: Timestamp, now: Timestamp, tim
|
|
|
999
1278
|
* @param {Timestamp} timestamp The Timestamp to transform
|
|
1000
1279
|
* @param {number} minutes The number of minutes to set from midnight
|
|
1001
1280
|
* @param {Timestamp=} now Optional Timestamp representing current date and time
|
|
1281
|
+
* @param {CalendarSystem=} calendar Calendar system to use. Defaults to Gregorian; pass an adapter such as islamicCivilCalendar for native calendar fields.
|
|
1002
1282
|
* @returns {Timestamp} A new Timestamp
|
|
1003
1283
|
* @category arithmetic
|
|
1004
1284
|
*/
|
|
1005
|
-
export declare function updateMinutes(timestamp: Timestamp, minutes: number, now?: Timestamp | null): Timestamp;
|
|
1285
|
+
export declare function updateMinutes(timestamp: Timestamp, minutes: number, now?: Timestamp | null, calendar?: CalendarSystem): Timestamp;
|
|
1006
1286
|
/**
|
|
1007
1287
|
* Updates the Timestamp with the weekday
|
|
1008
1288
|
* @param {Timestamp} timestamp The Timestamp to transform
|
|
1289
|
+
* @param {CalendarSystem=} calendar Calendar system to use. Defaults to Gregorian; pass an adapter such as islamicCivilCalendar for native calendar fields.
|
|
1009
1290
|
* @returns A new Timestamp
|
|
1010
1291
|
* @category formatting
|
|
1011
1292
|
*/
|
|
1012
|
-
export declare function updateWeekday(timestamp: Timestamp): Timestamp;
|
|
1293
|
+
export declare function updateWeekday(timestamp: Timestamp, calendar?: CalendarSystem): Timestamp;
|
|
1013
1294
|
/**
|
|
1014
1295
|
* Updates the Timestamp with the day of the year (doy)
|
|
1015
1296
|
* @param {Timestamp} timestamp The Timestamp to transform
|
|
1297
|
+
* @param {CalendarSystem=} calendar Calendar system to use. Defaults to Gregorian; pass an adapter such as islamicCivilCalendar for native calendar fields.
|
|
1016
1298
|
* @returns A new Timestamp
|
|
1017
1299
|
* @category formatting
|
|
1018
1300
|
*/
|
|
1019
|
-
export declare function updateDayOfYear(timestamp: Timestamp): Timestamp;
|
|
1301
|
+
export declare function updateDayOfYear(timestamp: Timestamp, calendar?: CalendarSystem): Timestamp;
|
|
1020
1302
|
/**
|
|
1021
1303
|
* Updates the Timestamp with the workweek
|
|
1022
1304
|
* @param {Timestamp} timestamp The Timestamp to transform
|
|
1305
|
+
* @param {CalendarSystem=} calendar Calendar system to use. Defaults to Gregorian; pass an adapter such as islamicCivilCalendar for native calendar fields.
|
|
1023
1306
|
* @returns A new Timestamp
|
|
1024
1307
|
* @category formatting
|
|
1025
1308
|
*/
|
|
1026
|
-
export declare function updateWorkWeek(timestamp: Timestamp): Timestamp;
|
|
1309
|
+
export declare function updateWorkWeek(timestamp: Timestamp, calendar?: CalendarSystem): Timestamp;
|
|
1027
1310
|
/**
|
|
1028
1311
|
* Updates the passed Timestamp with disabled, if needed
|
|
1029
1312
|
* @param {Timestamp} timestamp The Timestamp to transform
|
|
@@ -1035,34 +1318,93 @@ export declare function updateWorkWeek(timestamp: Timestamp): Timestamp;
|
|
|
1035
1318
|
* @category state
|
|
1036
1319
|
*/
|
|
1037
1320
|
export declare function updateDisabled(timestamp: Timestamp, disabledBefore?: string, disabledAfter?: string, disabledWeekdays?: number[], disabledDays?: DisabledDays): Timestamp;
|
|
1321
|
+
/**
|
|
1322
|
+
* Updates a timestamp with disabled state using calendar-native date strings.
|
|
1323
|
+
*
|
|
1324
|
+
* The default Gregorian calendar preserves existing Timestamp behavior. When
|
|
1325
|
+
* an alternate calendar is supplied, `disabledBefore`, `disabledAfter`, and
|
|
1326
|
+
* `disabledDays` are parsed as native dates for that adapter.
|
|
1327
|
+
*
|
|
1328
|
+
* @param timestamp Timestamp to transform.
|
|
1329
|
+
* @param disabledBefore Disable days on or before this adapter date.
|
|
1330
|
+
* @param disabledAfter Disable days on or after this adapter date.
|
|
1331
|
+
* @param disabledWeekdays Weekday numbers to mark disabled.
|
|
1332
|
+
* @param disabledDays Specific adapter dates or date ranges to mark disabled.
|
|
1333
|
+
* @param calendar Calendar system to use. Defaults to Gregorian; pass an adapter such as islamicCivilCalendar for native calendar fields.
|
|
1334
|
+
* @returns New timestamp with disabled metadata applied.
|
|
1335
|
+
* @category calendar
|
|
1336
|
+
*/
|
|
1337
|
+
export declare function updateCalendarDisabled(timestamp: Timestamp, disabledBefore?: string, disabledAfter?: string, disabledWeekdays?: number[], disabledDays?: DisabledDays, calendar?: CalendarSystem): Timestamp;
|
|
1338
|
+
/**
|
|
1339
|
+
* Resolves selected-date and selected-range state for a calendar timestamp.
|
|
1340
|
+
*
|
|
1341
|
+
* The default Gregorian calendar preserves existing Timestamp behavior. When
|
|
1342
|
+
* an alternate calendar is supplied, selected date strings are parsed as native
|
|
1343
|
+
* adapter dates.
|
|
1344
|
+
*
|
|
1345
|
+
* @param timestamp Timestamp to inspect.
|
|
1346
|
+
* @param options Selected dates and selected start/end dates.
|
|
1347
|
+
* @param calendar Calendar system to use. Defaults to Gregorian; pass an adapter such as islamicCivilCalendar for native calendar fields.
|
|
1348
|
+
* @returns Selected-date state for the timestamp.
|
|
1349
|
+
* @category calendar
|
|
1350
|
+
*/
|
|
1351
|
+
export declare function getCalendarSelectionState(timestamp: Timestamp, options?: CalendarSelectionOptions, calendar?: CalendarSystem): CalendarSelectionState;
|
|
1352
|
+
/**
|
|
1353
|
+
* Resolves disabled, selected, identity, and outside-month state for one date.
|
|
1354
|
+
*
|
|
1355
|
+
* @param timestamp Timestamp to resolve.
|
|
1356
|
+
* @param options Calendar-aware disabled, selection, and outside-month options.
|
|
1357
|
+
* @param calendar Calendar system to use. Defaults to Gregorian; pass an adapter such as islamicCivilCalendar for native calendar fields.
|
|
1358
|
+
* @returns Calendar date state suitable for component scopes.
|
|
1359
|
+
* @category calendar
|
|
1360
|
+
*/
|
|
1361
|
+
export declare function getCalendarDateState(timestamp: Timestamp, options?: CalendarDateStateOptions, calendar?: CalendarSystem): CalendarDateState;
|
|
1362
|
+
/**
|
|
1363
|
+
* Creates native calendar month view state for component rendering.
|
|
1364
|
+
*
|
|
1365
|
+
* The returned `days` use adapter-native `YYYY-MM-DD` values, while each
|
|
1366
|
+
* state's identity also includes Gregorian interop metadata.
|
|
1367
|
+
*
|
|
1368
|
+
* @param timestamp Reference timestamp in the adapter calendar.
|
|
1369
|
+
* @param now Timestamp used to calculate relative flags.
|
|
1370
|
+
* @param calendar Calendar system to use. Defaults to Gregorian; pass an adapter such as islamicCivilCalendar for native calendar fields.
|
|
1371
|
+
* @param options Calendar-aware disabled, selection, weekday, and size options.
|
|
1372
|
+
* @returns Calendar month view state.
|
|
1373
|
+
* @category calendar
|
|
1374
|
+
*/
|
|
1375
|
+
export declare function createCalendarMonthView(timestamp: Timestamp, now: Timestamp, calendar?: CalendarSystem, options?: CalendarMonthViewOptions): CalendarMonthView;
|
|
1038
1376
|
/**
|
|
1039
1377
|
* Updates the passed Timestamp with formatted data (time string, date string, weekday, day of year and workweek)
|
|
1040
1378
|
* @param {Timestamp} timestamp The Timestamp to transform
|
|
1379
|
+
* @param {CalendarSystem=} calendar Calendar system to use. Defaults to Gregorian; pass an adapter such as islamicCivilCalendar for native calendar fields.
|
|
1041
1380
|
* @returns A new Timestamp
|
|
1042
1381
|
* @category formatting
|
|
1043
1382
|
*/
|
|
1044
|
-
export declare function updateFormatted(timestamp: Timestamp): Timestamp;
|
|
1383
|
+
export declare function updateFormatted(timestamp: Timestamp, calendar?: CalendarSystem): Timestamp;
|
|
1045
1384
|
/**
|
|
1046
1385
|
* Returns day of the year (doy) for the passed in Timestamp
|
|
1047
1386
|
* @param {Timestamp} timestamp The Timestamp to use
|
|
1387
|
+
* @param {CalendarSystem=} calendar Calendar system to use. Defaults to Gregorian; pass an adapter such as islamicCivilCalendar for native calendar fields.
|
|
1048
1388
|
* @returns {number} The day of the year
|
|
1049
1389
|
* @category formatting
|
|
1050
1390
|
*/
|
|
1051
|
-
export declare function getDayOfYear(timestamp: Timestamp): number | void;
|
|
1391
|
+
export declare function getDayOfYear(timestamp: Timestamp, calendar?: CalendarSystem): number | void;
|
|
1052
1392
|
/**
|
|
1053
1393
|
* Returns workweek for the passed in Timestamp
|
|
1054
1394
|
* @param {Timestamp} timestamp The Timestamp to use
|
|
1395
|
+
* @param {CalendarSystem=} calendar Calendar system to use. Defaults to Gregorian; pass an adapter such as islamicCivilCalendar for native calendar fields.
|
|
1055
1396
|
* @returns {number} The work week
|
|
1056
1397
|
* @category formatting
|
|
1057
1398
|
*/
|
|
1058
|
-
export declare function getWorkWeek(timestamp: Timestamp): number;
|
|
1399
|
+
export declare function getWorkWeek(timestamp: Timestamp, calendar?: CalendarSystem): number;
|
|
1059
1400
|
/**
|
|
1060
1401
|
* Returns weekday for the passed in Timestamp
|
|
1061
1402
|
* @param {Timestamp} timestamp The Timestamp to use
|
|
1403
|
+
* @param {CalendarSystem=} calendar Calendar system to use. Defaults to Gregorian; pass an adapter such as islamicCivilCalendar for native calendar fields.
|
|
1062
1404
|
* @returns {number} The weekday
|
|
1063
1405
|
* @category formatting
|
|
1064
1406
|
*/
|
|
1065
|
-
export declare function getWeekday(timestamp: Timestamp): number;
|
|
1407
|
+
export declare function getWeekday(timestamp: Timestamp, calendar?: CalendarSystem): number;
|
|
1066
1408
|
/**
|
|
1067
1409
|
* Returns an immutable copy of a Timestamp object.
|
|
1068
1410
|
*
|
|
@@ -1088,21 +1430,23 @@ export declare function getStartOfDay(timestamp: Timestamp): Timestamp;
|
|
|
1088
1430
|
*/
|
|
1089
1431
|
export declare function getEndOfDay(timestamp: Timestamp): Timestamp;
|
|
1090
1432
|
/**
|
|
1091
|
-
* Returns a Timestamp at the start of the same
|
|
1433
|
+
* Returns a Timestamp at the start of the same calendar year.
|
|
1092
1434
|
*
|
|
1093
1435
|
* @param {Timestamp} timestamp Timestamp object to transform.
|
|
1094
|
-
* @
|
|
1436
|
+
* @param {CalendarSystem=} calendar Calendar system to use. Defaults to Gregorian; pass an adapter such as islamicCivilCalendar for native calendar fields.
|
|
1437
|
+
* @returns {Timestamp} New Timestamp for the first calendar day of the year at `00:00`.
|
|
1095
1438
|
* @category ranges
|
|
1096
1439
|
*/
|
|
1097
|
-
export declare function getStartOfYear(timestamp: Timestamp): Timestamp;
|
|
1440
|
+
export declare function getStartOfYear(timestamp: Timestamp, calendar?: CalendarSystem): Timestamp;
|
|
1098
1441
|
/**
|
|
1099
|
-
* Returns a Timestamp at the end of the same
|
|
1442
|
+
* Returns a Timestamp at the end of the same calendar year.
|
|
1100
1443
|
*
|
|
1101
1444
|
* @param {Timestamp} timestamp Timestamp object to transform.
|
|
1102
|
-
* @
|
|
1445
|
+
* @param {CalendarSystem=} calendar Calendar system to use. Defaults to Gregorian; pass an adapter such as islamicCivilCalendar for native calendar fields.
|
|
1446
|
+
* @returns {Timestamp} New Timestamp for the last calendar day of the year at `23:59:59.999`.
|
|
1103
1447
|
* @category ranges
|
|
1104
1448
|
*/
|
|
1105
|
-
export declare function getEndOfYear(timestamp: Timestamp): Timestamp;
|
|
1449
|
+
export declare function getEndOfYear(timestamp: Timestamp, calendar?: CalendarSystem): Timestamp;
|
|
1106
1450
|
/**
|
|
1107
1451
|
* Formats the date portion of a Timestamp object.
|
|
1108
1452
|
*
|
|
@@ -1136,30 +1480,33 @@ export declare function getDateTime(timestamp: Timestamp): string;
|
|
|
1136
1480
|
* @param {function} [mover=nextDay] The mover function to use (ie: {nextDay} or {prevDay}).
|
|
1137
1481
|
* @param {number} [days=1] The number of days to move.
|
|
1138
1482
|
* @param {number[]} [allowedWeekdays=[ 0, 1, 2, 3, 4, 5, 6 ]] An array of numbers representing the weekdays. ie: [0 = Sun, ..., 6 = Sat].
|
|
1483
|
+
* @param {CalendarSystem=} calendar Calendar system to use. Defaults to Gregorian; pass an adapter such as islamicCivilCalendar for native calendar fields.
|
|
1139
1484
|
* @returns A new Timestamp
|
|
1140
1485
|
* @category ranges
|
|
1141
1486
|
*/
|
|
1142
|
-
export declare function moveRelativeDays(timestamp: Timestamp, mover?: typeof nextDay, days?: number, allowedWeekdays?: number[]): Timestamp;
|
|
1487
|
+
export declare function moveRelativeDays(timestamp: Timestamp, mover?: typeof nextDay, days?: number, allowedWeekdays?: number[], calendar?: CalendarSystem): Timestamp;
|
|
1143
1488
|
/**
|
|
1144
1489
|
* Moves the Timestamp the number of relative days
|
|
1145
1490
|
* @param {Timestamp} timestamp The Timestamp to transform
|
|
1146
1491
|
* @param {function} [mover=nextDay] The mover function to use (ie: {nextDay} or {prevDay}).
|
|
1147
1492
|
* @param {number} [days=1] The number of days to move.
|
|
1148
1493
|
* @param {number[]} [allowedWeekdays=[ 0, 1, 2, 3, 4, 5, 6 ]] An array of numbers representing the weekdays. ie: [0 = Sun, ..., 6 = Sat].
|
|
1494
|
+
* @param {CalendarSystem=} calendar Calendar system to use. Defaults to Gregorian; pass an adapter such as islamicCivilCalendar for native calendar fields.
|
|
1149
1495
|
* @returns A new Timestamp
|
|
1150
1496
|
* @category ranges
|
|
1151
1497
|
*/
|
|
1152
|
-
export declare function relativeDays(timestamp: Timestamp, mover?: typeof nextDay, days?: number, allowedWeekdays?: number[]): Timestamp;
|
|
1498
|
+
export declare function relativeDays(timestamp: Timestamp, mover?: typeof nextDay, days?: number, allowedWeekdays?: number[], calendar?: CalendarSystem): Timestamp;
|
|
1153
1499
|
/**
|
|
1154
1500
|
* Finds the specified weekday (forward or back) based on the Timestamp
|
|
1155
1501
|
* @param {Timestamp} timestamp The Timestamp to transform
|
|
1156
1502
|
* @param {number} weekday The weekday number (Sun = 0, ..., Sat = 6)
|
|
1157
1503
|
* @param {function} [mover=nextDay] The function to use ({prevDay} or {nextDay}).
|
|
1158
1504
|
* @param {number} [maxDays=6] The number of days to look forward or back.
|
|
1505
|
+
* @param {CalendarSystem=} calendar Calendar system to use. Defaults to Gregorian; pass an adapter such as islamicCivilCalendar for native calendar fields.
|
|
1159
1506
|
* @returns A new Timestamp
|
|
1160
1507
|
* @category ranges
|
|
1161
1508
|
*/
|
|
1162
|
-
export declare function findWeekday(timestamp: Timestamp, weekday: number, mover?: typeof nextDay, maxDays?: number): Timestamp;
|
|
1509
|
+
export declare function findWeekday(timestamp: Timestamp, weekday: number, mover?: typeof nextDay, maxDays?: number, calendar?: CalendarSystem): Timestamp;
|
|
1163
1510
|
/**
|
|
1164
1511
|
* Creates an inclusive list of Timestamp days between start and end.
|
|
1165
1512
|
*
|
|
@@ -1176,10 +1523,11 @@ export declare function findWeekday(timestamp: Timestamp, weekday: number, mover
|
|
|
1176
1523
|
* @param {DisabledDays} [disabledDays] Specific dates or date ranges to mark disabled.
|
|
1177
1524
|
* @param {number} [max=42] Maximum number of days to return.
|
|
1178
1525
|
* @param {number} [min=0] Minimum number of days to return.
|
|
1526
|
+
* @param {CalendarSystem=} calendar Calendar system to use. Defaults to Gregorian; pass an adapter such as islamicCivilCalendar for native calendar fields.
|
|
1179
1527
|
* @returns {Timestamp[]} Timestamp days.
|
|
1180
1528
|
* @category ranges
|
|
1181
1529
|
*/
|
|
1182
|
-
export declare function createDayList(start: Timestamp, end: Timestamp, now: Timestamp, weekdays?: number[], disabledBefore?: string | undefined, disabledAfter?: string | undefined, disabledWeekdays?: number[], disabledDays?: DisabledDays, max?: number, min?: number): Timestamp[];
|
|
1530
|
+
export declare function createDayList(start: Timestamp, end: Timestamp, now: Timestamp, weekdays?: number[], disabledBefore?: string | undefined, disabledAfter?: string | undefined, disabledWeekdays?: number[], disabledDays?: DisabledDays, max?: number, min?: number, calendar?: CalendarSystem): Timestamp[];
|
|
1183
1531
|
/**
|
|
1184
1532
|
* Creates an array of interval Timestamp objects for one day.
|
|
1185
1533
|
*
|
|
@@ -1207,6 +1555,10 @@ export type WeekdayFormatter = (_weekday: keyof typeof weekdayDateMap, _type: st
|
|
|
1207
1555
|
* Function that formats a zero-based month number for a locale.
|
|
1208
1556
|
*/
|
|
1209
1557
|
export type MonthFormatter = (_month: number, _type?: string, _locale?: string) => string;
|
|
1558
|
+
/**
|
|
1559
|
+
* Function that formats a one-based calendar adapter month number for a locale.
|
|
1560
|
+
*/
|
|
1561
|
+
export type CalendarMonthFormatter = (_month: number, _type?: string, _locale?: string, _year?: number) => string;
|
|
1210
1562
|
/**
|
|
1211
1563
|
* Returns a host-local locale formatter backed by `Intl.DateTimeFormat`.
|
|
1212
1564
|
*
|
|
@@ -1245,7 +1597,7 @@ export declare function createNativeLocaleFormatterUTC(locale: string, cb: Local
|
|
|
1245
1597
|
* `calendar` option. The helper supplies `timeZone: "UTC"` unless the caller
|
|
1246
1598
|
* provides a different timezone.
|
|
1247
1599
|
*
|
|
1248
|
-
* @param calendar Calendar
|
|
1600
|
+
* @param calendar Calendar system to use. Defaults to Gregorian; pass an adapter such as islamicCivilCalendar for native calendar fields.
|
|
1249
1601
|
* @param locale The locale to use.
|
|
1250
1602
|
* @param cb Callback that returns Intl formatting options.
|
|
1251
1603
|
* @returns Function that formats a calendar timestamp.
|
|
@@ -1275,7 +1627,7 @@ export declare function makeDateUTC(timestamp: Timestamp): Date;
|
|
|
1275
1627
|
* can format the adapter date correctly when paired with a calendar option.
|
|
1276
1628
|
*
|
|
1277
1629
|
* @param timestamp Calendar timestamp object to convert.
|
|
1278
|
-
* @param calendar Calendar
|
|
1630
|
+
* @param calendar Calendar system to use. Defaults to Gregorian; pass an adapter such as islamicCivilCalendar for native calendar fields.
|
|
1279
1631
|
* @returns JavaScript Date object built with `Date.UTC()`.
|
|
1280
1632
|
* @category calendar
|
|
1281
1633
|
*/
|
|
@@ -1292,7 +1644,7 @@ export declare function makeDateTime(timestamp: Timestamp): Date;
|
|
|
1292
1644
|
* Converts an adapter calendar timestamp date-time into a UTC JavaScript Date.
|
|
1293
1645
|
*
|
|
1294
1646
|
* @param timestamp Calendar timestamp object to convert.
|
|
1295
|
-
* @param calendar Calendar
|
|
1647
|
+
* @param calendar Calendar system to use. Defaults to Gregorian; pass an adapter such as islamicCivilCalendar for native calendar fields.
|
|
1296
1648
|
* @returns JavaScript Date object built with `Date.UTC()`.
|
|
1297
1649
|
* @category calendar
|
|
1298
1650
|
*/
|
|
@@ -1521,8 +1873,9 @@ export interface AddToDateOptions {
|
|
|
1521
1873
|
* Adds or subtracts date/time units from a timestamp.
|
|
1522
1874
|
*
|
|
1523
1875
|
* This function returns a new frozen Timestamp; it does not mutate the
|
|
1524
|
-
* timestamp passed in.
|
|
1525
|
-
*
|
|
1876
|
+
* timestamp passed in. Gregorian dates are normalized through JavaScript Date
|
|
1877
|
+
* rules. Adapter-native dates use the supplied calendar system for year,
|
|
1878
|
+
* month, and day math.
|
|
1526
1879
|
*
|
|
1527
1880
|
* @param {Timestamp} timestamp Timestamp object to offset.
|
|
1528
1881
|
* @param {Object} options Date/time units to add or subtract.
|
|
@@ -1533,10 +1886,11 @@ export interface AddToDateOptions {
|
|
|
1533
1886
|
* @param {number=} options.minute If positive, adds minutes. If negative, removes minutes.
|
|
1534
1887
|
* @param {number=} options.second If positive, adds seconds. If negative, removes seconds.
|
|
1535
1888
|
* @param {number=} options.millisecond If positive, adds milliseconds. If negative, removes milliseconds.
|
|
1889
|
+
* @param {CalendarSystem=} calendar Calendar system to use. Defaults to Gregorian; pass an adapter such as islamicCivilCalendar for native calendar fields.
|
|
1536
1890
|
* @returns {Timestamp} New normalized Timestamp object.
|
|
1537
1891
|
* @category arithmetic
|
|
1538
1892
|
*/
|
|
1539
|
-
export declare function addToDate(timestamp: Timestamp, options: AddToDateOptions): Timestamp;
|
|
1893
|
+
export declare function addToDate(timestamp: Timestamp, options: AddToDateOptions, calendar?: CalendarSystem): Timestamp;
|
|
1540
1894
|
/**
|
|
1541
1895
|
* Adds or subtracts date/time units from a timestamp while clamping invalid
|
|
1542
1896
|
* target month days to the last valid day in the target month.
|
|
@@ -1558,10 +1912,11 @@ export declare function addToDate(timestamp: Timestamp, options: AddToDateOption
|
|
|
1558
1912
|
* @param {number=} options.minute If positive, adds minutes. If negative, removes minutes.
|
|
1559
1913
|
* @param {number=} options.second If positive, adds seconds. If negative, removes seconds.
|
|
1560
1914
|
* @param {number=} options.millisecond If positive, adds milliseconds. If negative, removes milliseconds.
|
|
1915
|
+
* @param {CalendarSystem=} calendar Calendar system to use. Defaults to Gregorian; pass an adapter such as islamicCivilCalendar for native calendar fields.
|
|
1561
1916
|
* @returns {Timestamp} New normalized Timestamp object.
|
|
1562
1917
|
* @category arithmetic
|
|
1563
1918
|
*/
|
|
1564
|
-
export declare function addToDateClamped(timestamp: Timestamp, options: AddToDateOptions): Timestamp;
|
|
1919
|
+
export declare function addToDateClamped(timestamp: Timestamp, options: AddToDateOptions, calendar?: CalendarSystem): Timestamp;
|
|
1565
1920
|
/**
|
|
1566
1921
|
* Returns number of days between two Timestamps
|
|
1567
1922
|
* @param {Timestamp} ts1 The first Timestamp
|
|
@@ -1708,6 +2063,19 @@ export declare function getWeekdayNames(type: string, locale: string): string[];
|
|
|
1708
2063
|
* @category locale
|
|
1709
2064
|
*/
|
|
1710
2065
|
export declare function getMonthFormatter(): MonthFormatter;
|
|
2066
|
+
/**
|
|
2067
|
+
* Returns a function that formats one-based calendar adapter month numbers.
|
|
2068
|
+
*
|
|
2069
|
+
* This is the calendar-aware counterpart to getMonthFormatter(). It converts
|
|
2070
|
+
* adapter fields through the adapter's epoch-day mapping, then asks Intl to
|
|
2071
|
+
* format the equivalent Gregorian Date with the adapter's Intl calendar id
|
|
2072
|
+
* when one is available.
|
|
2073
|
+
*
|
|
2074
|
+
* @param calendar Calendar system to use. Defaults to Gregorian; pass an adapter such as islamicCivilCalendar for native calendar fields.
|
|
2075
|
+
* @returns Function that formats one-based month numbers for the adapter.
|
|
2076
|
+
* @category calendar
|
|
2077
|
+
*/
|
|
2078
|
+
export declare function getCalendarMonthFormatter(calendar?: CalendarSystem): CalendarMonthFormatter;
|
|
1711
2079
|
/**
|
|
1712
2080
|
* Retrieves localized month names.
|
|
1713
2081
|
*
|
|
@@ -1717,4 +2085,19 @@ export declare function getMonthFormatter(): MonthFormatter;
|
|
|
1717
2085
|
* @category locale
|
|
1718
2086
|
*/
|
|
1719
2087
|
export declare function getMonthNames(type: string, locale: string): string[];
|
|
2088
|
+
/**
|
|
2089
|
+
* Retrieves localized month names for a calendar adapter.
|
|
2090
|
+
*
|
|
2091
|
+
* Month numbers are generated from `1` through `calendar.monthsInYear(year)`.
|
|
2092
|
+
* Pass a year when the calendar can have leap months or year-specific month
|
|
2093
|
+
* naming rules.
|
|
2094
|
+
*
|
|
2095
|
+
* @param calendar Calendar system to use. Defaults to Gregorian; pass an adapter such as islamicCivilCalendar for native calendar fields.
|
|
2096
|
+
* @param type Format type: `narrow`, `short`, or `long`.
|
|
2097
|
+
* @param locale Locale to use for formatting, such as `en-US`.
|
|
2098
|
+
* @param year Calendar year to sample. Defaults to `1`.
|
|
2099
|
+
* @returns Localized month names in calendar-native order.
|
|
2100
|
+
* @category calendar
|
|
2101
|
+
*/
|
|
2102
|
+
export declare function getCalendarMonthNames(calendar?: CalendarSystem, type?: string, locale?: string, year?: number): string[];
|
|
1720
2103
|
//# sourceMappingURL=index.d.ts.map
|