@formkit/tempo 0.1.2 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (178) hide show
  1. package/README.md +22 -1
  2. package/dist/add.d.ts +11 -0
  3. package/dist/add.mjs +50 -0
  4. package/dist/add.mjs.map +1 -0
  5. package/dist/addDay.d.ts +4 -3
  6. package/dist/addDay.mjs.map +1 -1
  7. package/dist/addHour.d.ts +4 -3
  8. package/dist/addHour.mjs.map +1 -1
  9. package/dist/addMillisecond.d.ts +10 -0
  10. package/dist/addMillisecond.mjs +11 -0
  11. package/dist/addMillisecond.mjs.map +1 -0
  12. package/dist/addMinute.d.ts +5 -4
  13. package/dist/addMinute.mjs.map +1 -1
  14. package/dist/addMonth.d.ts +5 -5
  15. package/dist/addMonth.mjs +2 -12
  16. package/dist/addMonth.mjs.map +1 -1
  17. package/dist/addSecond.d.ts +4 -3
  18. package/dist/addSecond.mjs.map +1 -1
  19. package/dist/addYear.d.ts +5 -5
  20. package/dist/addYear.mjs +6 -12
  21. package/dist/addYear.mjs.map +1 -1
  22. package/dist/ap.mjs +1 -2
  23. package/dist/ap.mjs.map +1 -1
  24. package/dist/applyOffset.d.ts +5 -5
  25. package/dist/applyOffset.mjs +5 -11
  26. package/dist/applyOffset.mjs.map +1 -1
  27. package/dist/bundle.d.ts +365 -115
  28. package/dist/bundle.mjs +364 -180
  29. package/dist/bundle.mjs.map +1 -1
  30. package/dist/common.d.ts +27 -7
  31. package/dist/common.mjs +47 -42
  32. package/dist/common.mjs.map +1 -1
  33. package/dist/date.d.ts +2 -2
  34. package/dist/date.mjs +1 -3
  35. package/dist/date.mjs.map +1 -1
  36. package/dist/dayEnd.d.ts +3 -3
  37. package/dist/dayEnd.mjs.map +1 -1
  38. package/dist/dayOfYear.d.ts +3 -3
  39. package/dist/dayOfYear.mjs.map +1 -1
  40. package/dist/dayStart.d.ts +3 -3
  41. package/dist/dayStart.mjs +1 -1
  42. package/dist/dayStart.mjs.map +1 -1
  43. package/dist/diff.d.ts +38 -0
  44. package/dist/diff.mjs +86 -0
  45. package/dist/diff.mjs.map +1 -0
  46. package/dist/diffDays.d.ts +12 -5
  47. package/dist/diffDays.mjs +1 -0
  48. package/dist/diffDays.mjs.map +1 -1
  49. package/dist/diffHours.d.ts +12 -5
  50. package/dist/diffHours.mjs +1 -0
  51. package/dist/diffHours.mjs.map +1 -1
  52. package/dist/diffMilliseconds.d.ts +10 -4
  53. package/dist/diffMilliseconds.mjs.map +1 -1
  54. package/dist/diffMinutes.d.ts +11 -3
  55. package/dist/diffMinutes.mjs +5 -1
  56. package/dist/diffMinutes.mjs.map +1 -1
  57. package/dist/diffMonths.d.ts +10 -4
  58. package/dist/diffMonths.mjs.map +1 -1
  59. package/dist/diffSeconds.d.ts +12 -5
  60. package/dist/diffSeconds.mjs +5 -1
  61. package/dist/diffSeconds.mjs.map +1 -1
  62. package/dist/diffWeeks.d.ts +10 -3
  63. package/dist/diffWeeks.mjs.map +1 -1
  64. package/dist/diffYears.d.ts +10 -4
  65. package/dist/diffYears.mjs +4 -1
  66. package/dist/diffYears.mjs.map +1 -1
  67. package/dist/format.mjs +2 -3
  68. package/dist/format.mjs.map +1 -1
  69. package/dist/handleDateOverflow.d.ts +12 -0
  70. package/dist/handleDateOverflow.mjs +18 -0
  71. package/dist/handleDateOverflow.mjs.map +1 -0
  72. package/dist/hourEnd.d.ts +3 -3
  73. package/dist/hourEnd.mjs.map +1 -1
  74. package/dist/hourStart.d.ts +3 -3
  75. package/dist/hourStart.mjs +1 -1
  76. package/dist/hourStart.mjs.map +1 -1
  77. package/dist/index.cjs +380 -183
  78. package/dist/index.cjs.map +1 -1
  79. package/dist/index.d.cts +365 -115
  80. package/dist/index.d.ts +14 -1
  81. package/dist/index.mjs +26 -0
  82. package/dist/index.mjs.map +1 -1
  83. package/dist/isAfter.d.ts +6 -6
  84. package/dist/isAfter.mjs.map +1 -1
  85. package/dist/isBefore.d.ts +5 -5
  86. package/dist/isBefore.mjs.map +1 -1
  87. package/dist/isEqual.d.ts +13 -4
  88. package/dist/isEqual.mjs.map +1 -1
  89. package/dist/isFuture.d.ts +10 -0
  90. package/dist/isFuture.mjs +9 -0
  91. package/dist/isFuture.mjs.map +1 -0
  92. package/dist/isPast.d.ts +10 -0
  93. package/dist/isPast.mjs +9 -0
  94. package/dist/isPast.mjs.map +1 -0
  95. package/dist/iso8601.d.ts +1 -1
  96. package/dist/iso8601.mjs +4 -7
  97. package/dist/iso8601.mjs.map +1 -1
  98. package/dist/minuteEnd.d.ts +3 -3
  99. package/dist/minuteEnd.mjs.map +1 -1
  100. package/dist/minuteStart.d.ts +3 -3
  101. package/dist/minuteStart.mjs +1 -1
  102. package/dist/minuteStart.mjs.map +1 -1
  103. package/dist/monthDays.d.ts +3 -3
  104. package/dist/monthDays.mjs.map +1 -1
  105. package/dist/monthEnd.d.ts +3 -3
  106. package/dist/monthEnd.mjs.map +1 -1
  107. package/dist/monthStart.d.ts +3 -3
  108. package/dist/monthStart.mjs +1 -1
  109. package/dist/monthStart.mjs.map +1 -1
  110. package/dist/nearestDay.d.ts +3 -3
  111. package/dist/nearestDay.mjs +2 -4
  112. package/dist/nearestDay.mjs.map +1 -1
  113. package/dist/offset.d.ts +5 -5
  114. package/dist/offset.mjs +16 -16
  115. package/dist/offset.mjs.map +1 -1
  116. package/dist/parse.mjs +33 -23
  117. package/dist/parse.mjs.map +1 -1
  118. package/dist/parts.mjs +14 -24
  119. package/dist/parts.mjs.map +1 -1
  120. package/dist/range.mjs +1 -2
  121. package/dist/range.mjs.map +1 -1
  122. package/dist/removeOffset.d.ts +4 -4
  123. package/dist/removeOffset.mjs.map +1 -1
  124. package/dist/sameDay.d.ts +8 -2
  125. package/dist/sameDay.mjs.map +1 -1
  126. package/dist/sameHour.d.ts +8 -2
  127. package/dist/sameHour.mjs.map +1 -1
  128. package/dist/sameMillisecond.d.ts +16 -0
  129. package/dist/sameMillisecond.mjs +11 -0
  130. package/dist/sameMillisecond.mjs.map +1 -0
  131. package/dist/sameMinute.d.ts +8 -2
  132. package/dist/sameMinute.mjs.map +1 -1
  133. package/dist/sameMonth.d.ts +16 -0
  134. package/dist/sameMonth.mjs +11 -0
  135. package/dist/sameMonth.mjs.map +1 -0
  136. package/dist/sameSecond.d.ts +8 -2
  137. package/dist/sameSecond.mjs.map +1 -1
  138. package/dist/sameYear.d.ts +8 -2
  139. package/dist/sameYear.mjs.map +1 -1
  140. package/dist/setDayOfMonth.d.ts +11 -0
  141. package/dist/setDayOfMonth.mjs +16 -0
  142. package/dist/setDayOfMonth.mjs.map +1 -0
  143. package/dist/setHour.d.ts +10 -0
  144. package/dist/setHour.mjs +11 -0
  145. package/dist/setHour.mjs.map +1 -0
  146. package/dist/setMilliseconds.d.ts +10 -0
  147. package/dist/setMilliseconds.mjs +11 -0
  148. package/dist/setMilliseconds.mjs.map +1 -0
  149. package/dist/setMinutes.d.ts +10 -0
  150. package/dist/setMinutes.mjs +11 -0
  151. package/dist/setMinutes.mjs.map +1 -0
  152. package/dist/setMonth.d.ts +11 -0
  153. package/dist/setMonth.mjs +9 -0
  154. package/dist/setMonth.mjs.map +1 -0
  155. package/dist/setSeconds.d.ts +10 -0
  156. package/dist/setSeconds.mjs +11 -0
  157. package/dist/setSeconds.mjs.map +1 -0
  158. package/dist/setYear.d.ts +11 -0
  159. package/dist/setYear.mjs +9 -0
  160. package/dist/setYear.mjs.map +1 -0
  161. package/dist/types.d.ts +29 -7
  162. package/dist/tzDate.d.ts +5 -3
  163. package/dist/tzDate.mjs.map +1 -1
  164. package/dist/weekEnd.d.ts +4 -4
  165. package/dist/weekEnd.mjs +1 -1
  166. package/dist/weekEnd.mjs.map +1 -1
  167. package/dist/weekStart.d.ts +4 -4
  168. package/dist/weekStart.mjs +2 -3
  169. package/dist/weekStart.mjs.map +1 -1
  170. package/dist/yearDays.d.ts +3 -3
  171. package/dist/yearDays.mjs.map +1 -1
  172. package/dist/yearEnd.d.ts +3 -3
  173. package/dist/yearEnd.mjs +1 -2
  174. package/dist/yearEnd.mjs.map +1 -1
  175. package/dist/yearStart.d.ts +3 -3
  176. package/dist/yearStart.mjs +2 -3
  177. package/dist/yearStart.mjs.map +1 -1
  178. package/package.json +32 -23
package/README.md CHANGED
@@ -10,7 +10,28 @@ Tempo is a new library in a proud tradition of JavaScript date and time librarie
10
10
 
11
11
  Tempo is best thought of as a collection of utilities for working with `Date` objects — an important distinction from other libraries that provide custom date primitives. Under the hood, Tempo mines JavaScript's `Intl.DateTimeFormat` to extract complex data like timezones offsets and locale aware date formats giving you a simple API to format, parse, and manipulates dates.
12
12
 
13
- Tempo is tiny tree-shakable framework, you can only take what you need. All functionality is available in **5.2 kB for esm** and **5.5 kB for cjs** modules (minified and brotlied). [Size Limit](https://github.com/ai/size-limit) controls the size.
13
+ Tempo is tiny tree-shakable framework, you can only take what you need. You can work with timezones with only a few bytes of library code, or perform full international date formatting for ~2Kb (minified and brotlied). [Size Limit](https://github.com/ai/size-limit) controls the size.
14
+
15
+ ## Development
16
+
17
+ Install from the repository root with `pnpm`:
18
+
19
+ ```bash
20
+ corepack enable
21
+ pnpm install
22
+ ```
23
+
24
+ Build the library:
25
+
26
+ ```bash
27
+ pnpm build
28
+ ```
29
+
30
+ Build the docs app:
31
+
32
+ ```bash
33
+ pnpm docs-build
34
+ ```
14
35
 
15
36
  <a href="https://tempo.formkit.com">
16
37
  <img src="docs/public/read-the-docs.png" alt="Read the docs" width="200" height="43">
package/dist/add.d.ts ADDED
@@ -0,0 +1,11 @@
1
+ import { MaybeDateInput, Duration } from './types.js';
2
+
3
+ /**
4
+ * Returns a new Date object with the duration applied.
5
+ * @param [inputDate] - A date to increment or null to increment from the current time.
6
+ * @param duration - An object with values for the amount of time to add to the original date.
7
+ * @param [dateOverflow] - Whether to allow month/year changes to overflow into a later month.
8
+ */
9
+ declare function add(inputDate: MaybeDateInput, duration: Duration, dateOverflow?: boolean): Date;
10
+
11
+ export { add };
package/dist/add.mjs ADDED
@@ -0,0 +1,50 @@
1
+ // src/add.ts
2
+ import { addDay } from "./addDay.mjs";
3
+ import { addHour } from "./addHour.mjs";
4
+ import { addMillisecond } from "./addMillisecond.mjs";
5
+ import { addMinute } from "./addMinute.mjs";
6
+ import { addMonth } from "./addMonth.mjs";
7
+ import { addSecond } from "./addSecond.mjs";
8
+ import { addYear } from "./addYear.mjs";
9
+ import { date } from "./date.mjs";
10
+ function add(inputDate, duration, dateOverflow = false) {
11
+ var _a, _b;
12
+ let d = date(inputDate);
13
+ const applyFixedUnits = () => {
14
+ if (duration.weeks) {
15
+ d = addDay(d, duration.weeks * 7);
16
+ }
17
+ if (duration.days) {
18
+ d = addDay(d, duration.days);
19
+ }
20
+ if (duration.hours) {
21
+ d = addHour(d, duration.hours);
22
+ }
23
+ if (duration.minutes) {
24
+ d = addMinute(d, duration.minutes);
25
+ }
26
+ if (duration.seconds) {
27
+ d = addSecond(d, duration.seconds);
28
+ }
29
+ if (duration.milliseconds) {
30
+ d = addMillisecond(d, duration.milliseconds);
31
+ }
32
+ };
33
+ const applyCalendarUnits = () => {
34
+ if (duration.months) {
35
+ d = addMonth(d, duration.months, dateOverflow);
36
+ }
37
+ if (duration.years) {
38
+ d = addYear(d, duration.years, dateOverflow);
39
+ }
40
+ };
41
+ const calendarFirst = ((_a = duration.months) != null ? _a : 0) < 0 || ((_b = duration.years) != null ? _b : 0) < 0;
42
+ if (calendarFirst) applyCalendarUnits();
43
+ applyFixedUnits();
44
+ if (!calendarFirst) applyCalendarUnits();
45
+ return d;
46
+ }
47
+ export {
48
+ add
49
+ };
50
+ //# sourceMappingURL=add.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/add.ts"],"sourcesContent":["import { addDay } from \"./addDay\"\nimport { addHour } from \"./addHour\"\nimport { addMillisecond } from \"./addMillisecond\"\nimport { addMinute } from \"./addMinute\"\nimport { addMonth } from \"./addMonth\"\nimport { addSecond } from \"./addSecond\"\nimport { addYear } from \"./addYear\"\nimport { date } from \"./date\"\nimport type { Duration, MaybeDateInput } from \"./types\"\n\n/**\n * Returns a new Date object with the duration applied.\n * @param [inputDate] - A date to increment or null to increment from the current time.\n * @param duration - An object with values for the amount of time to add to the original date.\n * @param [dateOverflow] - Whether to allow month/year changes to overflow into a later month.\n */\nexport function add(\n inputDate: MaybeDateInput,\n duration: Duration,\n dateOverflow = false\n) {\n let d = date(inputDate)\n const applyFixedUnits = () => {\n if (duration.weeks) {\n d = addDay(d, duration.weeks * 7)\n }\n if (duration.days) {\n d = addDay(d, duration.days)\n }\n if (duration.hours) {\n d = addHour(d, duration.hours)\n }\n if (duration.minutes) {\n d = addMinute(d, duration.minutes)\n }\n if (duration.seconds) {\n d = addSecond(d, duration.seconds)\n }\n if (duration.milliseconds) {\n d = addMillisecond(d, duration.milliseconds)\n }\n }\n const applyCalendarUnits = () => {\n if (duration.months) {\n d = addMonth(d, duration.months, dateOverflow)\n }\n if (duration.years) {\n d = addYear(d, duration.years, dateOverflow)\n }\n }\n const calendarFirst = (duration.months ?? 0) < 0 || (duration.years ?? 0) < 0\n\n if (calendarFirst) applyCalendarUnits()\n applyFixedUnits()\n if (!calendarFirst) applyCalendarUnits()\n\n return d\n}\n"],"mappings":";AAAA,SAAS,cAAc;AACvB,SAAS,eAAe;AACxB,SAAS,sBAAsB;AAC/B,SAAS,iBAAiB;AAC1B,SAAS,gBAAgB;AACzB,SAAS,iBAAiB;AAC1B,SAAS,eAAe;AACxB,SAAS,YAAY;AASd,SAAS,IACd,WACA,UACA,eAAe,OACf;AApBF;AAqBE,MAAI,IAAI,KAAK,SAAS;AACtB,QAAM,kBAAkB,MAAM;AAC5B,QAAI,SAAS,OAAO;AAClB,UAAI,OAAO,GAAG,SAAS,QAAQ,CAAC;AAAA,IAClC;AACA,QAAI,SAAS,MAAM;AACjB,UAAI,OAAO,GAAG,SAAS,IAAI;AAAA,IAC7B;AACA,QAAI,SAAS,OAAO;AAClB,UAAI,QAAQ,GAAG,SAAS,KAAK;AAAA,IAC/B;AACA,QAAI,SAAS,SAAS;AACpB,UAAI,UAAU,GAAG,SAAS,OAAO;AAAA,IACnC;AACA,QAAI,SAAS,SAAS;AACpB,UAAI,UAAU,GAAG,SAAS,OAAO;AAAA,IACnC;AACA,QAAI,SAAS,cAAc;AACzB,UAAI,eAAe,GAAG,SAAS,YAAY;AAAA,IAC7C;AAAA,EACF;AACA,QAAM,qBAAqB,MAAM;AAC/B,QAAI,SAAS,QAAQ;AACnB,UAAI,SAAS,GAAG,SAAS,QAAQ,YAAY;AAAA,IAC/C;AACA,QAAI,SAAS,OAAO;AAClB,UAAI,QAAQ,GAAG,SAAS,OAAO,YAAY;AAAA,IAC7C;AAAA,EACF;AACA,QAAM,kBAAiB,cAAS,WAAT,YAAmB,KAAK,OAAM,cAAS,UAAT,YAAkB,KAAK;AAE5E,MAAI,cAAe,oBAAmB;AACtC,kBAAgB;AAChB,MAAI,CAAC,cAAe,oBAAmB;AAEvC,SAAO;AACT;","names":[]}
package/dist/addDay.d.ts CHANGED
@@ -1,9 +1,10 @@
1
- import { DateInput } from './types.js';
1
+ import { MaybeDateInput } from './types.js';
2
2
 
3
3
  /**
4
4
  * Returns a new date object 1/n days after the original one.
5
- * @param inputDate - A date to increment by 1 day.
5
+ * @param [inputDate] - A date to increment or null to increment from the current time.
6
+ * @param [count] - The quantity to add.
6
7
  */
7
- declare function addDay(inputDate: DateInput, count?: number): Date;
8
+ declare function addDay(inputDate?: MaybeDateInput, count?: number): Date;
8
9
 
9
10
  export { addDay };
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/addDay.ts"],"sourcesContent":["import { date } from \"./date\"\nimport type { DateInput } from \"./types\"\n\n/**\n * Returns a new date object 1/n days after the original one.\n * @param inputDate - A date to increment by 1 day.\n */\nexport function addDay(inputDate: DateInput, count = 1) {\n const d = date(inputDate)\n d.setDate(d.getDate() + count)\n return d\n}\n"],"mappings":";AAAA,SAAS,YAAY;AAOd,SAAS,OAAO,WAAsB,QAAQ,GAAG;AACtD,QAAM,IAAI,KAAK,SAAS;AACxB,IAAE,QAAQ,EAAE,QAAQ,IAAI,KAAK;AAC7B,SAAO;AACT;","names":[]}
1
+ {"version":3,"sources":["../src/addDay.ts"],"sourcesContent":["import { date } from \"./date\"\nimport type { MaybeDateInput } from \"./types\"\n\n/**\n * Returns a new date object 1/n days after the original one.\n * @param [inputDate] - A date to increment or null to increment from the current time.\n * @param [count] - The quantity to add.\n */\nexport function addDay(inputDate?: MaybeDateInput, count = 1) {\n const d = date(inputDate)\n d.setDate(d.getDate() + count)\n return d\n}\n"],"mappings":";AAAA,SAAS,YAAY;AAQd,SAAS,OAAO,WAA4B,QAAQ,GAAG;AAC5D,QAAM,IAAI,KAAK,SAAS;AACxB,IAAE,QAAQ,EAAE,QAAQ,IAAI,KAAK;AAC7B,SAAO;AACT;","names":[]}
package/dist/addHour.d.ts CHANGED
@@ -1,9 +1,10 @@
1
- import { DateInput } from './types.js';
1
+ import { MaybeDateInput } from './types.js';
2
2
 
3
3
  /**
4
4
  * Returns a new date object 1/n hours after the original one.
5
- * @param inputDate - A date to increment by 1 day.
5
+ * @param [inputDate] - A date to increment or null to increment from the current time.
6
+ * @param [count] - The quantity to add.
6
7
  */
7
- declare function addHour(inputDate: DateInput, count?: number): Date;
8
+ declare function addHour(inputDate?: MaybeDateInput, count?: number): Date;
8
9
 
9
10
  export { addHour };
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/addHour.ts"],"sourcesContent":["import { date } from \"./date\"\nimport type { DateInput } from \"./types\"\n\n/**\n * Returns a new date object 1/n hours after the original one.\n * @param inputDate - A date to increment by 1 day.\n */\nexport function addHour(inputDate: DateInput, count = 1) {\n const d = date(inputDate)\n d.setHours(d.getHours() + count)\n return d\n}\n"],"mappings":";AAAA,SAAS,YAAY;AAOd,SAAS,QAAQ,WAAsB,QAAQ,GAAG;AACvD,QAAM,IAAI,KAAK,SAAS;AACxB,IAAE,SAAS,EAAE,SAAS,IAAI,KAAK;AAC/B,SAAO;AACT;","names":[]}
1
+ {"version":3,"sources":["../src/addHour.ts"],"sourcesContent":["import { date } from \"./date\"\nimport type { MaybeDateInput } from \"./types\"\n\n/**\n * Returns a new date object 1/n hours after the original one.\n * @param [inputDate] - A date to increment or null to increment from the current time.\n * @param [count] - The quantity to add.\n */\nexport function addHour(inputDate?: MaybeDateInput, count = 1) {\n const d = date(inputDate)\n d.setHours(d.getHours() + count)\n return d\n}\n"],"mappings":";AAAA,SAAS,YAAY;AAQd,SAAS,QAAQ,WAA4B,QAAQ,GAAG;AAC7D,QAAM,IAAI,KAAK,SAAS;AACxB,IAAE,SAAS,EAAE,SAAS,IAAI,KAAK;AAC/B,SAAO;AACT;","names":[]}
@@ -0,0 +1,10 @@
1
+ import { MaybeDateInput } from './types.js';
2
+
3
+ /**
4
+ * Returns a new date object 1/n milliseconds after the original one.
5
+ * @param [inputDate] - A date to increment or null to increment from the current time.
6
+ * @param [count] - The quantity to add.
7
+ */
8
+ declare function addMillisecond(inputDate?: MaybeDateInput, count?: number): Date;
9
+
10
+ export { addMillisecond };
@@ -0,0 +1,11 @@
1
+ // src/addMillisecond.ts
2
+ import { date } from "./date.mjs";
3
+ function addMillisecond(inputDate, count = 1) {
4
+ const d = date(inputDate);
5
+ d.setMilliseconds(d.getMilliseconds() + count);
6
+ return d;
7
+ }
8
+ export {
9
+ addMillisecond
10
+ };
11
+ //# sourceMappingURL=addMillisecond.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/addMillisecond.ts"],"sourcesContent":["import { date } from \"./date\"\nimport type { MaybeDateInput } from \"./types\"\n\n/**\n * Returns a new date object 1/n milliseconds after the original one.\n * @param [inputDate] - A date to increment or null to increment from the current time.\n * @param [count] - The quantity to add.\n */\nexport function addMillisecond(inputDate?: MaybeDateInput, count = 1) {\n const d = date(inputDate)\n d.setMilliseconds(d.getMilliseconds() + count)\n return d\n}\n"],"mappings":";AAAA,SAAS,YAAY;AAQd,SAAS,eAAe,WAA4B,QAAQ,GAAG;AACpE,QAAM,IAAI,KAAK,SAAS;AACxB,IAAE,gBAAgB,EAAE,gBAAgB,IAAI,KAAK;AAC7C,SAAO;AACT;","names":[]}
@@ -1,9 +1,10 @@
1
- import { DateInput } from './types.js';
1
+ import { MaybeDateInput } from './types.js';
2
2
 
3
3
  /**
4
- * Returns a new date object 1/n seconds after the original one.
5
- * @param inputDate - A date to increment by 1 day.
4
+ * Returns a new date object 1/n minutes after the original one.
5
+ * @param [inputDate] - A date to increment or null to increment from the current time.
6
+ * @param [count] - The quantity to add.
6
7
  */
7
- declare function addMinute(inputDate: DateInput, count?: number): Date;
8
+ declare function addMinute(inputDate?: MaybeDateInput, count?: number): Date;
8
9
 
9
10
  export { addMinute };
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/addMinute.ts"],"sourcesContent":["import { date } from \"./date\"\nimport type { DateInput } from \"./types\"\n\n/**\n * Returns a new date object 1/n seconds after the original one.\n * @param inputDate - A date to increment by 1 day.\n */\nexport function addMinute(inputDate: DateInput, count = 1) {\n const d = date(inputDate)\n d.setMinutes(d.getMinutes() + count)\n return d\n}\n"],"mappings":";AAAA,SAAS,YAAY;AAOd,SAAS,UAAU,WAAsB,QAAQ,GAAG;AACzD,QAAM,IAAI,KAAK,SAAS;AACxB,IAAE,WAAW,EAAE,WAAW,IAAI,KAAK;AACnC,SAAO;AACT;","names":[]}
1
+ {"version":3,"sources":["../src/addMinute.ts"],"sourcesContent":["import { date } from \"./date\"\nimport type { DateInput, MaybeDateInput } from \"./types\"\n\n/**\n * Returns a new date object 1/n minutes after the original one.\n * @param [inputDate] - A date to increment or null to increment from the current time.\n * @param [count] - The quantity to add.\n */\nexport function addMinute(inputDate?: MaybeDateInput, count = 1) {\n const d = date(inputDate)\n d.setMinutes(d.getMinutes() + count)\n return d\n}\n"],"mappings":";AAAA,SAAS,YAAY;AAQd,SAAS,UAAU,WAA4B,QAAQ,GAAG;AAC/D,QAAM,IAAI,KAAK,SAAS;AACxB,IAAE,WAAW,EAAE,WAAW,IAAI,KAAK;AACnC,SAAO;AACT;","names":[]}
@@ -1,13 +1,13 @@
1
- import { DateInput } from './types.js';
1
+ import { MaybeDateInput } from './types.js';
2
2
 
3
3
  /**
4
4
  * Returns a new date object 1/n months after the original one. Keep in mind if you
5
5
  * start with a date late in a given month you could get a date after the next
6
6
  * month.
7
- * @param inputDate - A date to increment by 1 or more months.
8
- * @param count - The quantity to add.
9
- * @param dateOverflow - Whether or not to allow the date to overflow to another month if the inputDate’s month is out of range of the new month.
7
+ * @param [inputDate] - A date to increment or null to increment from the current time
8
+ * @param [count] - The quantity to add.
9
+ * @param [dateOverflow] - Whether or not to allow the date to overflow to another month if the inputDate’s month is out of range of the new month.
10
10
  */
11
- declare function addMonth(inputDate: DateInput, count?: number, dateOverflow?: boolean): Date;
11
+ declare function addMonth(inputDate?: MaybeDateInput, count?: number, dateOverflow?: boolean): Date;
12
12
 
13
13
  export { addMonth };
package/dist/addMonth.mjs CHANGED
@@ -1,17 +1,7 @@
1
1
  // src/addMonth.ts
2
- import { date } from "./date.mjs";
3
- import { monthDays } from "./monthDays.mjs";
2
+ import { handleOverflow } from "./handleDateOverflow.mjs";
4
3
  function addMonth(inputDate, count = 1, dateOverflow = false) {
5
- const d = date(inputDate);
6
- const dayOfMonth = d.getDate();
7
- if (!dateOverflow)
8
- d.setDate(1);
9
- d.setMonth(d.getMonth() + count);
10
- if (!dateOverflow) {
11
- const daysInMonth = monthDays(d);
12
- d.setDate(daysInMonth < dayOfMonth ? daysInMonth : dayOfMonth);
13
- }
14
- return d;
4
+ return handleOverflow(inputDate, (d) => d.setMonth(d.getMonth() + count), dateOverflow);
15
5
  }
16
6
  export {
17
7
  addMonth
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/addMonth.ts"],"sourcesContent":["import { date } from \"./date\"\nimport { monthDays } from \"./monthDays\"\nimport type { DateInput } from \"./types\"\n\n/**\n * Returns a new date object 1/n months after the original one. Keep in mind if you\n * start with a date late in a given month you could get a date after the next\n * month.\n * @param inputDate - A date to increment by 1 or more months.\n * @param count - The quantity to add.\n * @param dateOverflow - Whether or not to allow the date to overflow to another month if the inputDate’s month is out of range of the new month.\n */\nexport function addMonth(\n inputDate: DateInput,\n count = 1,\n dateOverflow = false\n) {\n const d = date(inputDate)\n const dayOfMonth = d.getDate()\n // If overflowing is disallowed, set the date back to the first of the month\n if (!dateOverflow) d.setDate(1)\n d.setMonth(d.getMonth() + count)\n\n // If overflowing is disallowed, we need to set the date back to the proper\n // day or the last day of the month.\n if (!dateOverflow) {\n const daysInMonth = monthDays(d)\n d.setDate(daysInMonth < dayOfMonth ? daysInMonth : dayOfMonth)\n }\n return d\n}\n"],"mappings":";AAAA,SAAS,YAAY;AACrB,SAAS,iBAAiB;AAWnB,SAAS,SACd,WACA,QAAQ,GACR,eAAe,OACf;AACA,QAAM,IAAI,KAAK,SAAS;AACxB,QAAM,aAAa,EAAE,QAAQ;AAE7B,MAAI,CAAC;AAAc,MAAE,QAAQ,CAAC;AAC9B,IAAE,SAAS,EAAE,SAAS,IAAI,KAAK;AAI/B,MAAI,CAAC,cAAc;AACjB,UAAM,cAAc,UAAU,CAAC;AAC/B,MAAE,QAAQ,cAAc,aAAa,cAAc,UAAU;AAAA,EAC/D;AACA,SAAO;AACT;","names":[]}
1
+ {"version":3,"sources":["../src/addMonth.ts"],"sourcesContent":["import { handleOverflow } from \"./handleDateOverflow\"\nimport type { MaybeDateInput } from \"./types\"\n\n/**\n * Returns a new date object 1/n months after the original one. Keep in mind if you\n * start with a date late in a given month you could get a date after the next\n * month.\n * @param [inputDate] - A date to increment or null to increment from the current time\n * @param [count] - The quantity to add.\n * @param [dateOverflow] - Whether or not to allow the date to overflow to another month if the inputDate’s month is out of range of the new month.\n */\nexport function addMonth(inputDate?: MaybeDateInput, count = 1, dateOverflow = false) {\n return handleOverflow(inputDate, (d) => d.setMonth(d.getMonth() + count), dateOverflow)\n}\n"],"mappings":";AAAA,SAAS,sBAAsB;AAWxB,SAAS,SAAS,WAA4B,QAAQ,GAAG,eAAe,OAAO;AACpF,SAAO,eAAe,WAAW,CAAC,MAAM,EAAE,SAAS,EAAE,SAAS,IAAI,KAAK,GAAG,YAAY;AACxF;","names":[]}
@@ -1,9 +1,10 @@
1
- import { DateInput } from './types.js';
1
+ import { MaybeDateInput } from './types.js';
2
2
 
3
3
  /**
4
4
  * Returns a new date object 1/n seconds after the original one.
5
- * @param inputDate - A date to increment by 1 day.
5
+ * @param [inputDate] - A date to increment or null to increment from the current time.
6
+ * @param [count] - The quantity to add.
6
7
  */
7
- declare function addSecond(inputDate: DateInput, count?: number): Date;
8
+ declare function addSecond(inputDate?: MaybeDateInput, count?: number): Date;
8
9
 
9
10
  export { addSecond };
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/addSecond.ts"],"sourcesContent":["import { date } from \"./date\"\nimport type { DateInput } from \"./types\"\n\n/**\n * Returns a new date object 1/n seconds after the original one.\n * @param inputDate - A date to increment by 1 day.\n */\nexport function addSecond(inputDate: DateInput, count = 1) {\n const d = date(inputDate)\n d.setSeconds(d.getSeconds() + count)\n return d\n}\n"],"mappings":";AAAA,SAAS,YAAY;AAOd,SAAS,UAAU,WAAsB,QAAQ,GAAG;AACzD,QAAM,IAAI,KAAK,SAAS;AACxB,IAAE,WAAW,EAAE,WAAW,IAAI,KAAK;AACnC,SAAO;AACT;","names":[]}
1
+ {"version":3,"sources":["../src/addSecond.ts"],"sourcesContent":["import { date } from \"./date\"\nimport type { MaybeDateInput } from \"./types\"\n\n/**\n * Returns a new date object 1/n seconds after the original one.\n * @param [inputDate] - A date to increment or null to increment from the current time.\n * @param [count] - The quantity to add.\n */\nexport function addSecond(inputDate?: MaybeDateInput, count = 1) {\n const d = date(inputDate)\n d.setSeconds(d.getSeconds() + count)\n return d\n}\n"],"mappings":";AAAA,SAAS,YAAY;AAQd,SAAS,UAAU,WAA4B,QAAQ,GAAG;AAC/D,QAAM,IAAI,KAAK,SAAS;AACxB,IAAE,WAAW,EAAE,WAAW,IAAI,KAAK;AACnC,SAAO;AACT;","names":[]}
package/dist/addYear.d.ts CHANGED
@@ -1,13 +1,13 @@
1
- import { DateInput } from './types.js';
1
+ import { MaybeDateInput } from './types.js';
2
2
 
3
3
  /**
4
4
  * Returns a new date object 1/n years after the original one. Keep in mind if
5
5
  * you start with a date late in a given month you could get a date after the
6
6
  * next month.
7
- * @param inputDate - A date to increment by 1 day.
8
- * @param count - The quantity of years add.
9
- * @param dateOverflow - Whether or not to allow the date to overflow to another month if the inputDate’s month is out of range of the new month.
7
+ * @param [inputDate] - A date to increment or null to increment from the current time.
8
+ * @param [count] - The quantity of years add.
9
+ * @param [dateOverflow] - Whether or not to allow the date to overflow to another month if the inputDate’s month is out of range of the new month.
10
10
  */
11
- declare function addYear(inputDate: DateInput, count?: number, dateOverflow?: boolean): Date;
11
+ declare function addYear(inputDate?: MaybeDateInput, count?: number, dateOverflow?: boolean): Date;
12
12
 
13
13
  export { addYear };
package/dist/addYear.mjs CHANGED
@@ -1,17 +1,11 @@
1
1
  // src/addYear.ts
2
- import { date } from "./date.mjs";
3
- import { monthDays } from "./monthDays.mjs";
2
+ import { handleOverflow } from "./handleDateOverflow.mjs";
4
3
  function addYear(inputDate, count = 1, dateOverflow = false) {
5
- const d = date(inputDate);
6
- const dayOfMonth = d.getDate();
7
- if (!dateOverflow)
8
- d.setDate(1);
9
- d.setFullYear(d.getFullYear() + count);
10
- if (!dateOverflow) {
11
- const daysInMonth = monthDays(d);
12
- d.setDate(daysInMonth < dayOfMonth ? daysInMonth : dayOfMonth);
13
- }
14
- return d;
4
+ return handleOverflow(
5
+ inputDate,
6
+ (d) => d.setFullYear(d.getFullYear() + count),
7
+ dateOverflow
8
+ );
15
9
  }
16
10
  export {
17
11
  addYear
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/addYear.ts"],"sourcesContent":["import { date } from \"./date\"\nimport { monthDays } from \"./monthDays\"\nimport type { DateInput } from \"./types\"\n\n/**\n * Returns a new date object 1/n years after the original one. Keep in mind if\n * you start with a date late in a given month you could get a date after the\n * next month.\n * @param inputDate - A date to increment by 1 day.\n * @param count - The quantity of years add.\n * @param dateOverflow - Whether or not to allow the date to overflow to another month if the inputDate’s month is out of range of the new month.\n */\nexport function addYear(inputDate: DateInput, count = 1, dateOverflow = false) {\n const d = date(inputDate)\n const dayOfMonth = d.getDate()\n // If overflowing is disallowed, set the date back to the first of the month\n if (!dateOverflow) d.setDate(1)\n\n d.setFullYear(d.getFullYear() + count)\n\n // If overflowing is disallowed, we need to set the date back to the proper\n // day or the last day of the month.\n if (!dateOverflow) {\n const daysInMonth = monthDays(d)\n d.setDate(daysInMonth < dayOfMonth ? daysInMonth : dayOfMonth)\n }\n return d\n}\n"],"mappings":";AAAA,SAAS,YAAY;AACrB,SAAS,iBAAiB;AAWnB,SAAS,QAAQ,WAAsB,QAAQ,GAAG,eAAe,OAAO;AAC7E,QAAM,IAAI,KAAK,SAAS;AACxB,QAAM,aAAa,EAAE,QAAQ;AAE7B,MAAI,CAAC;AAAc,MAAE,QAAQ,CAAC;AAE9B,IAAE,YAAY,EAAE,YAAY,IAAI,KAAK;AAIrC,MAAI,CAAC,cAAc;AACjB,UAAM,cAAc,UAAU,CAAC;AAC/B,MAAE,QAAQ,cAAc,aAAa,cAAc,UAAU;AAAA,EAC/D;AACA,SAAO;AACT;","names":[]}
1
+ {"version":3,"sources":["../src/addYear.ts"],"sourcesContent":["import { handleOverflow } from \"./handleDateOverflow\"\nimport type { MaybeDateInput } from \"./types\"\n\n/**\n * Returns a new date object 1/n years after the original one. Keep in mind if\n * you start with a date late in a given month you could get a date after the\n * next month.\n * @param [inputDate] - A date to increment or null to increment from the current time.\n * @param [count] - The quantity of years add.\n * @param [dateOverflow] - Whether or not to allow the date to overflow to another month if the inputDate’s month is out of range of the new month.\n */\nexport function addYear(inputDate?: MaybeDateInput, count = 1, dateOverflow = false) {\n return handleOverflow(\n inputDate,\n (d) => d.setFullYear(d.getFullYear() + count),\n dateOverflow\n )\n}\n"],"mappings":";AAAA,SAAS,sBAAsB;AAWxB,SAAS,QAAQ,WAA4B,QAAQ,GAAG,eAAe,OAAO;AACnF,SAAO;AAAA,IACL;AAAA,IACA,CAAC,MAAM,EAAE,YAAY,EAAE,YAAY,IAAI,KAAK;AAAA,IAC5C;AAAA,EACF;AACF;","names":[]}
package/dist/ap.mjs CHANGED
@@ -2,8 +2,7 @@
2
2
  import { dayPeriodMap, specDate, normStr } from "./common.mjs";
3
3
  function ap(ampm, locale) {
4
4
  const l = dayPeriodMap.get(locale);
5
- if (l && l[ampm])
6
- return l[ampm];
5
+ if (l && l[ampm]) return l[ampm];
7
6
  const specimen = new Date(specDate);
8
7
  specimen.setUTCHours(ampm === "am" ? 5 : 20);
9
8
  const subparts = new Intl.DateTimeFormat(locale, {
package/dist/ap.mjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/ap.ts"],"sourcesContent":["import { dayPeriodMap, specDate, normStr } from \"./common\"\n\n/**\n * Determines the correct value for am/pm by locale and memoizes it.\n * @param ampm - am or pm\n * @param locale - The locale to fetch.\n */\nexport function ap(ampm: \"am\" | \"pm\", locale: string): string {\n const l = dayPeriodMap.get(locale)\n if (l && l[ampm]) return l[ampm] as string\n const specimen = new Date(specDate)\n specimen.setUTCHours(ampm === \"am\" ? 5 : 20)\n const subparts = new Intl.DateTimeFormat(locale, {\n timeStyle: \"full\",\n timeZone: \"UTC\",\n hour12: true,\n })\n .formatToParts(specimen)\n .map(normStr)\n const period = subparts.find((part) => part.type === \"dayPeriod\")\n if (period) {\n const localePeriods: { am?: string; pm?: string } = l || {}\n dayPeriodMap.set(\n locale,\n Object.assign(localePeriods, { [ampm]: period.value })\n )\n return period.value\n }\n return ampm\n}\n"],"mappings":";AAAA,SAAS,cAAc,UAAU,eAAe;AAOzC,SAAS,GAAG,MAAmB,QAAwB;AAC5D,QAAM,IAAI,aAAa,IAAI,MAAM;AACjC,MAAI,KAAK,EAAE,IAAI;AAAG,WAAO,EAAE,IAAI;AAC/B,QAAM,WAAW,IAAI,KAAK,QAAQ;AAClC,WAAS,YAAY,SAAS,OAAO,IAAI,EAAE;AAC3C,QAAM,WAAW,IAAI,KAAK,eAAe,QAAQ;AAAA,IAC/C,WAAW;AAAA,IACX,UAAU;AAAA,IACV,QAAQ;AAAA,EACV,CAAC,EACE,cAAc,QAAQ,EACtB,IAAI,OAAO;AACd,QAAM,SAAS,SAAS,KAAK,CAAC,SAAS,KAAK,SAAS,WAAW;AAChE,MAAI,QAAQ;AACV,UAAM,gBAA8C,KAAK,CAAC;AAC1D,iBAAa;AAAA,MACX;AAAA,MACA,OAAO,OAAO,eAAe,EAAE,CAAC,IAAI,GAAG,OAAO,MAAM,CAAC;AAAA,IACvD;AACA,WAAO,OAAO;AAAA,EAChB;AACA,SAAO;AACT;","names":[]}
1
+ {"version":3,"sources":["../src/ap.ts"],"sourcesContent":["import { dayPeriodMap, specDate, normStr } from \"./common\"\n\n/**\n * Determines the correct value for am/pm by locale and memoizes it.\n * @param ampm - am or pm\n * @param locale - The locale to fetch.\n */\nexport function ap(ampm: \"am\" | \"pm\", locale: string): string {\n const l = dayPeriodMap.get(locale)\n if (l && l[ampm]) return l[ampm] as string\n const specimen = new Date(specDate)\n specimen.setUTCHours(ampm === \"am\" ? 5 : 20)\n const subparts = new Intl.DateTimeFormat(locale, {\n timeStyle: \"full\",\n timeZone: \"UTC\",\n hour12: true,\n })\n .formatToParts(specimen)\n .map(normStr)\n const period = subparts.find((part) => part.type === \"dayPeriod\")\n if (period) {\n const localePeriods: { am?: string; pm?: string } = l || {}\n dayPeriodMap.set(\n locale,\n Object.assign(localePeriods, { [ampm]: period.value })\n )\n return period.value\n }\n return ampm\n}\n"],"mappings":";AAAA,SAAS,cAAc,UAAU,eAAe;AAOzC,SAAS,GAAG,MAAmB,QAAwB;AAC5D,QAAM,IAAI,aAAa,IAAI,MAAM;AACjC,MAAI,KAAK,EAAE,IAAI,EAAG,QAAO,EAAE,IAAI;AAC/B,QAAM,WAAW,IAAI,KAAK,QAAQ;AAClC,WAAS,YAAY,SAAS,OAAO,IAAI,EAAE;AAC3C,QAAM,WAAW,IAAI,KAAK,eAAe,QAAQ;AAAA,IAC/C,WAAW;AAAA,IACX,UAAU;AAAA,IACV,QAAQ;AAAA,EACV,CAAC,EACE,cAAc,QAAQ,EACtB,IAAI,OAAO;AACd,QAAM,SAAS,SAAS,KAAK,CAAC,SAAS,KAAK,SAAS,WAAW;AAChE,MAAI,QAAQ;AACV,UAAM,gBAA8C,KAAK,CAAC;AAC1D,iBAAa;AAAA,MACX;AAAA,MACA,OAAO,OAAO,eAAe,EAAE,CAAC,IAAI,GAAG,OAAO,MAAM,CAAC;AAAA,IACvD;AACA,WAAO,OAAO;AAAA,EAChB;AACA,SAAO;AACT;","names":[]}
@@ -1,11 +1,11 @@
1
- import { DateInput } from './types.js';
1
+ import { MaybeDateInput } from './types.js';
2
2
 
3
3
  /**
4
4
  * Apply a given offset to a date, returning a new date with the offset
5
- * applied by adding or subtracting the given number of minutes.
6
- * @param dateInput - The date to apply the offset to.
7
- * @param offset - The offset to apply in the +-HHmm or +-HH:mm format.
5
+ * applied by adding or subtracting the given number of seconds.
6
+ * @param [dateInput] - The date to apply the offset to. (default: current time)
7
+ * @param [offset] - The offset to apply in the +-HHmm, +-HH:mm, +-HHmmss, or +-HH:mm:ss format.
8
8
  */
9
- declare function applyOffset(dateInput: DateInput, offset?: string): Date;
9
+ declare function applyOffset(dateInput?: MaybeDateInput, offset?: string): Date;
10
10
 
11
11
  export { applyOffset };
@@ -1,18 +1,12 @@
1
1
  // src/applyOffset.ts
2
2
  import { date } from "./date.mjs";
3
- import { fixedLengthByOffset, offsetToMins } from "./common.mjs";
3
+ import { fixedLengthByOffset, offsetToSecs } from "./common.mjs";
4
4
  function applyOffset(dateInput, offset = "+00:00") {
5
5
  const d = date(dateInput);
6
- const token = (() => {
7
- switch (fixedLengthByOffset(offset)) {
8
- case 5:
9
- return "ZZ";
10
- case 6:
11
- return "Z";
12
- }
13
- })();
14
- const timeDiffInMins = offsetToMins(offset, token);
15
- return new Date(d.getTime() + timeDiffInMins * 1e3 * 60);
6
+ const len = fixedLengthByOffset(offset);
7
+ const token = len === 5 || len === 8 ? "ZZ" : "Z";
8
+ const timeDiffInSecs = offsetToSecs(offset, token);
9
+ return new Date(d.getTime() + timeDiffInSecs * 1e3);
16
10
  }
17
11
  export {
18
12
  applyOffset
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/applyOffset.ts"],"sourcesContent":["import { date } from \"./date\"\nimport { TimezoneToken, fixedLengthByOffset, offsetToMins } from \"./common\"\nimport type { DateInput } from \"./types\"\n\n/**\n * Apply a given offset to a date, returning a new date with the offset\n * applied by adding or subtracting the given number of minutes.\n * @param dateInput - The date to apply the offset to.\n * @param offset - The offset to apply in the +-HHmm or +-HH:mm format.\n */\nexport function applyOffset(dateInput: DateInput, offset = \"+00:00\"): Date {\n const d = date(dateInput)\n const token = ((): TimezoneToken => {\n switch (fixedLengthByOffset(offset)) {\n case 5:\n return \"ZZ\"\n case 6:\n return \"Z\"\n }\n })()\n const timeDiffInMins = offsetToMins(offset, token)\n return new Date(d.getTime() + timeDiffInMins * 1000 * 60)\n}\n"],"mappings":";AAAA,SAAS,YAAY;AACrB,SAAwB,qBAAqB,oBAAoB;AAS1D,SAAS,YAAY,WAAsB,SAAS,UAAgB;AACzE,QAAM,IAAI,KAAK,SAAS;AACxB,QAAM,SAAS,MAAqB;AAClC,YAAQ,oBAAoB,MAAM,GAAG;AAAA,MACnC,KAAK;AACH,eAAO;AAAA,MACT,KAAK;AACH,eAAO;AAAA,IACX;AAAA,EACF,GAAG;AACH,QAAM,iBAAiB,aAAa,QAAQ,KAAK;AACjD,SAAO,IAAI,KAAK,EAAE,QAAQ,IAAI,iBAAiB,MAAO,EAAE;AAC1D;","names":[]}
1
+ {"version":3,"sources":["../src/applyOffset.ts"],"sourcesContent":["import { date } from \"./date\"\nimport { TimezoneToken, fixedLengthByOffset, offsetToSecs } from \"./common\"\nimport type { MaybeDateInput } from \"./types\"\n\n/**\n * Apply a given offset to a date, returning a new date with the offset\n * applied by adding or subtracting the given number of seconds.\n * @param [dateInput] - The date to apply the offset to. (default: current time)\n * @param [offset] - The offset to apply in the +-HHmm, +-HH:mm, +-HHmmss, or +-HH:mm:ss format.\n */\nexport function applyOffset(dateInput?: MaybeDateInput, offset = \"+00:00\"): Date {\n const d = date(dateInput)\n const len = fixedLengthByOffset(offset)\n // 5 or 8 chars = no colons (ZZ format), 6 or 9 chars = with colons (Z format)\n const token: TimezoneToken = len === 5 || len === 8 ? \"ZZ\" : \"Z\"\n const timeDiffInSecs = offsetToSecs(offset, token)\n return new Date(d.getTime() + timeDiffInSecs * 1000)\n}\n"],"mappings":";AAAA,SAAS,YAAY;AACrB,SAAwB,qBAAqB,oBAAoB;AAS1D,SAAS,YAAY,WAA4B,SAAS,UAAgB;AAC/E,QAAM,IAAI,KAAK,SAAS;AACxB,QAAM,MAAM,oBAAoB,MAAM;AAEtC,QAAM,QAAuB,QAAQ,KAAK,QAAQ,IAAI,OAAO;AAC7D,QAAM,iBAAiB,aAAa,QAAQ,KAAK;AACjD,SAAO,IAAI,KAAK,EAAE,QAAQ,IAAI,iBAAiB,GAAI;AACrD;","names":[]}