@formkit/tempo 0.1.2 → 1.0.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 (147) hide show
  1. package/dist/addDay.d.ts +4 -3
  2. package/dist/addDay.mjs.map +1 -1
  3. package/dist/addHour.d.ts +4 -3
  4. package/dist/addHour.mjs.map +1 -1
  5. package/dist/addMillisecond.d.ts +10 -0
  6. package/dist/addMillisecond.mjs +11 -0
  7. package/dist/addMillisecond.mjs.map +1 -0
  8. package/dist/addMinute.d.ts +5 -4
  9. package/dist/addMinute.mjs.map +1 -1
  10. package/dist/addMonth.d.ts +5 -5
  11. package/dist/addMonth.mjs +1 -2
  12. package/dist/addMonth.mjs.map +1 -1
  13. package/dist/addSecond.d.ts +4 -3
  14. package/dist/addSecond.mjs.map +1 -1
  15. package/dist/addYear.d.ts +5 -5
  16. package/dist/addYear.mjs +1 -2
  17. package/dist/addYear.mjs.map +1 -1
  18. package/dist/ap.mjs +1 -2
  19. package/dist/ap.mjs.map +1 -1
  20. package/dist/applyOffset.d.ts +5 -5
  21. package/dist/applyOffset.mjs +5 -11
  22. package/dist/applyOffset.mjs.map +1 -1
  23. package/dist/bundle.d.ts +256 -115
  24. package/dist/bundle.mjs +158 -142
  25. package/dist/bundle.mjs.map +1 -1
  26. package/dist/common.d.ts +27 -7
  27. package/dist/common.mjs +47 -42
  28. package/dist/common.mjs.map +1 -1
  29. package/dist/date.d.ts +2 -2
  30. package/dist/date.mjs +1 -3
  31. package/dist/date.mjs.map +1 -1
  32. package/dist/dayEnd.d.ts +3 -3
  33. package/dist/dayEnd.mjs.map +1 -1
  34. package/dist/dayOfYear.d.ts +3 -3
  35. package/dist/dayOfYear.mjs.map +1 -1
  36. package/dist/dayStart.d.ts +3 -3
  37. package/dist/dayStart.mjs +1 -1
  38. package/dist/dayStart.mjs.map +1 -1
  39. package/dist/diffDays.d.ts +12 -5
  40. package/dist/diffDays.mjs +1 -0
  41. package/dist/diffDays.mjs.map +1 -1
  42. package/dist/diffHours.d.ts +12 -5
  43. package/dist/diffHours.mjs +1 -0
  44. package/dist/diffHours.mjs.map +1 -1
  45. package/dist/diffMilliseconds.d.ts +10 -4
  46. package/dist/diffMilliseconds.mjs.map +1 -1
  47. package/dist/diffMinutes.d.ts +11 -3
  48. package/dist/diffMinutes.mjs +5 -1
  49. package/dist/diffMinutes.mjs.map +1 -1
  50. package/dist/diffMonths.d.ts +10 -4
  51. package/dist/diffMonths.mjs.map +1 -1
  52. package/dist/diffSeconds.d.ts +12 -5
  53. package/dist/diffSeconds.mjs +5 -1
  54. package/dist/diffSeconds.mjs.map +1 -1
  55. package/dist/diffWeeks.d.ts +10 -3
  56. package/dist/diffWeeks.mjs.map +1 -1
  57. package/dist/diffYears.d.ts +10 -4
  58. package/dist/diffYears.mjs +4 -1
  59. package/dist/diffYears.mjs.map +1 -1
  60. package/dist/format.mjs +2 -3
  61. package/dist/format.mjs.map +1 -1
  62. package/dist/hourEnd.d.ts +3 -3
  63. package/dist/hourEnd.mjs.map +1 -1
  64. package/dist/hourStart.d.ts +3 -3
  65. package/dist/hourStart.mjs +1 -1
  66. package/dist/hourStart.mjs.map +1 -1
  67. package/dist/index.cjs +165 -145
  68. package/dist/index.cjs.map +1 -1
  69. package/dist/index.d.cts +256 -115
  70. package/dist/index.d.ts +5 -1
  71. package/dist/index.mjs +8 -0
  72. package/dist/index.mjs.map +1 -1
  73. package/dist/isAfter.d.ts +6 -6
  74. package/dist/isAfter.mjs.map +1 -1
  75. package/dist/isBefore.d.ts +5 -5
  76. package/dist/isBefore.mjs.map +1 -1
  77. package/dist/isEqual.d.ts +13 -4
  78. package/dist/isEqual.mjs.map +1 -1
  79. package/dist/isFuture.d.ts +10 -0
  80. package/dist/isFuture.mjs +9 -0
  81. package/dist/isFuture.mjs.map +1 -0
  82. package/dist/isPast.d.ts +10 -0
  83. package/dist/isPast.mjs +9 -0
  84. package/dist/isPast.mjs.map +1 -0
  85. package/dist/iso8601.d.ts +1 -1
  86. package/dist/iso8601.mjs +4 -7
  87. package/dist/iso8601.mjs.map +1 -1
  88. package/dist/minuteEnd.d.ts +3 -3
  89. package/dist/minuteEnd.mjs.map +1 -1
  90. package/dist/minuteStart.d.ts +3 -3
  91. package/dist/minuteStart.mjs +1 -1
  92. package/dist/minuteStart.mjs.map +1 -1
  93. package/dist/monthDays.d.ts +3 -3
  94. package/dist/monthDays.mjs.map +1 -1
  95. package/dist/monthEnd.d.ts +3 -3
  96. package/dist/monthEnd.mjs.map +1 -1
  97. package/dist/monthStart.d.ts +3 -3
  98. package/dist/monthStart.mjs +1 -1
  99. package/dist/monthStart.mjs.map +1 -1
  100. package/dist/nearestDay.d.ts +3 -3
  101. package/dist/nearestDay.mjs +2 -4
  102. package/dist/nearestDay.mjs.map +1 -1
  103. package/dist/offset.d.ts +5 -5
  104. package/dist/offset.mjs +3 -5
  105. package/dist/offset.mjs.map +1 -1
  106. package/dist/parse.mjs +33 -23
  107. package/dist/parse.mjs.map +1 -1
  108. package/dist/parts.mjs +14 -24
  109. package/dist/parts.mjs.map +1 -1
  110. package/dist/range.mjs +1 -2
  111. package/dist/range.mjs.map +1 -1
  112. package/dist/removeOffset.d.ts +4 -4
  113. package/dist/removeOffset.mjs.map +1 -1
  114. package/dist/sameDay.d.ts +8 -2
  115. package/dist/sameDay.mjs.map +1 -1
  116. package/dist/sameHour.d.ts +8 -2
  117. package/dist/sameHour.mjs.map +1 -1
  118. package/dist/sameMillisecond.d.ts +16 -0
  119. package/dist/sameMillisecond.mjs +11 -0
  120. package/dist/sameMillisecond.mjs.map +1 -0
  121. package/dist/sameMinute.d.ts +8 -2
  122. package/dist/sameMinute.mjs.map +1 -1
  123. package/dist/sameMonth.d.ts +16 -0
  124. package/dist/sameMonth.mjs +11 -0
  125. package/dist/sameMonth.mjs.map +1 -0
  126. package/dist/sameSecond.d.ts +8 -2
  127. package/dist/sameSecond.mjs.map +1 -1
  128. package/dist/sameYear.d.ts +8 -2
  129. package/dist/sameYear.mjs.map +1 -1
  130. package/dist/types.d.ts +15 -7
  131. package/dist/tzDate.d.ts +5 -3
  132. package/dist/tzDate.mjs.map +1 -1
  133. package/dist/weekEnd.d.ts +4 -4
  134. package/dist/weekEnd.mjs +1 -1
  135. package/dist/weekEnd.mjs.map +1 -1
  136. package/dist/weekStart.d.ts +4 -4
  137. package/dist/weekStart.mjs +2 -3
  138. package/dist/weekStart.mjs.map +1 -1
  139. package/dist/yearDays.d.ts +3 -3
  140. package/dist/yearDays.mjs.map +1 -1
  141. package/dist/yearEnd.d.ts +3 -3
  142. package/dist/yearEnd.mjs +1 -2
  143. package/dist/yearEnd.mjs.map +1 -1
  144. package/dist/yearStart.d.ts +3 -3
  145. package/dist/yearStart.mjs +2 -3
  146. package/dist/yearStart.mjs.map +1 -1
  147. package/package.json +32 -23
@@ -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":[]}
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.
@@ -140,4 +148,4 @@ interface FormatOptions {
140
148
  partFilter?: (part: Part) => boolean;
141
149
  }
142
150
 
143
- export type { DateInput, FilledPart, Format, FormatOptions, FormatPattern, FormatStyle, FormatStyleObj, FormatToken, NamedFormatOption, NamedFormats, ParseOptions, Part };
151
+ export type { DateInput, 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.0.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": "cd ./docs && pnpm nuxt 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": "cd ./docs && pnpm 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
+ }