@internationalized/date 3.12.0 → 3.12.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (204) hide show
  1. package/dist/index.cjs +113 -0
  2. package/dist/index.cjs.map +1 -0
  3. package/dist/index.js +45 -0
  4. package/dist/index.js.map +1 -0
  5. package/dist/index.mjs +45 -0
  6. package/dist/index.mjs.map +1 -0
  7. package/dist/private/CalendarDate.cjs +272 -0
  8. package/dist/private/CalendarDate.cjs.map +1 -0
  9. package/dist/private/CalendarDate.js +282 -0
  10. package/dist/private/CalendarDate.js.map +1 -0
  11. package/dist/private/CalendarDate.mjs +264 -0
  12. package/dist/private/CalendarDate.mjs.map +1 -0
  13. package/dist/{DateFormatter.main.js → private/DateFormatter.cjs} +31 -28
  14. package/dist/private/DateFormatter.cjs.map +1 -0
  15. package/dist/{DateFormatter.module.js → private/DateFormatter.js} +27 -24
  16. package/dist/private/DateFormatter.js.map +1 -0
  17. package/dist/{DateFormatter.mjs → private/DateFormatter.mjs} +31 -28
  18. package/dist/private/DateFormatter.mjs.map +1 -0
  19. package/dist/{BuddhistCalendar.main.js → private/calendars/BuddhistCalendar.cjs} +13 -13
  20. package/dist/{BuddhistCalendar.main.js.map → private/calendars/BuddhistCalendar.cjs.map} +1 -1
  21. package/dist/{BuddhistCalendar.module.js → private/calendars/BuddhistCalendar.js} +13 -13
  22. package/dist/{BuddhistCalendar.module.js.map → private/calendars/BuddhistCalendar.js.map} +1 -1
  23. package/dist/{BuddhistCalendar.mjs → private/calendars/BuddhistCalendar.mjs} +13 -13
  24. package/dist/private/calendars/BuddhistCalendar.mjs.map +1 -0
  25. package/dist/{EthiopicCalendar.main.js → private/calendars/EthiopicCalendar.cjs} +37 -37
  26. package/dist/private/calendars/EthiopicCalendar.cjs.map +1 -0
  27. package/dist/{EthiopicCalendar.module.js → private/calendars/EthiopicCalendar.js} +35 -35
  28. package/dist/private/calendars/EthiopicCalendar.js.map +1 -0
  29. package/dist/{EthiopicCalendar.mjs → private/calendars/EthiopicCalendar.mjs} +35 -35
  30. package/dist/private/calendars/EthiopicCalendar.mjs.map +1 -0
  31. package/dist/{GregorianCalendar.main.js → private/calendars/GregorianCalendar.cjs} +31 -31
  32. package/dist/private/calendars/GregorianCalendar.cjs.map +1 -0
  33. package/dist/{GregorianCalendar.module.js → private/calendars/GregorianCalendar.js} +27 -27
  34. package/dist/private/calendars/GregorianCalendar.js.map +1 -0
  35. package/dist/{GregorianCalendar.mjs → private/calendars/GregorianCalendar.mjs} +27 -27
  36. package/dist/private/calendars/GregorianCalendar.mjs.map +1 -0
  37. package/dist/{HebrewCalendar.main.js → private/calendars/HebrewCalendar.cjs} +44 -44
  38. package/dist/private/calendars/HebrewCalendar.cjs.map +1 -0
  39. package/dist/{HebrewCalendar.module.js → private/calendars/HebrewCalendar.js} +44 -44
  40. package/dist/private/calendars/HebrewCalendar.js.map +1 -0
  41. package/dist/{HebrewCalendar.mjs → private/calendars/HebrewCalendar.mjs} +44 -44
  42. package/dist/private/calendars/HebrewCalendar.mjs.map +1 -0
  43. package/dist/{IndianCalendar.main.js → private/calendars/IndianCalendar.cjs} +20 -20
  44. package/dist/private/calendars/IndianCalendar.cjs.map +1 -0
  45. package/dist/{IndianCalendar.module.js → private/calendars/IndianCalendar.js} +20 -20
  46. package/dist/private/calendars/IndianCalendar.js.map +1 -0
  47. package/dist/{IndianCalendar.mjs → private/calendars/IndianCalendar.mjs} +20 -20
  48. package/dist/private/calendars/IndianCalendar.mjs.map +1 -0
  49. package/dist/private/calendars/IslamicCalendar.cjs +168 -0
  50. package/dist/private/calendars/IslamicCalendar.cjs.map +1 -0
  51. package/dist/private/calendars/IslamicCalendar.js +161 -0
  52. package/dist/private/calendars/IslamicCalendar.js.map +1 -0
  53. package/dist/private/calendars/IslamicCalendar.mjs +161 -0
  54. package/dist/private/calendars/IslamicCalendar.mjs.map +1 -0
  55. package/dist/{JapaneseCalendar.main.js → private/calendars/JapaneseCalendar.cjs} +37 -37
  56. package/dist/private/calendars/JapaneseCalendar.cjs.map +1 -0
  57. package/dist/{JapaneseCalendar.module.js → private/calendars/JapaneseCalendar.js} +37 -37
  58. package/dist/private/calendars/JapaneseCalendar.js.map +1 -0
  59. package/dist/{JapaneseCalendar.mjs → private/calendars/JapaneseCalendar.mjs} +37 -37
  60. package/dist/private/calendars/JapaneseCalendar.mjs.map +1 -0
  61. package/dist/{PersianCalendar.main.js → private/calendars/PersianCalendar.cjs} +13 -13
  62. package/dist/private/calendars/PersianCalendar.cjs.map +1 -0
  63. package/dist/{PersianCalendar.module.js → private/calendars/PersianCalendar.js} +13 -13
  64. package/dist/private/calendars/PersianCalendar.js.map +1 -0
  65. package/dist/{PersianCalendar.mjs → private/calendars/PersianCalendar.mjs} +13 -13
  66. package/dist/private/calendars/PersianCalendar.mjs.map +1 -0
  67. package/dist/{TaiwanCalendar.main.js → private/calendars/TaiwanCalendar.cjs} +20 -20
  68. package/dist/{TaiwanCalendar.main.js.map → private/calendars/TaiwanCalendar.cjs.map} +1 -1
  69. package/dist/private/calendars/TaiwanCalendar.js +75 -0
  70. package/dist/{TaiwanCalendar.module.js.map → private/calendars/TaiwanCalendar.js.map} +1 -1
  71. package/dist/{TaiwanCalendar.mjs → private/calendars/TaiwanCalendar.mjs} +20 -20
  72. package/dist/private/calendars/TaiwanCalendar.mjs.map +1 -0
  73. package/dist/{conversion.main.js → private/conversion.cjs} +85 -85
  74. package/dist/private/conversion.cjs.map +1 -0
  75. package/dist/{conversion.module.js → private/conversion.js} +71 -71
  76. package/dist/private/conversion.js.map +1 -0
  77. package/dist/{conversion.mjs → private/conversion.mjs} +71 -71
  78. package/dist/private/conversion.mjs.map +1 -0
  79. package/dist/private/createCalendar.cjs +69 -0
  80. package/dist/private/createCalendar.cjs.map +1 -0
  81. package/dist/private/createCalendar.js +64 -0
  82. package/dist/private/createCalendar.js.map +1 -0
  83. package/dist/private/createCalendar.mjs +64 -0
  84. package/dist/private/createCalendar.mjs.map +1 -0
  85. package/dist/{manipulation.main.js → private/manipulation.cjs} +106 -109
  86. package/dist/private/manipulation.cjs.map +1 -0
  87. package/dist/{manipulation.mjs → private/manipulation.js} +88 -88
  88. package/dist/private/manipulation.js.map +1 -0
  89. package/dist/{manipulation.module.js → private/manipulation.mjs} +93 -96
  90. package/dist/private/manipulation.mjs.map +1 -0
  91. package/dist/private/queries.cjs +359 -0
  92. package/dist/private/queries.cjs.map +1 -0
  93. package/dist/private/queries.js +326 -0
  94. package/dist/private/queries.js.map +1 -0
  95. package/dist/private/queries.mjs +324 -0
  96. package/dist/private/queries.mjs.map +1 -0
  97. package/dist/private/string.cjs +181 -0
  98. package/dist/private/string.cjs.map +1 -0
  99. package/dist/{string.mjs → private/string.js} +64 -64
  100. package/dist/private/string.js.map +1 -0
  101. package/dist/private/string.mjs +166 -0
  102. package/dist/private/string.mjs.map +1 -0
  103. package/dist/{utils.main.js → private/utils.cjs} +3 -3
  104. package/dist/{utils.main.js.map → private/utils.cjs.map} +1 -1
  105. package/dist/{utils.module.js → private/utils.js} +3 -3
  106. package/dist/{utils.module.js.map → private/utils.js.map} +1 -1
  107. package/dist/{utils.mjs → private/utils.mjs} +3 -3
  108. package/dist/private/utils.mjs.map +1 -0
  109. package/dist/{weekStartData.main.js → private/weekStartData.cjs} +3 -3
  110. package/dist/{weekStartData.main.js.map → private/weekStartData.cjs.map} +1 -1
  111. package/dist/{weekStartData.module.js → private/weekStartData.js} +3 -3
  112. package/dist/{weekStartData.module.js.map → private/weekStartData.js.map} +1 -1
  113. package/dist/{weekStartData.mjs → private/weekStartData.mjs} +3 -3
  114. package/dist/private/weekStartData.mjs.map +1 -0
  115. package/dist/types/src/CalendarDate.d.ts +207 -0
  116. package/dist/types/src/DateFormatter.d.ts +24 -0
  117. package/dist/types/src/calendars/BuddhistCalendar.d.ts +16 -0
  118. package/dist/types/src/calendars/EthiopicCalendar.d.ts +45 -0
  119. package/dist/types/src/calendars/GregorianCalendar.d.ts +26 -0
  120. package/dist/types/src/calendars/HebrewCalendar.d.ts +21 -0
  121. package/dist/types/src/calendars/IndianCalendar.d.ts +17 -0
  122. package/dist/types/src/calendars/IslamicCalendar.d.ts +51 -0
  123. package/dist/types/src/calendars/JapaneseCalendar.d.ts +22 -0
  124. package/dist/types/src/calendars/PersianCalendar.d.ts +19 -0
  125. package/dist/types/src/calendars/TaiwanCalendar.d.ts +19 -0
  126. package/dist/types/src/conversion.d.ts +45 -0
  127. package/dist/types/src/createCalendar.d.ts +3 -0
  128. package/dist/types/src/index.d.ts +17 -0
  129. package/dist/types/src/manipulation.d.ts +25 -0
  130. package/dist/types/src/queries.d.ts +93 -0
  131. package/dist/types/src/string.d.ts +36 -0
  132. package/dist/types/src/types.d.ts +136 -0
  133. package/dist/types/src/utils.d.ts +4 -0
  134. package/dist/types/src/weekStartData.d.ts +97 -0
  135. package/package.json +33 -18
  136. package/src/CalendarDate.ts +215 -35
  137. package/src/DateFormatter.ts +36 -16
  138. package/src/calendars/BuddhistCalendar.ts +1 -6
  139. package/src/calendars/EthiopicCalendar.ts +6 -5
  140. package/src/calendars/GregorianCalendar.ts +11 -4
  141. package/src/calendars/HebrewCalendar.ts +8 -4
  142. package/src/calendars/IndianCalendar.ts +8 -3
  143. package/src/calendars/IslamicCalendar.ts +40 -25
  144. package/src/calendars/JapaneseCalendar.ts +18 -10
  145. package/src/calendars/PersianCalendar.ts +2 -4
  146. package/src/calendars/TaiwanCalendar.ts +2 -9
  147. package/src/conversion.ts +98 -25
  148. package/src/createCalendar.ts +10 -2
  149. package/src/index.ts +11 -2
  150. package/src/manipulation.ts +133 -30
  151. package/src/queries.ts +57 -15
  152. package/src/string.ts +52 -25
  153. package/src/types.ts +73 -51
  154. package/src/utils.ts +1 -1
  155. package/dist/CalendarDate.main.js +0 -260
  156. package/dist/CalendarDate.main.js.map +0 -1
  157. package/dist/CalendarDate.mjs +0 -252
  158. package/dist/CalendarDate.module.js +0 -252
  159. package/dist/CalendarDate.module.js.map +0 -1
  160. package/dist/DateFormatter.main.js.map +0 -1
  161. package/dist/DateFormatter.module.js.map +0 -1
  162. package/dist/EthiopicCalendar.main.js.map +0 -1
  163. package/dist/EthiopicCalendar.module.js.map +0 -1
  164. package/dist/GregorianCalendar.main.js.map +0 -1
  165. package/dist/GregorianCalendar.module.js.map +0 -1
  166. package/dist/HebrewCalendar.main.js.map +0 -1
  167. package/dist/HebrewCalendar.module.js.map +0 -1
  168. package/dist/IndianCalendar.main.js.map +0 -1
  169. package/dist/IndianCalendar.module.js.map +0 -1
  170. package/dist/IslamicCalendar.main.js +0 -168
  171. package/dist/IslamicCalendar.main.js.map +0 -1
  172. package/dist/IslamicCalendar.mjs +0 -161
  173. package/dist/IslamicCalendar.module.js +0 -161
  174. package/dist/IslamicCalendar.module.js.map +0 -1
  175. package/dist/JapaneseCalendar.main.js.map +0 -1
  176. package/dist/JapaneseCalendar.module.js.map +0 -1
  177. package/dist/PersianCalendar.main.js.map +0 -1
  178. package/dist/PersianCalendar.module.js.map +0 -1
  179. package/dist/TaiwanCalendar.module.js +0 -75
  180. package/dist/conversion.main.js.map +0 -1
  181. package/dist/conversion.module.js.map +0 -1
  182. package/dist/createCalendar.main.js +0 -69
  183. package/dist/createCalendar.main.js.map +0 -1
  184. package/dist/createCalendar.mjs +0 -64
  185. package/dist/createCalendar.module.js +0 -64
  186. package/dist/createCalendar.module.js.map +0 -1
  187. package/dist/import.mjs +0 -45
  188. package/dist/main.js +0 -113
  189. package/dist/main.js.map +0 -1
  190. package/dist/manipulation.main.js.map +0 -1
  191. package/dist/manipulation.module.js.map +0 -1
  192. package/dist/module.js +0 -45
  193. package/dist/module.js.map +0 -1
  194. package/dist/queries.main.js +0 -361
  195. package/dist/queries.main.js.map +0 -1
  196. package/dist/queries.mjs +0 -326
  197. package/dist/queries.module.js +0 -326
  198. package/dist/queries.module.js.map +0 -1
  199. package/dist/string.main.js +0 -190
  200. package/dist/string.main.js.map +0 -1
  201. package/dist/string.module.js +0 -175
  202. package/dist/string.module.js.map +0 -1
  203. package/dist/types.d.ts +0 -672
  204. package/dist/types.d.ts.map +0 -1
@@ -0,0 +1,93 @@
1
+ import { AnyCalendarDate, AnyTime, Calendar } from './types';
2
+ import { CalendarDate, CalendarDateTime, DateValue, ZonedDateTime } from './CalendarDate';
3
+ /** Returns whether the given dates occur on the same day, regardless of the time or calendar system. */
4
+ export declare function isSameDay(a: DateValue, b: DateValue): boolean;
5
+ /**
6
+ * Returns whether the given dates occur in the same month, using the calendar system of the first
7
+ * date.
8
+ */
9
+ export declare function isSameMonth(a: DateValue, b: DateValue): boolean;
10
+ /**
11
+ * Returns whether the given dates occur in the same year, using the calendar system of the first
12
+ * date.
13
+ */
14
+ export declare function isSameYear(a: DateValue, b: DateValue): boolean;
15
+ /** Returns whether the given dates occur on the same day, and are of the same calendar system. */
16
+ export declare function isEqualDay(a: DateValue, b: DateValue): boolean;
17
+ /** Returns whether the given dates occur in the same month, and are of the same calendar system. */
18
+ export declare function isEqualMonth(a: DateValue, b: DateValue): boolean;
19
+ /** Returns whether the given dates occur in the same year, and are of the same calendar system. */
20
+ export declare function isEqualYear(a: DateValue, b: DateValue): boolean;
21
+ /** Returns whether two calendars are the same. */
22
+ export declare function isEqualCalendar(a: Calendar, b: Calendar): boolean;
23
+ /** Returns whether the date is today in the given time zone. */
24
+ export declare function isToday(date: DateValue, timeZone: string): boolean;
25
+ type DayOfWeek = 'sun' | 'mon' | 'tue' | 'wed' | 'thu' | 'fri' | 'sat';
26
+ /**
27
+ * Returns the day of week for the given date and locale. Days are numbered from zero to six,
28
+ * where zero is the first day of the week in the given locale. For example, in the United States,
29
+ * the first day of the week is Sunday, but in France it is Monday.
30
+ */
31
+ export declare function getDayOfWeek(date: DateValue, locale: string, firstDayOfWeek?: DayOfWeek): number;
32
+ /** Returns the current time in the given time zone. */
33
+ export declare function now(timeZone: string): ZonedDateTime;
34
+ /** Returns today's date in the given time zone. */
35
+ export declare function today(timeZone: string): CalendarDate;
36
+ export declare function compareDate(a: AnyCalendarDate, b: AnyCalendarDate): number;
37
+ export declare function compareTime(a: AnyTime, b: AnyTime): number;
38
+ /**
39
+ * Returns the number of hours in the given date and time zone.
40
+ * Usually this is 24, but it could be 23 or 25 if the date is on a daylight saving transition.
41
+ */
42
+ export declare function getHoursInDay(a: CalendarDate, timeZone: string): number;
43
+ /** Returns the time zone identifier for the current user. */
44
+ export declare function getLocalTimeZone(): string;
45
+ /** Sets the time zone identifier for the current user. */
46
+ export declare function setLocalTimeZone(timeZone: string): void;
47
+ /** Resets the time zone identifier for the current user. */
48
+ export declare function resetLocalTimeZone(): void;
49
+ /** Returns whether the local time zone has been explicitly overridden via `setLocalTimeZone`. */
50
+ export declare function isLocalTimeZoneOverridden(): boolean;
51
+ /** Returns the first date of the month for the given date. */
52
+ export declare function startOfMonth(date: ZonedDateTime): ZonedDateTime;
53
+ export declare function startOfMonth(date: CalendarDateTime): CalendarDateTime;
54
+ export declare function startOfMonth(date: CalendarDate): CalendarDate;
55
+ export declare function startOfMonth(date: DateValue): DateValue;
56
+ /** Returns the last date of the month for the given date. */
57
+ export declare function endOfMonth(date: ZonedDateTime): ZonedDateTime;
58
+ export declare function endOfMonth(date: CalendarDateTime): CalendarDateTime;
59
+ export declare function endOfMonth(date: CalendarDate): CalendarDate;
60
+ export declare function endOfMonth(date: DateValue): DateValue;
61
+ /** Returns the first day of the year for the given date. */
62
+ export declare function startOfYear(date: ZonedDateTime): ZonedDateTime;
63
+ export declare function startOfYear(date: CalendarDateTime): CalendarDateTime;
64
+ export declare function startOfYear(date: CalendarDate): CalendarDate;
65
+ export declare function startOfYear(date: DateValue): DateValue;
66
+ /** Returns the last day of the year for the given date. */
67
+ export declare function endOfYear(date: ZonedDateTime): ZonedDateTime;
68
+ export declare function endOfYear(date: CalendarDateTime): CalendarDateTime;
69
+ export declare function endOfYear(date: CalendarDate): CalendarDate;
70
+ export declare function endOfYear(date: DateValue): DateValue;
71
+ export declare function getMinimumMonthInYear(date: AnyCalendarDate): number;
72
+ export declare function getMinimumDayInMonth(date: AnyCalendarDate): number;
73
+ /** Returns the first date of the week for the given date and locale. */
74
+ export declare function startOfWeek(date: ZonedDateTime, locale: string, firstDayOfWeek?: DayOfWeek): ZonedDateTime;
75
+ export declare function startOfWeek(date: CalendarDateTime, locale: string, firstDayOfWeek?: DayOfWeek): CalendarDateTime;
76
+ export declare function startOfWeek(date: CalendarDate, locale: string, firstDayOfWeek?: DayOfWeek): CalendarDate;
77
+ export declare function startOfWeek(date: DateValue, locale: string, firstDayOfWeek?: DayOfWeek): DateValue;
78
+ /** Returns the last date of the week for the given date and locale. */
79
+ export declare function endOfWeek(date: ZonedDateTime, locale: string, firstDayOfWeek?: DayOfWeek): ZonedDateTime;
80
+ export declare function endOfWeek(date: CalendarDateTime, locale: string, firstDayOfWeek?: DayOfWeek): CalendarDateTime;
81
+ export declare function endOfWeek(date: CalendarDate, locale: string, firstDayOfWeek?: DayOfWeek): CalendarDate;
82
+ export declare function endOfWeek(date: DateValue, locale: string, firstDayOfWeek?: DayOfWeek): DateValue;
83
+ /** Returns the number of weeks in the given month and locale. */
84
+ export declare function getWeeksInMonth(date: DateValue, locale: string, firstDayOfWeek?: DayOfWeek): number;
85
+ /** Returns the lesser of the two provider dates. */
86
+ export declare function minDate<A extends DateValue, B extends DateValue>(a?: A | null, b?: B | null): A | B | null | undefined;
87
+ /** Returns the greater of the two provider dates. */
88
+ export declare function maxDate<A extends DateValue, B extends DateValue>(a?: A | null, b?: B | null): A | B | null | undefined;
89
+ /** Returns whether the given date is on a weekend in the given locale. */
90
+ export declare function isWeekend(date: DateValue, locale: string): boolean;
91
+ /** Returns whether the given date is on a weekday in the given locale. */
92
+ export declare function isWeekday(date: DateValue, locale: string): boolean;
93
+ export {};
@@ -0,0 +1,36 @@
1
+ import { AnyDateTime, DateTimeDuration, Disambiguation } from './types';
2
+ import { CalendarDate, CalendarDateTime, Time, ZonedDateTime } from './CalendarDate';
3
+ /** Parses an ISO 8601 time string. */
4
+ export declare function parseTime(value: string): Time;
5
+ /** Parses an ISO 8601 date string, with no time components. */
6
+ export declare function parseDate(value: string): CalendarDate;
7
+ /** Parses an ISO 8601 date and time string, with no time zone. */
8
+ export declare function parseDateTime(value: string): CalendarDateTime;
9
+ /**
10
+ * Parses an ISO 8601 date and time string with a time zone extension and optional UTC offset (e.g.
11
+ * "2021-11-07T00:45[America/Los_Angeles]" or "2021-11-07T00:45-07:00[America/Los_Angeles]").
12
+ * Ambiguous times due to daylight saving time transitions are resolved according to the
13
+ * `disambiguation` parameter.
14
+ */
15
+ export declare function parseZonedDateTime(value: string, disambiguation?: Disambiguation): ZonedDateTime;
16
+ /**
17
+ * Parses an ISO 8601 date and time string with a UTC offset (e.g. "2021-11-07T07:45:00Z"
18
+ * or "2021-11-07T07:45:00-07:00"). The result is converted to the provided time zone.
19
+ */
20
+ export declare function parseAbsolute(value: string, timeZone: string): ZonedDateTime;
21
+ /**
22
+ * Parses an ISO 8601 date and time string with a UTC offset (e.g. "2021-11-07T07:45:00Z"
23
+ * or "2021-11-07T07:45:00-07:00"). The result is converted to the user's local time zone.
24
+ */
25
+ export declare function parseAbsoluteToLocal(value: string): ZonedDateTime;
26
+ export declare function timeToString(time: Time): string;
27
+ export declare function dateToString(date: CalendarDate): string;
28
+ export declare function dateTimeToString(date: AnyDateTime): string;
29
+ export declare function zonedDateTimeToString(date: ZonedDateTime): string;
30
+ /**
31
+ * Parses an ISO 8601 duration string (e.g. "P3Y6M6W4DT12H30M5S").
32
+ *
33
+ * @param value An ISO 8601 duration string.
34
+ * @returns A DateTimeDuration object.
35
+ */
36
+ export declare function parseDuration(value: string): Required<DateTimeDuration>;
@@ -0,0 +1,136 @@
1
+ import { CalendarDate } from './CalendarDate';
2
+ /** An interface that is compatible with any object with date fields. */
3
+ export interface AnyCalendarDate {
4
+ readonly calendar: Calendar;
5
+ readonly era: string;
6
+ readonly year: number;
7
+ readonly month: number;
8
+ readonly day: number;
9
+ copy(): this;
10
+ }
11
+ /** An interface that is compatible with any object with time fields. */
12
+ export interface AnyTime {
13
+ readonly hour: number;
14
+ readonly minute: number;
15
+ readonly second: number;
16
+ readonly millisecond: number;
17
+ copy(): this;
18
+ }
19
+ /** An interface that is compatible with any object with both date and time fields. */
20
+ export interface AnyDateTime extends AnyCalendarDate, AnyTime {
21
+ }
22
+ export type CalendarIdentifier = 'gregory' | 'buddhist' | 'chinese' | 'coptic' | 'dangi' | 'ethioaa' | 'ethiopic' | 'hebrew' | 'indian' | 'islamic' | 'islamic-umalqura' | 'islamic-tbla' | 'islamic-civil' | 'islamic-rgsa' | 'iso8601' | 'japanese' | 'persian' | 'roc';
23
+ /**
24
+ * The Calendar interface represents a calendar system, including information
25
+ * about how days, months, years, and eras are organized, and methods to perform
26
+ * arithmetic on dates.
27
+ */
28
+ export interface Calendar {
29
+ /**
30
+ * A string identifier for the calendar, as defined by Unicode CLDR. See
31
+ * [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/supportedValuesOf#supported_calendar_types).
32
+ */
33
+ identifier: CalendarIdentifier;
34
+ /** Creates a CalendarDate in this calendar from the given Julian day number. */
35
+ fromJulianDay(jd: number): CalendarDate;
36
+ /** Converts a date in this calendar to a Julian day number. */
37
+ toJulianDay(date: AnyCalendarDate): number;
38
+ /** Returns the number of days in the month of the given date. */
39
+ getDaysInMonth(date: AnyCalendarDate): number;
40
+ /** Returns the number of months in the year of the given date. */
41
+ getMonthsInYear(date: AnyCalendarDate): number;
42
+ /** Returns the number of years in the era of the given date. */
43
+ getYearsInEra(date: AnyCalendarDate): number;
44
+ /** Returns a list of era identifiers for the calendar. */
45
+ getEras(): string[];
46
+ /**
47
+ * Returns the minimum month number of the given date's year.
48
+ * Normally, this is 1, but in some calendars such as the Japanese,
49
+ * eras may begin in the middle of a year.
50
+ */
51
+ getMinimumMonthInYear?(date: AnyCalendarDate): number;
52
+ /**
53
+ * Returns the minimum day number of the given date's month.
54
+ * Normally, this is 1, but in some calendars such as the Japanese,
55
+ * eras may begin in the middle of a month.
56
+ */
57
+ getMinimumDayInMonth?(date: AnyCalendarDate): number;
58
+ /** Returns the maximum months across all years. */
59
+ getMaximumMonthsInYear(): number;
60
+ /** Returns the maximum days across all months. */
61
+ getMaximumDaysInMonth(): number;
62
+ /**
63
+ * Returns a date that is the first day of the month for the given date.
64
+ * This is used to determine the month that the given date falls in, if
65
+ * the calendar has months that do not align with the standard calendar months
66
+ * (e.g. fiscal calendars).
67
+ */
68
+ getFormattableMonth?(date: AnyCalendarDate): CalendarDate;
69
+ /** Returns whether the given calendar is the same as this calendar. */
70
+ isEqual?(calendar: Calendar): boolean;
71
+ /** @private */
72
+ balanceDate?(date: AnyCalendarDate): void;
73
+ /** @private */
74
+ balanceYearMonth?(date: AnyCalendarDate, previousDate: AnyCalendarDate): void;
75
+ /** @private */
76
+ constrainDate?(date: AnyCalendarDate): void;
77
+ /** @private */
78
+ isInverseEra?(date: AnyCalendarDate): boolean;
79
+ }
80
+ /** Represents an amount of time in calendar-specific units, for use when performing arithmetic. */
81
+ export interface DateDuration {
82
+ /** The number of years to add or subtract. */
83
+ years?: number;
84
+ /** The number of months to add or subtract. */
85
+ months?: number;
86
+ /** The number of weeks to add or subtract. */
87
+ weeks?: number;
88
+ /** The number of days to add or subtract. */
89
+ days?: number;
90
+ }
91
+ /** Represents an amount of time, for use whe performing arithmetic. */
92
+ export interface TimeDuration {
93
+ /** The number of hours to add or subtract. */
94
+ hours?: number;
95
+ /** The number of minutes to add or subtract. */
96
+ minutes?: number;
97
+ /** The number of seconds to add or subtract. */
98
+ seconds?: number;
99
+ /** The number of milliseconds to add or subtract. */
100
+ milliseconds?: number;
101
+ }
102
+ /**
103
+ * Represents an amount of time with both date and time components, for use when performing
104
+ * arithmetic.
105
+ */
106
+ export interface DateTimeDuration extends DateDuration, TimeDuration {
107
+ }
108
+ export interface DateFields {
109
+ era?: string;
110
+ year?: number;
111
+ month?: number;
112
+ day?: number;
113
+ }
114
+ export interface TimeFields {
115
+ hour?: number;
116
+ minute?: number;
117
+ second?: number;
118
+ millisecond?: number;
119
+ }
120
+ export type DateField = keyof DateFields;
121
+ export type TimeField = keyof TimeFields;
122
+ export type Disambiguation = 'compatible' | 'earlier' | 'later' | 'reject';
123
+ export interface CycleOptions {
124
+ /** Whether to round the field value to the nearest interval of the amount. */
125
+ round?: boolean;
126
+ }
127
+ export interface CycleTimeOptions extends CycleOptions {
128
+ /**
129
+ * Whether to use 12 or 24 hour time. If 12 hour time is chosen, the resulting value
130
+ * will remain in the same day period as the original value (e.g. if the value is AM,
131
+ * the resulting value also be AM).
132
+ *
133
+ * @default 24
134
+ */
135
+ hourCycle?: 12 | 24;
136
+ }
@@ -0,0 +1,4 @@
1
+ export type Mutable<T> = {
2
+ -readonly [P in keyof T]: T[P];
3
+ };
4
+ export declare function mod(amount: number, numerator: number): number;
@@ -0,0 +1,97 @@
1
+ export declare const weekStartData: {
2
+ '001': number;
3
+ AD: number;
4
+ AE: number;
5
+ AF: number;
6
+ AI: number;
7
+ AL: number;
8
+ AM: number;
9
+ AN: number;
10
+ AR: number;
11
+ AT: number;
12
+ AU: number;
13
+ AX: number;
14
+ AZ: number;
15
+ BA: number;
16
+ BE: number;
17
+ BG: number;
18
+ BH: number;
19
+ BM: number;
20
+ BN: number;
21
+ BY: number;
22
+ CH: number;
23
+ CL: number;
24
+ CM: number;
25
+ CN: number;
26
+ CR: number;
27
+ CY: number;
28
+ CZ: number;
29
+ DE: number;
30
+ DJ: number;
31
+ DK: number;
32
+ DZ: number;
33
+ EC: number;
34
+ EE: number;
35
+ EG: number;
36
+ ES: number;
37
+ FI: number;
38
+ FJ: number;
39
+ FO: number;
40
+ FR: number;
41
+ GB: number;
42
+ GE: number;
43
+ GF: number;
44
+ GP: number;
45
+ GR: number;
46
+ HR: number;
47
+ HU: number;
48
+ IE: number;
49
+ IQ: number;
50
+ IR: number;
51
+ IS: number;
52
+ IT: number;
53
+ JO: number;
54
+ KG: number;
55
+ KW: number;
56
+ KZ: number;
57
+ LB: number;
58
+ LI: number;
59
+ LK: number;
60
+ LT: number;
61
+ LU: number;
62
+ LV: number;
63
+ LY: number;
64
+ MC: number;
65
+ MD: number;
66
+ ME: number;
67
+ MK: number;
68
+ MN: number;
69
+ MQ: number;
70
+ MV: number;
71
+ MY: number;
72
+ NL: number;
73
+ NO: number;
74
+ NZ: number;
75
+ OM: number;
76
+ PL: number;
77
+ QA: number;
78
+ RE: number;
79
+ RO: number;
80
+ RS: number;
81
+ RU: number;
82
+ SD: number;
83
+ SE: number;
84
+ SI: number;
85
+ SK: number;
86
+ SM: number;
87
+ SY: number;
88
+ TJ: number;
89
+ TM: number;
90
+ TR: number;
91
+ UA: number;
92
+ UY: number;
93
+ UZ: number;
94
+ VA: number;
95
+ VN: number;
96
+ XK: number;
97
+ };
package/package.json CHANGED
@@ -1,35 +1,50 @@
1
1
  {
2
2
  "name": "@internationalized/date",
3
- "version": "3.12.0",
3
+ "version": "3.12.2",
4
4
  "description": "Internationalized calendar, date, and time manipulation utilities",
5
5
  "license": "Apache-2.0",
6
- "main": "dist/main.js",
7
- "module": "dist/module.js",
8
- "exports": {
9
- "source": "./src/index.ts",
10
- "types": [
11
- "./dist/types.d.ts",
12
- "./src/index.ts"
13
- ],
14
- "import": "./dist/import.mjs",
15
- "require": "./dist/main.js"
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/adobe/react-spectrum/tree/main/packages/@internationalized/date"
16
9
  },
17
- "types": "dist/types.d.ts",
18
10
  "source": "src/index.ts",
19
11
  "files": [
20
12
  "dist",
21
13
  "src"
22
14
  ],
23
15
  "sideEffects": false,
24
- "repository": {
25
- "type": "git",
26
- "url": "https://github.com/adobe/react-spectrum/tree/main/packages/@internationalized/date"
16
+ "main": "dist/index.cjs",
17
+ "module": "dist/index.js",
18
+ "types": "./dist/types/src/index.d.ts",
19
+ "exports": {
20
+ "source": "./src/index.ts",
21
+ "types": "./dist/types/src/index.d.ts",
22
+ "import": "./dist/index.mjs",
23
+ "require": "./dist/index.cjs"
24
+ },
25
+ "publishConfig": {
26
+ "access": "public"
27
27
  },
28
28
  "dependencies": {
29
29
  "@swc/helpers": "^0.5.0"
30
30
  },
31
- "publishConfig": {
32
- "access": "public"
31
+ "import": "dist/index.mjs",
32
+ "targets": {
33
+ "types": false,
34
+ "module": {
35
+ "engines": {
36
+ "browsers": [
37
+ "chrome >= 79",
38
+ "firefox >= 85",
39
+ "safari >= 13"
40
+ ]
41
+ }
42
+ },
43
+ "import": {
44
+ "isLibrary": true,
45
+ "outputFormat": "esmodule",
46
+ "includeNodeModules": false
47
+ }
33
48
  },
34
- "gitHead": "8df187370053aa35f553cb388ad670f65e1ab371"
49
+ "gitHead": "3577a20859b9585a000010c720f6ee39c1c588cc"
35
50
  }