@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
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/sameSecond.ts"],"sourcesContent":["import { date } from \"./date\"\nimport type { DateInput } from \"./types\"\n\n/**\n * Checks if two date objects refer to the same time seconds. Ignores date.\n * @param inputDateA - First date to compare\n * @param inputDateB - Second date to compare\n */\nexport function sameSecond(inputDateA: DateInput, inputDateB: DateInput) {\n const a = date(inputDateA)\n const b = date(inputDateB)\n return a.getSeconds() === b.getSeconds()\n}\n"],"mappings":";AAAA,SAAS,YAAY;AAQd,SAAS,WAAW,YAAuB,YAAuB;AACvE,QAAM,IAAI,KAAK,UAAU;AACzB,QAAM,IAAI,KAAK,UAAU;AACzB,SAAO,EAAE,WAAW,MAAM,EAAE,WAAW;AACzC;","names":[]}
1
+ {"version":3,"sources":["../src/sameSecond.ts"],"sourcesContent":["import { date } from \"./date\"\nimport type { DateInput, MaybeDateInput } from \"./types\"\n\n/**\n * Checks if two date objects refer to the same time seconds. Ignores date.\n * @param inputDateA - First date to compare\n * @param [inputDateB] - Second date to compare or the current time if nothing given\n */\nexport function sameSecond(inputDateA: DateInput, inputDateB?: MaybeDateInput): boolean\n/**\n * Checks if two date objects refer to the same time seconds. Ignores date.\n * @param [inputDateA] - First date to compare or the current time if null given\n * @param inputDateB - Second date to compare\n */\nexport function sameSecond(inputDateA: MaybeDateInput, inputDateB: DateInput): boolean\nexport function sameSecond(\n inputDateA: MaybeDateInput,\n inputDateB?: MaybeDateInput\n): boolean {\n const a = date(inputDateA)\n const b = date(inputDateB)\n return a.getSeconds() === b.getSeconds()\n}\n"],"mappings":";AAAA,SAAS,YAAY;AAed,SAAS,WACd,YACA,YACS;AACT,QAAM,IAAI,KAAK,UAAU;AACzB,QAAM,IAAI,KAAK,UAAU;AACzB,SAAO,EAAE,WAAW,MAAM,EAAE,WAAW;AACzC;","names":[]}
@@ -1,10 +1,16 @@
1
- import { DateInput } from './types.js';
1
+ import { DateInput, MaybeDateInput } from './types.js';
2
2
 
3
3
  /**
4
4
  * Checks if two date objects refer to the same year.
5
5
  * @param inputDateA - First date to compare
6
+ * @param [inputDateB] - Second date to compare or the current time if null given
7
+ */
8
+ declare function sameYear(inputDateA: DateInput, inputDateB?: MaybeDateInput): boolean;
9
+ /**
10
+ * Checks if two date objects refer to the same year.
11
+ * @param [inputDateA] - First date to compare or the current time if null given
6
12
  * @param inputDateB - Second date to compare
7
13
  */
8
- declare function sameYear(inputDateA: DateInput, inputDateB: DateInput): boolean;
14
+ declare function sameYear(inputDateA: MaybeDateInput, inputDateB: DateInput): boolean;
9
15
 
10
16
  export { sameYear };
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/sameYear.ts"],"sourcesContent":["import { date } from \"./date\"\nimport type { DateInput } from \"./types\"\n\n/**\n * Checks if two date objects refer to the same year.\n * @param inputDateA - First date to compare\n * @param inputDateB - Second date to compare\n */\nexport function sameYear(inputDateA: DateInput, inputDateB: DateInput) {\n const a = date(inputDateA)\n const b = date(inputDateB)\n return a.getFullYear() === b.getFullYear()\n}\n"],"mappings":";AAAA,SAAS,YAAY;AAQd,SAAS,SAAS,YAAuB,YAAuB;AACrE,QAAM,IAAI,KAAK,UAAU;AACzB,QAAM,IAAI,KAAK,UAAU;AACzB,SAAO,EAAE,YAAY,MAAM,EAAE,YAAY;AAC3C;","names":[]}
1
+ {"version":3,"sources":["../src/sameYear.ts"],"sourcesContent":["import { date } from \"./date\"\nimport type { DateInput, MaybeDateInput } from \"./types\"\n\n/**\n * Checks if two date objects refer to the same year.\n * @param inputDateA - First date to compare\n * @param [inputDateB] - Second date to compare or the current time if null given\n */\nexport function sameYear(inputDateA: DateInput, inputDateB?: MaybeDateInput): boolean\n/**\n * Checks if two date objects refer to the same year.\n * @param [inputDateA] - First date to compare or the current time if null given\n * @param inputDateB - Second date to compare\n */\nexport function sameYear(inputDateA: MaybeDateInput, inputDateB: DateInput): boolean\nexport function sameYear(\n inputDateA: MaybeDateInput,\n inputDateB?: MaybeDateInput\n): boolean {\n const a = date(inputDateA)\n const b = date(inputDateB)\n return a.getFullYear() === b.getFullYear()\n}\n"],"mappings":";AAAA,SAAS,YAAY;AAed,SAAS,SACd,YACA,YACS;AACT,QAAM,IAAI,KAAK,UAAU;AACzB,QAAM,IAAI,KAAK,UAAU;AACzB,SAAO,EAAE,YAAY,MAAM,EAAE,YAAY;AAC3C;","names":[]}
@@ -0,0 +1,11 @@
1
+ import { MaybeDateInput } from './types.js';
2
+
3
+ /**
4
+ * set the day of the month in a date object
5
+ * @param [inputDate] - a date or null for current time
6
+ * @param day - the day of the month you want the date set to (1-28/29/30/31) (can over/underflow)
7
+ * @param [dateOverflow] - Whether or not to allow the date to overflow to another month if the given day isn't in the current month
8
+ */
9
+ declare function setDayOfMonth(inputDate: MaybeDateInput, day: number, dateOverflow?: boolean): Date;
10
+
11
+ export { setDayOfMonth };
@@ -0,0 +1,16 @@
1
+ // src/setDayOfMonth.ts
2
+ import { date } from "./date.mjs";
3
+ import { monthDays } from "./monthDays.mjs";
4
+ function setDayOfMonth(inputDate, day, dateOverflow = false) {
5
+ const d = date(inputDate);
6
+ const daysInMonth = monthDays(d);
7
+ if (!dateOverflow) {
8
+ day = day > daysInMonth ? daysInMonth : day;
9
+ }
10
+ d.setDate(day);
11
+ return d;
12
+ }
13
+ export {
14
+ setDayOfMonth
15
+ };
16
+ //# sourceMappingURL=setDayOfMonth.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/setDayOfMonth.ts"],"sourcesContent":["import { date } from \"./date\"\nimport { monthDays } from \"./monthDays\"\nimport type { MaybeDateInput } from \"./types\"\n\n/**\n * set the day of the month in a date object\n * @param [inputDate] - a date or null for current time\n * @param day - the day of the month you want the date set to (1-28/29/30/31) (can over/underflow)\n * @param [dateOverflow] - Whether or not to allow the date to overflow to another month if the given day isn't in the current month\n */\nexport function setDayOfMonth(\n inputDate: MaybeDateInput,\n day: number,\n dateOverflow = false\n): Date {\n const d = date(inputDate)\n const daysInMonth = monthDays(d)\n if (!dateOverflow) {\n day = day > daysInMonth ? daysInMonth : day\n }\n d.setDate(day)\n return d\n}\n"],"mappings":";AAAA,SAAS,YAAY;AACrB,SAAS,iBAAiB;AASnB,SAAS,cACd,WACA,KACA,eAAe,OACT;AACN,QAAM,IAAI,KAAK,SAAS;AACxB,QAAM,cAAc,UAAU,CAAC;AAC/B,MAAI,CAAC,cAAc;AACjB,UAAM,MAAM,cAAc,cAAc;AAAA,EAC1C;AACA,IAAE,QAAQ,GAAG;AACb,SAAO;AACT;","names":[]}
@@ -0,0 +1,10 @@
1
+ import { MaybeDateInput } from './types.js';
2
+
3
+ /**
4
+ * set the hour of a date object
5
+ * @param [inputDate] - a date or null for current time
6
+ * @param hour - the hour you want the date set to (0 - 23) (can over/underflow)
7
+ */
8
+ declare function setHour(inputDate: MaybeDateInput, hour: number): Date;
9
+
10
+ export { setHour };
@@ -0,0 +1,11 @@
1
+ // src/setHour.ts
2
+ import { date } from "./date.mjs";
3
+ function setHour(inputDate, hour) {
4
+ const d = date(inputDate);
5
+ d.setHours(hour);
6
+ return d;
7
+ }
8
+ export {
9
+ setHour
10
+ };
11
+ //# sourceMappingURL=setHour.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/setHour.ts"],"sourcesContent":["import { date } from \"./date\"\nimport type { MaybeDateInput } from \"./types\"\n\n/**\n * set the hour of a date object\n * @param [inputDate] - a date or null for current time\n * @param hour - the hour you want the date set to (0 - 23) (can over/underflow)\n */\nexport function setHour(inputDate: MaybeDateInput, hour: number): Date {\n const d = date(inputDate)\n d.setHours(hour)\n return d\n}\n"],"mappings":";AAAA,SAAS,YAAY;AAQd,SAAS,QAAQ,WAA2B,MAAoB;AACrE,QAAM,IAAI,KAAK,SAAS;AACxB,IAAE,SAAS,IAAI;AACf,SAAO;AACT;","names":[]}
@@ -0,0 +1,10 @@
1
+ import { MaybeDateInput } from './types.js';
2
+
3
+ /**
4
+ * set the millisecond of a date object
5
+ * @param [inputDate] - a date or null for current time
6
+ * @param ms - the milliseconds you want the date set to (0 - 999) (can over/underflow)
7
+ */
8
+ declare function setMilliseconds(inputDate: MaybeDateInput, ms: number): Date;
9
+
10
+ export { setMilliseconds };
@@ -0,0 +1,11 @@
1
+ // src/setMilliseconds.ts
2
+ import { date } from "./date.mjs";
3
+ function setMilliseconds(inputDate, ms) {
4
+ const d = date(inputDate);
5
+ d.setMilliseconds(ms);
6
+ return d;
7
+ }
8
+ export {
9
+ setMilliseconds
10
+ };
11
+ //# sourceMappingURL=setMilliseconds.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/setMilliseconds.ts"],"sourcesContent":["import { date } from \"./date\"\nimport type { MaybeDateInput } from \"./types\"\n\n/**\n * set the millisecond of a date object\n * @param [inputDate] - a date or null for current time\n * @param ms - the milliseconds you want the date set to (0 - 999) (can over/underflow)\n */\nexport function setMilliseconds(inputDate: MaybeDateInput, ms: number): Date {\n const d = date(inputDate)\n d.setMilliseconds(ms)\n return d\n}\n"],"mappings":";AAAA,SAAS,YAAY;AAQd,SAAS,gBAAgB,WAA2B,IAAkB;AAC3E,QAAM,IAAI,KAAK,SAAS;AACxB,IAAE,gBAAgB,EAAE;AACpB,SAAO;AACT;","names":[]}
@@ -0,0 +1,10 @@
1
+ import { MaybeDateInput } from './types.js';
2
+
3
+ /**
4
+ * set the minute of a date object
5
+ * @param [inputDate] - a date or null for current time
6
+ * @param minute - the minute you want the date set to (0 - 59) (can over/underflow)
7
+ */
8
+ declare function setMinutes(inputDate: MaybeDateInput, minute: number): Date;
9
+
10
+ export { setMinutes };
@@ -0,0 +1,11 @@
1
+ // src/setMinutes.ts
2
+ import { date } from "./date.mjs";
3
+ function setMinutes(inputDate, minute) {
4
+ const d = date(inputDate);
5
+ d.setMinutes(minute);
6
+ return d;
7
+ }
8
+ export {
9
+ setMinutes
10
+ };
11
+ //# sourceMappingURL=setMinutes.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/setMinutes.ts"],"sourcesContent":["import { date } from \"./date\"\nimport type { MaybeDateInput } from \"./types\"\n\n/**\n * set the minute of a date object\n * @param [inputDate] - a date or null for current time\n * @param minute - the minute you want the date set to (0 - 59) (can over/underflow)\n */\nexport function setMinutes(inputDate: MaybeDateInput, minute: number): Date {\n const d = date(inputDate)\n d.setMinutes(minute)\n return d\n}\n"],"mappings":";AAAA,SAAS,YAAY;AAQd,SAAS,WAAW,WAA2B,QAAsB;AAC1E,QAAM,IAAI,KAAK,SAAS;AACxB,IAAE,WAAW,MAAM;AACnB,SAAO;AACT;","names":[]}
@@ -0,0 +1,11 @@
1
+ import { MaybeDateInput } from './types.js';
2
+
3
+ /**
4
+ * set the month of a date
5
+ * @param [inputDate] - a date or null for current time
6
+ * @param month - the zero-based month to set (0-11, where 0 is January) (can over/underflow)
7
+ * @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.
8
+ */
9
+ declare function setMonth(inputDate: MaybeDateInput, month: number, dateOverflow?: boolean): Date;
10
+
11
+ export { setMonth };
@@ -0,0 +1,9 @@
1
+ // src/setMonth.ts
2
+ import { handleOverflow } from "./handleDateOverflow.mjs";
3
+ function setMonth(inputDate, month, dateOverflow = false) {
4
+ return handleOverflow(inputDate, (d) => d.setMonth(month), dateOverflow);
5
+ }
6
+ export {
7
+ setMonth
8
+ };
9
+ //# sourceMappingURL=setMonth.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/setMonth.ts"],"sourcesContent":["import { handleOverflow } from \"./handleDateOverflow\"\nimport type { MaybeDateInput } from \"./types\"\n\n/**\n * set the month of a date\n * @param [inputDate] - a date or null for current time\n * @param month - the zero-based month to set (0-11, where 0 is January) (can over/underflow)\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 setMonth(\n inputDate: MaybeDateInput,\n month: number,\n dateOverflow = false\n): Date {\n return handleOverflow(inputDate, (d) => d.setMonth(month), dateOverflow)\n}\n"],"mappings":";AAAA,SAAS,sBAAsB;AASxB,SAAS,SACd,WACA,OACA,eAAe,OACT;AACN,SAAO,eAAe,WAAW,CAAC,MAAM,EAAE,SAAS,KAAK,GAAG,YAAY;AACzE;","names":[]}
@@ -0,0 +1,10 @@
1
+ import { MaybeDateInput } from './types.js';
2
+
3
+ /**
4
+ * set the second of a date object
5
+ * @param [inputDate] - a date or null for current time
6
+ * @param second - the second you want the date set to (0 - 59) (can over/underflow)
7
+ */
8
+ declare function setSeconds(inputDate: MaybeDateInput, second: number): Date;
9
+
10
+ export { setSeconds };
@@ -0,0 +1,11 @@
1
+ // src/setSeconds.ts
2
+ import { date } from "./date.mjs";
3
+ function setSeconds(inputDate, second) {
4
+ const d = date(inputDate);
5
+ d.setSeconds(second);
6
+ return d;
7
+ }
8
+ export {
9
+ setSeconds
10
+ };
11
+ //# sourceMappingURL=setSeconds.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/setSeconds.ts"],"sourcesContent":["import { date } from \"./date\"\nimport type { MaybeDateInput } from \"./types\"\n\n/**\n * set the second of a date object\n * @param [inputDate] - a date or null for current time\n * @param second - the second you want the date set to (0 - 59) (can over/underflow)\n */\nexport function setSeconds(inputDate: MaybeDateInput, second: number): Date {\n const d = date(inputDate)\n d.setSeconds(second)\n return d\n}\n"],"mappings":";AAAA,SAAS,YAAY;AAQd,SAAS,WAAW,WAA2B,QAAsB;AAC1E,QAAM,IAAI,KAAK,SAAS;AACxB,IAAE,WAAW,MAAM;AACnB,SAAO;AACT;","names":[]}
@@ -0,0 +1,11 @@
1
+ import { MaybeDateInput } from './types.js';
2
+
3
+ /**
4
+ * set the year of a date object
5
+ * @param inputDate - a date or null for current time
6
+ * @param year - the full year you want the date to be set to
7
+ * @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.
8
+ */
9
+ declare function setYear(inputDate: MaybeDateInput, year: number, dateOverflow?: boolean): Date;
10
+
11
+ export { setYear };
@@ -0,0 +1,9 @@
1
+ // src/setYear.ts
2
+ import { handleOverflow } from "./handleDateOverflow.mjs";
3
+ function setYear(inputDate, year, dateOverflow = false) {
4
+ return handleOverflow(inputDate, (d) => d.setFullYear(year), dateOverflow);
5
+ }
6
+ export {
7
+ setYear
8
+ };
9
+ //# sourceMappingURL=setYear.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/setYear.ts"],"sourcesContent":["import { date } from \"./date\"\nimport type { MaybeDateInput } from \"./types\"\nimport { handleOverflow } from \"./handleDateOverflow\"\n\n/**\n * set the year of a date object\n * @param inputDate - a date or null for current time\n * @param year - the full year you want the date to be set to\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 setYear(\n inputDate: MaybeDateInput,\n year: number,\n dateOverflow = false\n): Date {\n return handleOverflow(inputDate, (d) => d.setFullYear(year), dateOverflow)\n}\n"],"mappings":";AAEA,SAAS,sBAAsB;AAQxB,SAAS,QACd,WACA,MACA,eAAe,OACT;AACN,SAAO,eAAe,WAAW,CAAC,MAAM,EAAE,YAAY,IAAI,GAAG,YAAY;AAC3E;","names":[]}
package/dist/types.d.ts CHANGED
@@ -2,10 +2,18 @@
2
2
  * The date format used as an input value. Either a date or an ISO8601 string.
3
3
  */
4
4
  type DateInput = Date | string;
5
+ /**
6
+ * The date format used as a maybe input value. Either a date, ISO8601 string or null for current time
7
+ */
8
+ type MaybeDateInput = DateInput | null;
5
9
  /**
6
10
  * Format parts with text names use these descriptors:
7
11
  */
8
12
  type NamedFormatOption = "long" | "short" | "narrow";
13
+ /**
14
+ * Extended part types that include custom tokens not in Intl.DateTimeFormatPartTypes.
15
+ */
16
+ type ExtendedPartTypes = Intl.DateTimeFormatPartTypes | "fractionalSecond";
9
17
  /**
10
18
  * A registry of named format parts. Each type of part has every option.
11
19
  */
@@ -28,11 +36,11 @@ interface Part {
28
36
  option: FormatPattern[1];
29
37
  /**
30
38
  * The name of the part, these must be valid parts of a date format as
31
- * specified in Intl.DateTimeFormatPartTypes. Valid values are:
32
- * day, dayPeriod, era, hour, literal, minute, month, second, timeZoneName,
33
- * weekday, year
39
+ * specified in Intl.DateTimeFormatPartTypes, plus custom extensions.
40
+ * Valid values are: day, dayPeriod, era, hour, literal, minute, month,
41
+ * second, timeZoneName, weekday, year, fractionalSecond
34
42
  */
35
- partName: Intl.DateTimeFormatPartTypes;
43
+ partName: ExtendedPartTypes;
36
44
  /**
37
45
  * The value of a given part. For example "2-digit", or "narrow".
38
46
  */
@@ -61,7 +69,7 @@ type FilledPart = Part & {
61
69
  */
62
70
  type FormatPattern = [
63
71
  pattern: FormatToken | string,
64
- option: Partial<Record<Intl.DateTimeFormatPartTypes, string>>,
72
+ option: Partial<Record<ExtendedPartTypes, string>>,
65
73
  exp?: RegExp
66
74
  ];
67
75
  /**
@@ -83,7 +91,7 @@ type Format = FormatStyle | FormatStyleObj | (string & {});
83
91
  /**
84
92
  * A union of all available formatting tokens.
85
93
  */
86
- type FormatToken = "YYYY" | "YY" | "MMMM" | "MMM" | "MM" | "M" | "DD" | "D" | "dddd" | "ddd" | "d" | "mm" | "m" | "ss" | "s" | "HH" | "H" | "hh" | "h" | "a" | "A" | "ZZ" | "Z";
94
+ type FormatToken = "YYYY" | "YY" | "MMMM" | "MMM" | "MM" | "M" | "DD" | "D" | "dddd" | "ddd" | "d" | "mm" | "m" | "ss" | "s" | "SSS" | "HH" | "H" | "hh" | "h" | "a" | "A" | "ZZ" | "Z";
87
95
  interface ParseOptions {
88
96
  /**
89
97
  * A string representing a date.
@@ -139,5 +147,19 @@ interface FormatOptions {
139
147
  */
140
148
  partFilter?: (part: Part) => boolean;
141
149
  }
150
+ interface Duration {
151
+ years?: number;
152
+ months?: number;
153
+ weeks?: number;
154
+ days?: number;
155
+ hours?: number;
156
+ minutes?: number;
157
+ seconds?: number;
158
+ milliseconds?: number;
159
+ }
160
+ interface DurationObj extends Duration {
161
+ microseconds?: number;
162
+ nanoseconds?: number;
163
+ }
142
164
 
143
- export type { DateInput, FilledPart, Format, FormatOptions, FormatPattern, FormatStyle, FormatStyleObj, FormatToken, NamedFormatOption, NamedFormats, ParseOptions, Part };
165
+ export type { DateInput, Duration, DurationObj, ExtendedPartTypes, FilledPart, Format, FormatOptions, FormatPattern, FormatStyle, FormatStyleObj, FormatToken, MaybeDateInput, NamedFormatOption, NamedFormats, ParseOptions, Part };
package/dist/tzDate.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { DateInput } from './types.js';
1
+ import { MaybeDateInput } from './types.js';
2
2
 
3
3
  /**
4
4
  * Creates a date object for the input date at the given timezone. For example
@@ -7,9 +7,11 @@ import { DateInput } from './types.js';
7
7
  *
8
8
  * If given a Date object it will use local time and convert it to the given
9
9
  * timezone, thus "changing" the date.
10
- * @param inputDate - An iso8601 date string with no timezone
10
+ *
11
+ * if given no string or date object, it'll use the current locale time and convert to the given timezone
12
+ * @param [inputDate] - An iso8601 date string with no timezone
11
13
  * @param tz - A timezone string
12
14
  */
13
- declare function tzDate(inputDate: DateInput, tz: string): Date;
15
+ declare function tzDate(inputDate: MaybeDateInput, tz: string): Date;
14
16
 
15
17
  export { tzDate };
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/tzDate.ts"],"sourcesContent":["import { offset } from \"./offset\"\nimport { applyOffset } from \"./applyOffset\"\nimport { date } from \"./date\"\nimport { DateInput } from \"./types\"\n\n/**\n * Creates a date object for the input date at the given timezone. For example\n * `tzDate(\"2017-05-06T12:00\", \"Europe/Amsterdam\")` will return a date object\n * for 2017-05-06T10:00:00Z since 12:00 in Amsterdam is 10:00Z.\n *\n * If given a Date object it will use local time and convert it to the given\n * timezone, thus \"changing\" the date.\n * @param inputDate - An iso8601 date string with no timezone\n * @param tz - A timezone string\n */\nexport function tzDate(inputDate: DateInput, tz: string) {\n const d = date(inputDate)\n return applyOffset(d, offset(d, tz))\n}\n"],"mappings":";AAAA,SAAS,cAAc;AACvB,SAAS,mBAAmB;AAC5B,SAAS,YAAY;AAad,SAAS,OAAO,WAAsB,IAAY;AACvD,QAAM,IAAI,KAAK,SAAS;AACxB,SAAO,YAAY,GAAG,OAAO,GAAG,EAAE,CAAC;AACrC;","names":[]}
1
+ {"version":3,"sources":["../src/tzDate.ts"],"sourcesContent":["import { offset } from \"./offset\"\nimport { applyOffset } from \"./applyOffset\"\nimport { date } from \"./date\"\nimport { DateInput, MaybeDateInput } from \"./types\"\n\n/**\n * Creates a date object for the input date at the given timezone. For example\n * `tzDate(\"2017-05-06T12:00\", \"Europe/Amsterdam\")` will return a date object\n * for 2017-05-06T10:00:00Z since 12:00 in Amsterdam is 10:00Z.\n *\n * If given a Date object it will use local time and convert it to the given\n * timezone, thus \"changing\" the date.\n *\n * if given no string or date object, it'll use the current locale time and convert to the given timezone\n * @param [inputDate] - An iso8601 date string with no timezone\n * @param tz - A timezone string\n */\nexport function tzDate(inputDate: MaybeDateInput, tz: string) {\n const d = date(inputDate)\n return applyOffset(d, offset(d, tz))\n}\n"],"mappings":";AAAA,SAAS,cAAc;AACvB,SAAS,mBAAmB;AAC5B,SAAS,YAAY;AAed,SAAS,OAAO,WAA2B,IAAY;AAC5D,QAAM,IAAI,KAAK,SAAS;AACxB,SAAO,YAAY,GAAG,OAAO,GAAG,EAAE,CAAC;AACrC;","names":[]}
package/dist/weekEnd.d.ts CHANGED
@@ -1,12 +1,12 @@
1
- import { DateInput } from './types.js';
1
+ import { MaybeDateInput } from './types.js';
2
2
 
3
3
  /**
4
4
  * Returns a Date object for the last day at the last second of the given week.
5
5
  * Defaults to Sunday as the first day of the week:
6
6
  * 0 = Sunday ... 6 = Saturday
7
- * @param inputDate - Gets the last day of the week
8
- * @param startOfWeekDay - The first day of the week
7
+ * @param [inputDate] - Gets the last day of the week
8
+ * @param [startOfWeekDay] - The first day of the week
9
9
  */
10
- declare function weekEnd(inputDate: DateInput, startOfWeekDay?: number): Date;
10
+ declare function weekEnd(inputDate?: MaybeDateInput, startOfWeekDay?: number): Date;
11
11
 
12
12
  export { weekEnd };
package/dist/weekEnd.mjs CHANGED
@@ -3,7 +3,7 @@ import { weekStart } from "./weekStart.mjs";
3
3
  function weekEnd(inputDate, startOfWeekDay = 0) {
4
4
  const d = weekStart(inputDate, startOfWeekDay);
5
5
  d.setDate(d.getDate() + 6);
6
- d.setHours(23, 59, 59);
6
+ d.setHours(23, 59, 59, 999);
7
7
  return d;
8
8
  }
9
9
  export {
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/weekEnd.ts"],"sourcesContent":["import { weekStart } from \"./weekStart\"\nimport type { DateInput } from \"./types\"\n\n/**\n * Returns a Date object for the last day at the last second of the given week.\n * Defaults to Sunday as the first day of the week:\n * 0 = Sunday ... 6 = Saturday\n * @param inputDate - Gets the last day of the week\n * @param startOfWeekDay - The first day of the week\n */\nexport function weekEnd(inputDate: DateInput, startOfWeekDay = 0): Date {\n const d = weekStart(inputDate, startOfWeekDay)\n d.setDate(d.getDate() + 6)\n d.setHours(23, 59, 59)\n return d\n}\n"],"mappings":";AAAA,SAAS,iBAAiB;AAUnB,SAAS,QAAQ,WAAsB,iBAAiB,GAAS;AACtE,QAAM,IAAI,UAAU,WAAW,cAAc;AAC7C,IAAE,QAAQ,EAAE,QAAQ,IAAI,CAAC;AACzB,IAAE,SAAS,IAAI,IAAI,EAAE;AACrB,SAAO;AACT;","names":[]}
1
+ {"version":3,"sources":["../src/weekEnd.ts"],"sourcesContent":["import { weekStart } from \"./weekStart\"\nimport type { MaybeDateInput } from \"./types\"\n\n/**\n * Returns a Date object for the last day at the last second of the given week.\n * Defaults to Sunday as the first day of the week:\n * 0 = Sunday ... 6 = Saturday\n * @param [inputDate] - Gets the last day of the week\n * @param [startOfWeekDay] - The first day of the week\n */\nexport function weekEnd(inputDate?: MaybeDateInput, startOfWeekDay = 0): Date {\n const d = weekStart(inputDate, startOfWeekDay)\n d.setDate(d.getDate() + 6)\n d.setHours(23, 59, 59, 999)\n return d\n}\n"],"mappings":";AAAA,SAAS,iBAAiB;AAUnB,SAAS,QAAQ,WAA4B,iBAAiB,GAAS;AAC5E,QAAM,IAAI,UAAU,WAAW,cAAc;AAC7C,IAAE,QAAQ,EAAE,QAAQ,IAAI,CAAC;AACzB,IAAE,SAAS,IAAI,IAAI,IAAI,GAAG;AAC1B,SAAO;AACT;","names":[]}
@@ -1,12 +1,12 @@
1
- import { DateInput } from './types.js';
1
+ import { MaybeDateInput } from './types.js';
2
2
 
3
3
  /**
4
4
  * Returns a Date object for start of the given week. Defaults to Sunday as the
5
5
  * first day of the week:
6
6
  * 0 = Sunday ... 6 = Saturday
7
- * @param inputDate - A string or Date object
8
- * @param startOfWeekDay - Determines which day of the week is the first
7
+ * @param [inputDate] - A string, Date object or nothing for current week
8
+ * @param [startOfWeekDay] - Determines which day of the week is the first
9
9
  */
10
- declare function weekStart(inputDate: DateInput, startOfWeekDay?: number): Date;
10
+ declare function weekStart(inputDate?: MaybeDateInput, startOfWeekDay?: number): Date;
11
11
 
12
12
  export { weekStart };
@@ -3,10 +3,9 @@ import { date } from "./date.mjs";
3
3
  function weekStart(inputDate, startOfWeekDay = 0) {
4
4
  const d = date(inputDate);
5
5
  let diff = startOfWeekDay - d.getDay();
6
- if (diff > 0)
7
- diff = diff - 7;
6
+ if (diff > 0) diff = diff - 7;
8
7
  d.setDate(d.getDate() + diff);
9
- d.setHours(0, 0, 0);
8
+ d.setHours(0, 0, 0, 0);
10
9
  return d;
11
10
  }
12
11
  export {
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/weekStart.ts"],"sourcesContent":["import { date } from \"./date\"\nimport type { DateInput } from \"./types\"\n\n/**\n * Returns a Date object for start of the given week. Defaults to Sunday as the\n * first day of the week:\n * 0 = Sunday ... 6 = Saturday\n * @param inputDate - A string or Date object\n * @param startOfWeekDay - Determines which day of the week is the first\n */\nexport function weekStart(inputDate: DateInput, startOfWeekDay = 0): Date {\n const d = date(inputDate)\n let diff = startOfWeekDay - d.getDay()\n if (diff > 0) diff = diff - 7\n d.setDate(d.getDate() + diff)\n d.setHours(0, 0, 0)\n return d\n}\n"],"mappings":";AAAA,SAAS,YAAY;AAUd,SAAS,UAAU,WAAsB,iBAAiB,GAAS;AACxE,QAAM,IAAI,KAAK,SAAS;AACxB,MAAI,OAAO,iBAAiB,EAAE,OAAO;AACrC,MAAI,OAAO;AAAG,WAAO,OAAO;AAC5B,IAAE,QAAQ,EAAE,QAAQ,IAAI,IAAI;AAC5B,IAAE,SAAS,GAAG,GAAG,CAAC;AAClB,SAAO;AACT;","names":[]}
1
+ {"version":3,"sources":["../src/weekStart.ts"],"sourcesContent":["import { date } from \"./date\"\nimport type { MaybeDateInput } from \"./types\"\n\n/**\n * Returns a Date object for start of the given week. Defaults to Sunday as the\n * first day of the week:\n * 0 = Sunday ... 6 = Saturday\n * @param [inputDate] - A string, Date object or nothing for current week\n * @param [startOfWeekDay] - Determines which day of the week is the first\n */\nexport function weekStart(inputDate?: MaybeDateInput, startOfWeekDay = 0): Date {\n const d = date(inputDate)\n let diff = startOfWeekDay - d.getDay()\n if (diff > 0) diff = diff - 7\n d.setDate(d.getDate() + diff)\n d.setHours(0, 0, 0, 0)\n return d\n}\n"],"mappings":";AAAA,SAAS,YAAY;AAUd,SAAS,UAAU,WAA4B,iBAAiB,GAAS;AAC9E,QAAM,IAAI,KAAK,SAAS;AACxB,MAAI,OAAO,iBAAiB,EAAE,OAAO;AACrC,MAAI,OAAO,EAAG,QAAO,OAAO;AAC5B,IAAE,QAAQ,EAAE,QAAQ,IAAI,IAAI;AAC5B,IAAE,SAAS,GAAG,GAAG,GAAG,CAAC;AACrB,SAAO;AACT;","names":[]}
@@ -1,9 +1,9 @@
1
- import { DateInput } from './types.js';
1
+ import { MaybeDateInput } from './types.js';
2
2
 
3
3
  /**
4
4
  * Get the number of days in the given date’s year.
5
- * @param inputDate - A string or Date object
5
+ * @param [inputDate] - A string, Date object or nothing for the current year
6
6
  */
7
- declare function yearDays(inputDate: DateInput): number;
7
+ declare function yearDays(inputDate?: MaybeDateInput): number;
8
8
 
9
9
  export { yearDays };
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/yearDays.ts"],"sourcesContent":["import { date } from \"./date\"\nimport type { DateInput } from \"./types\"\n\n/**\n * Get the number of days in the given date’s year.\n * @param inputDate - A string or Date object\n */\nexport function yearDays(inputDate: DateInput): number {\n const d = date(inputDate)\n return (\n (new Date(d.getFullYear() + 1, 0, 0).getTime() -\n new Date(d.getFullYear(), 0, 0).getTime()) /\n 86400000\n )\n}\n"],"mappings":";AAAA,SAAS,YAAY;AAOd,SAAS,SAAS,WAA8B;AACrD,QAAM,IAAI,KAAK,SAAS;AACxB,UACG,IAAI,KAAK,EAAE,YAAY,IAAI,GAAG,GAAG,CAAC,EAAE,QAAQ,IAC3C,IAAI,KAAK,EAAE,YAAY,GAAG,GAAG,CAAC,EAAE,QAAQ,KAC1C;AAEJ;","names":[]}
1
+ {"version":3,"sources":["../src/yearDays.ts"],"sourcesContent":["import { date } from \"./date\"\nimport type { MaybeDateInput } from \"./types\"\n\n/**\n * Get the number of days in the given date’s year.\n * @param [inputDate] - A string, Date object or nothing for the current year\n */\nexport function yearDays(inputDate?: MaybeDateInput): number {\n const d = date(inputDate)\n return (\n (new Date(d.getFullYear() + 1, 0, 0).getTime() -\n new Date(d.getFullYear(), 0, 0).getTime()) /\n 86400000\n )\n}\n"],"mappings":";AAAA,SAAS,YAAY;AAOd,SAAS,SAAS,WAAoC;AAC3D,QAAM,IAAI,KAAK,SAAS;AACxB,UACG,IAAI,KAAK,EAAE,YAAY,IAAI,GAAG,GAAG,CAAC,EAAE,QAAQ,IAC3C,IAAI,KAAK,EAAE,YAAY,GAAG,GAAG,CAAC,EAAE,QAAQ,KAC1C;AAEJ;","names":[]}
package/dist/yearEnd.d.ts CHANGED
@@ -1,9 +1,9 @@
1
- import { DateInput } from './types.js';
1
+ import { MaybeDateInput } from './types.js';
2
2
 
3
3
  /**
4
4
  * Returns a Date object for the with the input date set to the end of the current year.
5
- * @param inputDate - A string or Date object
5
+ * @param [inputDate] - A string, Date object or nothing for the current year
6
6
  */
7
- declare function yearEnd(inputDate: DateInput): Date;
7
+ declare function yearEnd(inputDate?: MaybeDateInput): Date;
8
8
 
9
9
  export { yearEnd };
package/dist/yearEnd.mjs CHANGED
@@ -2,8 +2,7 @@
2
2
  import { date } from "./date.mjs";
3
3
  function yearEnd(inputDate) {
4
4
  const d = date(inputDate);
5
- d.setMonth(11);
6
- d.setDate(31);
5
+ d.setMonth(11, 31);
7
6
  d.setHours(23, 59, 59, 999);
8
7
  return d;
9
8
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/yearEnd.ts"],"sourcesContent":["import { date } from \"./date\"\nimport type { DateInput } from \"./types\"\n\n/**\n * Returns a Date object for the with the input date set to the end of the current year.\n * @param inputDate - A string or Date object\n */\nexport function yearEnd(inputDate: DateInput): Date {\n const d = date(inputDate);\n\n d.setMonth(11);\n d.setDate(31);\n d.setHours(23, 59, 59, 999);\n\n return d;\n}\n"],"mappings":";AAAA,SAAS,YAAY;AAOd,SAAS,QAAQ,WAA4B;AAClD,QAAM,IAAI,KAAK,SAAS;AAExB,IAAE,SAAS,EAAE;AACb,IAAE,QAAQ,EAAE;AACZ,IAAE,SAAS,IAAI,IAAI,IAAI,GAAG;AAE1B,SAAO;AACT;","names":[]}
1
+ {"version":3,"sources":["../src/yearEnd.ts"],"sourcesContent":["import { date } from \"./date\"\nimport type { MaybeDateInput } from \"./types\"\n\n/**\n * Returns a Date object for the with the input date set to the end of the current year.\n * @param [inputDate] - A string, Date object or nothing for the current year\n */\nexport function yearEnd(inputDate?: MaybeDateInput): Date {\n const d = date(inputDate)\n\n d.setMonth(11, 31)\n d.setHours(23, 59, 59, 999)\n\n return d\n}\n"],"mappings":";AAAA,SAAS,YAAY;AAOd,SAAS,QAAQ,WAAkC;AACxD,QAAM,IAAI,KAAK,SAAS;AAExB,IAAE,SAAS,IAAI,EAAE;AACjB,IAAE,SAAS,IAAI,IAAI,IAAI,GAAG;AAE1B,SAAO;AACT;","names":[]}
@@ -1,9 +1,9 @@
1
- import { DateInput } from './types.js';
1
+ import { MaybeDateInput } from './types.js';
2
2
 
3
3
  /**
4
4
  * Returns a Date object for the with the input date set to the start of the current year.
5
- * @param inputDate - A string or Date object
5
+ * @param [inputDate] - A string, Date object or nothing for the current year
6
6
  */
7
- declare function yearStart(inputDate: DateInput): Date;
7
+ declare function yearStart(inputDate?: MaybeDateInput): Date;
8
8
 
9
9
  export { yearStart };
@@ -2,9 +2,8 @@
2
2
  import { date } from "./date.mjs";
3
3
  function yearStart(inputDate) {
4
4
  const d = date(inputDate);
5
- d.setMonth(0);
6
- d.setDate(1);
7
- d.setHours(0, 0, 0);
5
+ d.setMonth(0, 1);
6
+ d.setHours(0, 0, 0, 0);
8
7
  return d;
9
8
  }
10
9
  export {
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/yearStart.ts"],"sourcesContent":["import { date } from \"./date\"\nimport type { DateInput } from \"./types\"\n\n/**\n * Returns a Date object for the with the input date set to the start of the current year.\n * @param inputDate - A string or Date object\n */\nexport function yearStart(inputDate: DateInput): Date {\n const d = date(inputDate)\n\n d.setMonth(0)\n d.setDate(1)\n d.setHours(0, 0, 0)\n\n return d\n}\n"],"mappings":";AAAA,SAAS,YAAY;AAOd,SAAS,UAAU,WAA4B;AACpD,QAAM,IAAI,KAAK,SAAS;AAExB,IAAE,SAAS,CAAC;AACZ,IAAE,QAAQ,CAAC;AACX,IAAE,SAAS,GAAG,GAAG,CAAC;AAElB,SAAO;AACT;","names":[]}
1
+ {"version":3,"sources":["../src/yearStart.ts"],"sourcesContent":["import { date } from \"./date\"\nimport type { MaybeDateInput } from \"./types\"\n\n/**\n * Returns a Date object for the with the input date set to the start of the current year.\n * @param [inputDate] - A string, Date object or nothing for the current year\n */\nexport function yearStart(inputDate?: MaybeDateInput): Date {\n const d = date(inputDate)\n\n d.setMonth(0, 1)\n d.setHours(0, 0, 0, 0)\n\n return d\n}\n"],"mappings":";AAAA,SAAS,YAAY;AAOd,SAAS,UAAU,WAAkC;AAC1D,QAAM,IAAI,KAAK,SAAS;AAExB,IAAE,SAAS,GAAG,CAAC;AACf,IAAE,SAAS,GAAG,GAAG,GAAG,CAAC;AAErB,SAAO;AACT;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "@formkit/tempo",
3
- "version": "0.1.2",
3
+ "version": "1.1.0",
4
+ "packageManager": "pnpm@10.11.0",
4
5
  "description": "The easiest way to work with dates in JavaScript and TypeScript.",
5
6
  "type": "module",
6
7
  "main": "dist/index.cjs",
@@ -23,6 +24,24 @@
23
24
  }
24
25
  }
25
26
  },
27
+ "homepage": "https://github.com/formkit/tempo",
28
+ "repository": {
29
+ "type": "git",
30
+ "url": "https://github.com/formkit/tempo.git"
31
+ },
32
+ "bugs": {
33
+ "url": "https://github.com/formkit/tempo/issues"
34
+ },
35
+ "scripts": {
36
+ "dev": "npm --prefix ./docs run dev",
37
+ "build": "tsup",
38
+ "post:build": "node scripts/size-limit/index.js || echo 'Size limit check skipped'",
39
+ "test": "TZ=\"America/New_York\" vitest",
40
+ "docs-build": "npm --prefix ./docs run build",
41
+ "publint": "publint",
42
+ "release": "pnpm build && bumpp --push",
43
+ "size": "npm run build && size-limit"
44
+ },
26
45
  "files": [
27
46
  "dist",
28
47
  "docs/public/read-the-docs.png",
@@ -37,27 +56,17 @@
37
56
  "author": "Justin Schroeder <justin@formkit.com>",
38
57
  "license": "MIT",
39
58
  "devDependencies": {
40
- "@size-limit/esbuild": "^11.1.1",
41
- "@size-limit/file": "^11.1.1",
42
- "@size-limit/preset-small-lib": "^11.0.2",
43
- "@types/node": "^20.11.10",
44
- "bumpp": "^9.3.0",
59
+ "@size-limit/esbuild": "^12.0.0",
60
+ "@size-limit/file": "^12.0.0",
61
+ "@size-limit/preset-small-lib": "^12.0.0",
62
+ "@types/node": "^25.0.3",
63
+ "bumpp": "^10.3.2",
45
64
  "bytes-iec": "^3.1.1",
46
- "esbuild-plugin-file-path-extensions": "^2.0.0",
47
- "publint": "^0.2.7",
48
- "size-limit": "^11.0.2",
49
- "tsup": "^8.0.1",
50
- "typescript": "^5.3.3",
51
- "vitest": "^1.2.1"
52
- },
53
- "scripts": {
54
- "dev": "cd ./docs && pnpm nuxt dev",
55
- "build": "tsup",
56
- "post:build": "node scripts/size-limit/index.js",
57
- "test": "TZ=\"America/New_York\" vitest",
58
- "docs-build": "cd ./docs && pnpm run build",
59
- "publint": "publint",
60
- "release": "pnpm build && bumpp && pnpm publish",
61
- "size": "npm run build && size-limit"
65
+ "esbuild-plugin-file-path-extensions": "^2.1.4",
66
+ "publint": "^0.3.16",
67
+ "size-limit": "^12.0.0",
68
+ "tsup": "^8.5.1",
69
+ "typescript": "^5.9.3",
70
+ "vitest": "^4.0.16"
62
71
  }
63
- }
72
+ }