@formkit/tempo 1.0.0 → 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 (48) 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/addMonth.mjs +2 -11
  6. package/dist/addMonth.mjs.map +1 -1
  7. package/dist/addYear.mjs +6 -11
  8. package/dist/addYear.mjs.map +1 -1
  9. package/dist/bundle.d.ts +110 -1
  10. package/dist/bundle.mjs +214 -46
  11. package/dist/bundle.mjs.map +1 -1
  12. package/dist/diff.d.ts +38 -0
  13. package/dist/diff.mjs +86 -0
  14. package/dist/diff.mjs.map +1 -0
  15. package/dist/handleDateOverflow.d.ts +12 -0
  16. package/dist/handleDateOverflow.mjs +18 -0
  17. package/dist/handleDateOverflow.mjs.map +1 -0
  18. package/dist/index.cjs +223 -46
  19. package/dist/index.cjs.map +1 -1
  20. package/dist/index.d.cts +110 -1
  21. package/dist/index.d.ts +10 -1
  22. package/dist/index.mjs +18 -0
  23. package/dist/index.mjs.map +1 -1
  24. package/dist/offset.mjs +14 -12
  25. package/dist/offset.mjs.map +1 -1
  26. package/dist/setDayOfMonth.d.ts +11 -0
  27. package/dist/setDayOfMonth.mjs +16 -0
  28. package/dist/setDayOfMonth.mjs.map +1 -0
  29. package/dist/setHour.d.ts +10 -0
  30. package/dist/setHour.mjs +11 -0
  31. package/dist/setHour.mjs.map +1 -0
  32. package/dist/setMilliseconds.d.ts +10 -0
  33. package/dist/setMilliseconds.mjs +11 -0
  34. package/dist/setMilliseconds.mjs.map +1 -0
  35. package/dist/setMinutes.d.ts +10 -0
  36. package/dist/setMinutes.mjs +11 -0
  37. package/dist/setMinutes.mjs.map +1 -0
  38. package/dist/setMonth.d.ts +11 -0
  39. package/dist/setMonth.mjs +9 -0
  40. package/dist/setMonth.mjs.map +1 -0
  41. package/dist/setSeconds.d.ts +10 -0
  42. package/dist/setSeconds.mjs +11 -0
  43. package/dist/setSeconds.mjs.map +1 -0
  44. package/dist/setYear.d.ts +11 -0
  45. package/dist/setYear.mjs +9 -0
  46. package/dist/setYear.mjs.map +1 -0
  47. package/dist/types.d.ts +15 -1
  48. package/package.json +3 -3
package/dist/index.d.cts CHANGED
@@ -147,6 +147,28 @@ interface FormatOptions {
147
147
  */
148
148
  partFilter?: (part: Part) => boolean;
149
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
+ }
164
+
165
+ /**
166
+ * Returns a new Date object with the duration applied.
167
+ * @param [inputDate] - A date to increment or null to increment from the current time.
168
+ * @param duration - An object with values for the amount of time to add to the original date.
169
+ * @param [dateOverflow] - Whether to allow month/year changes to overflow into a later month.
170
+ */
171
+ declare function add(inputDate: MaybeDateInput, duration: Duration, dateOverflow?: boolean): Date;
150
172
 
151
173
  /**
152
174
  * Returns a new date object 1/n days after the original one.
@@ -497,6 +519,58 @@ declare function sameYear(inputDateA: DateInput, inputDateB?: MaybeDateInput): b
497
519
  */
498
520
  declare function sameYear(inputDateA: MaybeDateInput, inputDateB: DateInput): boolean;
499
521
 
522
+ /**
523
+ * set the millisecond of a date object
524
+ * @param [inputDate] - a date or null for current time
525
+ * @param ms - the milliseconds you want the date set to (0 - 999) (can over/underflow)
526
+ */
527
+ declare function setMilliseconds(inputDate: MaybeDateInput, ms: number): Date;
528
+
529
+ /**
530
+ * set the second of a date object
531
+ * @param [inputDate] - a date or null for current time
532
+ * @param second - the second you want the date set to (0 - 59) (can over/underflow)
533
+ */
534
+ declare function setSeconds(inputDate: MaybeDateInput, second: number): Date;
535
+
536
+ /**
537
+ * set the minute of a date object
538
+ * @param [inputDate] - a date or null for current time
539
+ * @param minute - the minute you want the date set to (0 - 59) (can over/underflow)
540
+ */
541
+ declare function setMinutes(inputDate: MaybeDateInput, minute: number): Date;
542
+
543
+ /**
544
+ * set the hour of a date object
545
+ * @param [inputDate] - a date or null for current time
546
+ * @param hour - the hour you want the date set to (0 - 23) (can over/underflow)
547
+ */
548
+ declare function setHour(inputDate: MaybeDateInput, hour: number): Date;
549
+
550
+ /**
551
+ * set the day of the month in a date object
552
+ * @param [inputDate] - a date or null for current time
553
+ * @param day - the day of the month you want the date set to (1-28/29/30/31) (can over/underflow)
554
+ * @param [dateOverflow] - Whether or not to allow the date to overflow to another month if the given day isn't in the current month
555
+ */
556
+ declare function setDayOfMonth(inputDate: MaybeDateInput, day: number, dateOverflow?: boolean): Date;
557
+
558
+ /**
559
+ * set the month of a date
560
+ * @param [inputDate] - a date or null for current time
561
+ * @param month - the zero-based month to set (0-11, where 0 is January) (can over/underflow)
562
+ * @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.
563
+ */
564
+ declare function setMonth(inputDate: MaybeDateInput, month: number, dateOverflow?: boolean): Date;
565
+
566
+ /**
567
+ * set the year of a date object
568
+ * @param inputDate - a date or null for current time
569
+ * @param year - the full year you want the date to be set to
570
+ * @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.
571
+ */
572
+ declare function setYear(inputDate: MaybeDateInput, year: number, dateOverflow?: boolean): Date;
573
+
500
574
  /**
501
575
  * Returns a Date object for the last day at the last second of the given week.
502
576
  * Defaults to Sunday as the first day of the week:
@@ -707,4 +781,39 @@ declare function diffYears(dateA: DateInput, dateB?: MaybeDateInput): number;
707
781
  */
708
782
  declare function diffYears(dateA: MaybeDateInput, dateB: DateInput): number;
709
783
 
710
- export { type DateInput, type ExtendedPartTypes, type FilledPart, type Format, type FormatOptions, type FormatPattern, type FormatStyle, type FormatStyleObj, type FormatToken, type MaybeDateInput, type NamedFormatOption, type NamedFormats, type ParseOptions, type Part, addDay, addHour, addMillisecond, addMinute, addMonth, addSecond, addYear, ap, applyOffset, date, dayEnd, dayOfYear, dayStart, diffDays, diffHours, diffMilliseconds, diffMinutes, diffMonths, diffSeconds, diffWeeks, diffYears, format, formatStr, fourDigitYear, hourEnd, hourStart, isAfter, isBefore, isEqual, isFuture, isPast, iso8601, minuteEnd, minuteStart, monthDays, monthEnd, monthStart, nearestDay, offset, parse, parseParts, parts, range, removeOffset, sameDay, sameHour, sameMillisecond, sameMinute, sameSecond, sameYear, tzDate, weekEnd, weekStart, yearDays, yearEnd, yearStart };
784
+ type DurationKey = keyof Duration;
785
+ /**
786
+ * Options for `diff` function
787
+ */
788
+ interface DiffOptions {
789
+ /**
790
+ * whether the difference should be absolute (not negative)
791
+ */
792
+ abs?: boolean;
793
+ /**
794
+ * units you want to skip, for example weeks
795
+ */
796
+ skip?: DurationKey[] | Set<DurationKey>;
797
+ }
798
+ /**
799
+ * Returns the difference between 2 dates in an object
800
+ * @param dateA - A date to compare with the right date
801
+ * @param [dateB] - A date to compare with the left date or nothing to compare with the current time
802
+ * @param [options] additional options
803
+ * @param [options.skip] units you want skip
804
+ * @param [options.abs] whether the difference should be absolute
805
+ * @returns an object which could be used with `Intl.DurationFormat.format'`
806
+ */
807
+ declare function diff(dateA: DateInput, dateB?: MaybeDateInput, options?: DiffOptions): Duration;
808
+ /**
809
+ * Returns the difference between 2 dates in an object
810
+ * @param [dateA] - A date to compare with the right date or null to compare with the current time
811
+ * @param dateB - A date to compare with the left date
812
+ * @param [options] additional options
813
+ * @param [options.skip] units you want skip
814
+ * @param [options.abs] whether the difference should be absolute
815
+ * @returns an object which could be used with `Intl.DurationFormat.format'`
816
+ */
817
+ declare function diff(dateA: MaybeDateInput, dateB: DateInput, options?: DiffOptions): Duration;
818
+
819
+ export { type DateInput, type DiffOptions, type Duration, type DurationObj, type ExtendedPartTypes, type FilledPart, type Format, type FormatOptions, type FormatPattern, type FormatStyle, type FormatStyleObj, type FormatToken, type MaybeDateInput, type NamedFormatOption, type NamedFormats, type ParseOptions, type Part, add, addDay, addHour, addMillisecond, addMinute, addMonth, addSecond, addYear, ap, applyOffset, date, dayEnd, dayOfYear, dayStart, diff, diffDays, diffHours, diffMilliseconds, diffMinutes, diffMonths, diffSeconds, diffWeeks, diffYears, format, formatStr, fourDigitYear, hourEnd, hourStart, isAfter, isBefore, isEqual, isFuture, isPast, iso8601, minuteEnd, minuteStart, monthDays, monthEnd, monthStart, nearestDay, offset, parse, parseParts, parts, range, removeOffset, sameDay, sameHour, sameMillisecond, sameMinute, sameSecond, sameYear, setDayOfMonth, setHour, setMilliseconds, setMinutes, setMonth, setSeconds, setYear, tzDate, weekEnd, weekStart, yearDays, yearEnd, yearStart };
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ export { add } from './add.js';
1
2
  export { addDay } from './addDay.js';
2
3
  export { addMonth } from './addMonth.js';
3
4
  export { addYear } from './addYear.js';
@@ -35,6 +36,13 @@ export { sameMillisecond } from './sameMillisecond.js';
35
36
  export { sameMinute } from './sameMinute.js';
36
37
  export { sameHour } from './sameHour.js';
37
38
  export { sameYear } from './sameYear.js';
39
+ export { setMilliseconds } from './setMilliseconds.js';
40
+ export { setSeconds } from './setSeconds.js';
41
+ export { setMinutes } from './setMinutes.js';
42
+ export { setHour } from './setHour.js';
43
+ export { setDayOfMonth } from './setDayOfMonth.js';
44
+ export { setMonth } from './setMonth.js';
45
+ export { setYear } from './setYear.js';
38
46
  export { weekEnd } from './weekEnd.js';
39
47
  export { weekStart } from './weekStart.js';
40
48
  export { yearDays } from './yearDays.js';
@@ -45,7 +53,7 @@ export { isAfter } from './isAfter.js';
45
53
  export { isEqual } from './isEqual.js';
46
54
  export { isPast } from './isPast.js';
47
55
  export { isFuture } from './isFuture.js';
48
- export { DateInput, ExtendedPartTypes, FilledPart, Format, FormatOptions, FormatPattern, FormatStyle, FormatStyleObj, FormatToken, MaybeDateInput, NamedFormatOption, NamedFormats, ParseOptions, Part } from './types.js';
56
+ export { DateInput, Duration, DurationObj, ExtendedPartTypes, FilledPart, Format, FormatOptions, FormatPattern, FormatStyle, FormatStyleObj, FormatToken, MaybeDateInput, NamedFormatOption, NamedFormats, ParseOptions, Part } from './types.js';
49
57
  export { diffMilliseconds } from './diffMilliseconds.js';
50
58
  export { diffSeconds } from './diffSeconds.js';
51
59
  export { diffMinutes } from './diffMinutes.js';
@@ -54,5 +62,6 @@ export { diffDays } from './diffDays.js';
54
62
  export { diffWeeks } from './diffWeeks.js';
55
63
  export { diffMonths } from './diffMonths.js';
56
64
  export { diffYears } from './diffYears.js';
65
+ export { DiffOptions, diff } from './diff.js';
57
66
  import './common.js';
58
67
  import './diffRound.js';
package/dist/index.mjs CHANGED
@@ -1,4 +1,5 @@
1
1
  // src/index.ts
2
+ import { add } from "./add.mjs";
2
3
  import { addDay } from "./addDay.mjs";
3
4
  import { addMonth } from "./addMonth.mjs";
4
5
  import { addYear } from "./addYear.mjs";
@@ -37,6 +38,13 @@ import { sameMillisecond } from "./sameMillisecond.mjs";
37
38
  import { sameMinute } from "./sameMinute.mjs";
38
39
  import { sameHour } from "./sameHour.mjs";
39
40
  import { sameYear } from "./sameYear.mjs";
41
+ import { setMilliseconds } from "./setMilliseconds.mjs";
42
+ import { setSeconds } from "./setSeconds.mjs";
43
+ import { setMinutes } from "./setMinutes.mjs";
44
+ import { setHour } from "./setHour.mjs";
45
+ import { setDayOfMonth } from "./setDayOfMonth.mjs";
46
+ import { setMonth } from "./setMonth.mjs";
47
+ import { setYear } from "./setYear.mjs";
40
48
  import { weekEnd } from "./weekEnd.mjs";
41
49
  import { weekStart } from "./weekStart.mjs";
42
50
  import { yearDays } from "./yearDays.mjs";
@@ -56,7 +64,9 @@ import { diffDays } from "./diffDays.mjs";
56
64
  import { diffWeeks } from "./diffWeeks.mjs";
57
65
  import { diffMonths } from "./diffMonths.mjs";
58
66
  import { diffYears } from "./diffYears.mjs";
67
+ import { diff } from "./diff.mjs";
59
68
  export {
69
+ add,
60
70
  addDay,
61
71
  addHour,
62
72
  addMillisecond,
@@ -70,6 +80,7 @@ export {
70
80
  dayEnd,
71
81
  dayOfYear,
72
82
  dayStart,
83
+ diff,
73
84
  diffDays,
74
85
  diffHours,
75
86
  diffMilliseconds,
@@ -107,6 +118,13 @@ export {
107
118
  sameMinute,
108
119
  sameSecond,
109
120
  sameYear,
121
+ setDayOfMonth,
122
+ setHour,
123
+ setMilliseconds,
124
+ setMinutes,
125
+ setMonth,
126
+ setSeconds,
127
+ setYear,
110
128
  tzDate,
111
129
  weekEnd,
112
130
  weekStart,
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["export { addDay } from \"./addDay\"\nexport { addMonth } from \"./addMonth\"\nexport { addYear } from \"./addYear\"\nexport { addHour } from \"./addHour\"\nexport { addMinute } from \"./addMinute\"\nexport { addSecond } from \"./addSecond\"\nexport { addMillisecond } from \"./addMillisecond\"\nexport { ap } from \"./ap\"\nexport { applyOffset } from \"./applyOffset\"\nexport { date } from \"./date\"\nexport { tzDate } from \"./tzDate\"\nexport { dayOfYear } from \"./dayOfYear\"\nexport { dayEnd } from \"./dayEnd\"\nexport { dayStart } from \"./dayStart\"\nexport { format } from \"./format\"\nexport { formatStr } from \"./formatStr\"\nexport { fourDigitYear } from \"./fourDigitYear\"\nexport { hourEnd } from \"./hourEnd\"\nexport { hourStart } from \"./hourStart\"\nexport { iso8601 } from \"./iso8601\"\nexport { minuteEnd } from \"./minuteEnd\"\nexport { minuteStart } from \"./minuteStart\"\nexport { monthDays } from \"./monthDays\"\nexport { monthEnd } from \"./monthEnd\"\nexport { monthStart } from \"./monthStart\"\nexport { nearestDay } from \"./nearestDay\"\nexport { offset } from \"./offset\"\nexport { parse } from \"./parse\"\nexport { parseParts } from \"./parse\"\nexport { parts } from \"./parts\"\nexport { range } from \"./range\"\nexport { removeOffset } from \"./removeOffset\"\nexport { sameDay } from \"./sameDay\"\nexport { sameSecond } from \"./sameSecond\"\nexport { sameMillisecond } from \"./sameMillisecond\"\nexport { sameMinute } from \"./sameMinute\"\nexport { sameHour } from \"./sameHour\"\nexport { sameYear } from \"./sameYear\"\nexport { weekEnd } from \"./weekEnd\"\nexport { weekStart } from \"./weekStart\"\nexport { yearDays } from \"./yearDays\"\nexport { yearStart } from \"./yearStart\"\nexport { yearEnd } from \"./yearEnd\"\nexport { isBefore } from \"./isBefore\"\nexport { isAfter } from \"./isAfter\"\nexport { isEqual } from \"./isEqual\"\nexport { isPast } from \"./isPast\"\nexport { isFuture } from \"./isFuture\"\nexport * from \"./types\"\nexport { diffMilliseconds } from \"./diffMilliseconds\"\nexport { diffSeconds } from \"./diffSeconds\"\nexport { diffMinutes } from \"./diffMinutes\"\nexport { diffHours } from \"./diffHours\"\nexport { diffDays } from \"./diffDays\"\nexport { diffWeeks } from \"./diffWeeks\"\nexport { diffMonths } from \"./diffMonths\"\nexport { diffYears } from \"./diffYears\"\n"],"mappings":";AAAA,SAAS,cAAc;AACvB,SAAS,gBAAgB;AACzB,SAAS,eAAe;AACxB,SAAS,eAAe;AACxB,SAAS,iBAAiB;AAC1B,SAAS,iBAAiB;AAC1B,SAAS,sBAAsB;AAC/B,SAAS,UAAU;AACnB,SAAS,mBAAmB;AAC5B,SAAS,YAAY;AACrB,SAAS,cAAc;AACvB,SAAS,iBAAiB;AAC1B,SAAS,cAAc;AACvB,SAAS,gBAAgB;AACzB,SAAS,cAAc;AACvB,SAAS,iBAAiB;AAC1B,SAAS,qBAAqB;AAC9B,SAAS,eAAe;AACxB,SAAS,iBAAiB;AAC1B,SAAS,eAAe;AACxB,SAAS,iBAAiB;AAC1B,SAAS,mBAAmB;AAC5B,SAAS,iBAAiB;AAC1B,SAAS,gBAAgB;AACzB,SAAS,kBAAkB;AAC3B,SAAS,kBAAkB;AAC3B,SAAS,cAAc;AACvB,SAAS,aAAa;AACtB,SAAS,kBAAkB;AAC3B,SAAS,aAAa;AACtB,SAAS,aAAa;AACtB,SAAS,oBAAoB;AAC7B,SAAS,eAAe;AACxB,SAAS,kBAAkB;AAC3B,SAAS,uBAAuB;AAChC,SAAS,kBAAkB;AAC3B,SAAS,gBAAgB;AACzB,SAAS,gBAAgB;AACzB,SAAS,eAAe;AACxB,SAAS,iBAAiB;AAC1B,SAAS,gBAAgB;AACzB,SAAS,iBAAiB;AAC1B,SAAS,eAAe;AACxB,SAAS,gBAAgB;AACzB,SAAS,eAAe;AACxB,SAAS,eAAe;AACxB,SAAS,cAAc;AACvB,SAAS,gBAAgB;AACzB,cAAc;AACd,SAAS,wBAAwB;AACjC,SAAS,mBAAmB;AAC5B,SAAS,mBAAmB;AAC5B,SAAS,iBAAiB;AAC1B,SAAS,gBAAgB;AACzB,SAAS,iBAAiB;AAC1B,SAAS,kBAAkB;AAC3B,SAAS,iBAAiB;","names":[]}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["export { add } from \"./add\"\nexport { addDay } from \"./addDay\"\nexport { addMonth } from \"./addMonth\"\nexport { addYear } from \"./addYear\"\nexport { addHour } from \"./addHour\"\nexport { addMinute } from \"./addMinute\"\nexport { addSecond } from \"./addSecond\"\nexport { addMillisecond } from \"./addMillisecond\"\nexport { ap } from \"./ap\"\nexport { applyOffset } from \"./applyOffset\"\nexport { date } from \"./date\"\nexport { tzDate } from \"./tzDate\"\nexport { dayOfYear } from \"./dayOfYear\"\nexport { dayEnd } from \"./dayEnd\"\nexport { dayStart } from \"./dayStart\"\nexport { format } from \"./format\"\nexport { formatStr } from \"./formatStr\"\nexport { fourDigitYear } from \"./fourDigitYear\"\nexport { hourEnd } from \"./hourEnd\"\nexport { hourStart } from \"./hourStart\"\nexport { iso8601 } from \"./iso8601\"\nexport { minuteEnd } from \"./minuteEnd\"\nexport { minuteStart } from \"./minuteStart\"\nexport { monthDays } from \"./monthDays\"\nexport { monthEnd } from \"./monthEnd\"\nexport { monthStart } from \"./monthStart\"\nexport { nearestDay } from \"./nearestDay\"\nexport { offset } from \"./offset\"\nexport { parse } from \"./parse\"\nexport { parseParts } from \"./parse\"\nexport { parts } from \"./parts\"\nexport { range } from \"./range\"\nexport { removeOffset } from \"./removeOffset\"\nexport { sameDay } from \"./sameDay\"\nexport { sameSecond } from \"./sameSecond\"\nexport { sameMillisecond } from \"./sameMillisecond\"\nexport { sameMinute } from \"./sameMinute\"\nexport { sameHour } from \"./sameHour\"\nexport { sameYear } from \"./sameYear\"\nexport { setMilliseconds } from \"./setMilliseconds\"\nexport { setSeconds } from \"./setSeconds\"\nexport { setMinutes } from \"./setMinutes\"\nexport { setHour } from \"./setHour\"\nexport { setDayOfMonth } from \"./setDayOfMonth\"\nexport { setMonth } from \"./setMonth\"\nexport { setYear } from \"./setYear\"\nexport { weekEnd } from \"./weekEnd\"\nexport { weekStart } from \"./weekStart\"\nexport { yearDays } from \"./yearDays\"\nexport { yearStart } from \"./yearStart\"\nexport { yearEnd } from \"./yearEnd\"\nexport { isBefore } from \"./isBefore\"\nexport { isAfter } from \"./isAfter\"\nexport { isEqual } from \"./isEqual\"\nexport { isPast } from \"./isPast\"\nexport { isFuture } from \"./isFuture\"\nexport * from \"./types\"\nexport { diffMilliseconds } from \"./diffMilliseconds\"\nexport { diffSeconds } from \"./diffSeconds\"\nexport { diffMinutes } from \"./diffMinutes\"\nexport { diffHours } from \"./diffHours\"\nexport { diffDays } from \"./diffDays\"\nexport { diffWeeks } from \"./diffWeeks\"\nexport { diffMonths } from \"./diffMonths\"\nexport { diffYears } from \"./diffYears\"\nexport { diff, type DiffOptions } from \"./diff\"\n"],"mappings":";AAAA,SAAS,WAAW;AACpB,SAAS,cAAc;AACvB,SAAS,gBAAgB;AACzB,SAAS,eAAe;AACxB,SAAS,eAAe;AACxB,SAAS,iBAAiB;AAC1B,SAAS,iBAAiB;AAC1B,SAAS,sBAAsB;AAC/B,SAAS,UAAU;AACnB,SAAS,mBAAmB;AAC5B,SAAS,YAAY;AACrB,SAAS,cAAc;AACvB,SAAS,iBAAiB;AAC1B,SAAS,cAAc;AACvB,SAAS,gBAAgB;AACzB,SAAS,cAAc;AACvB,SAAS,iBAAiB;AAC1B,SAAS,qBAAqB;AAC9B,SAAS,eAAe;AACxB,SAAS,iBAAiB;AAC1B,SAAS,eAAe;AACxB,SAAS,iBAAiB;AAC1B,SAAS,mBAAmB;AAC5B,SAAS,iBAAiB;AAC1B,SAAS,gBAAgB;AACzB,SAAS,kBAAkB;AAC3B,SAAS,kBAAkB;AAC3B,SAAS,cAAc;AACvB,SAAS,aAAa;AACtB,SAAS,kBAAkB;AAC3B,SAAS,aAAa;AACtB,SAAS,aAAa;AACtB,SAAS,oBAAoB;AAC7B,SAAS,eAAe;AACxB,SAAS,kBAAkB;AAC3B,SAAS,uBAAuB;AAChC,SAAS,kBAAkB;AAC3B,SAAS,gBAAgB;AACzB,SAAS,gBAAgB;AACzB,SAAS,uBAAuB;AAChC,SAAS,kBAAkB;AAC3B,SAAS,kBAAkB;AAC3B,SAAS,eAAe;AACxB,SAAS,qBAAqB;AAC9B,SAAS,gBAAgB;AACzB,SAAS,eAAe;AACxB,SAAS,eAAe;AACxB,SAAS,iBAAiB;AAC1B,SAAS,gBAAgB;AACzB,SAAS,iBAAiB;AAC1B,SAAS,eAAe;AACxB,SAAS,gBAAgB;AACzB,SAAS,eAAe;AACxB,SAAS,eAAe;AACxB,SAAS,cAAc;AACvB,SAAS,gBAAgB;AACzB,cAAc;AACd,SAAS,wBAAwB;AACjC,SAAS,mBAAmB;AAC5B,SAAS,mBAAmB;AAC5B,SAAS,iBAAiB;AAC1B,SAAS,gBAAgB;AACzB,SAAS,iBAAiB;AAC1B,SAAS,kBAAkB;AAC3B,SAAS,iBAAiB;AAC1B,SAAS,YAA8B;","names":[]}
package/dist/offset.mjs CHANGED
@@ -1,25 +1,27 @@
1
1
  // src/offset.ts
2
2
  import { date } from "./date.mjs";
3
- import { normStr, secsToOffset } from "./common.mjs";
3
+ import { secsToOffset } from "./common.mjs";
4
4
  import { deviceTZ } from "./deviceTZ.mjs";
5
5
  function relativeTime(d, timeZone) {
6
6
  const utcParts = new Intl.DateTimeFormat("en-US", {
7
+ era: "short",
7
8
  year: "numeric",
8
- month: "2-digit",
9
- day: "2-digit",
10
- hour: "2-digit",
11
- minute: "2-digit",
12
- second: "2-digit",
9
+ month: "numeric",
10
+ day: "numeric",
11
+ hour: "numeric",
12
+ minute: "numeric",
13
+ second: "numeric",
13
14
  timeZone,
14
15
  hourCycle: "h23"
15
- }).formatToParts(d).map(normStr);
16
- const parts = {};
16
+ }).formatToParts(d);
17
+ const p = {};
17
18
  utcParts.forEach((part) => {
18
- parts[part.type] = part.value;
19
+ if (part.type !== "literal") p[part.type] = part.value;
19
20
  });
20
- return /* @__PURE__ */ new Date(
21
- `${parts.year}-${parts.month}-${parts.day}T${parts.hour}:${parts.minute}:${parts.second}Z`
22
- );
21
+ const year = p.era === "BC" ? 1 - Number(p.year) : Number(p.year);
22
+ const result = new Date(Date.UTC(0, 0, 1, Number(p.hour), Number(p.minute), Number(p.second)));
23
+ result.setUTCFullYear(year, Number(p.month) - 1, Number(p.day));
24
+ return result;
23
25
  }
24
26
  function offset(utcTime, tzA = "UTC", tzB = "device", timeZoneToken = "Z") {
25
27
  var _a;
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/offset.ts"],"sourcesContent":["import { date } from \"./date\"\nimport { normStr, secsToOffset, TimezoneToken } from \"./common\"\nimport { deviceTZ } from \"./deviceTZ\"\nimport type { DateInput, MaybeDateInput } from \"./types\"\n\n/**\n * Converts a date object from one timezone to that same time in UTC. This is\n * only for internal use.\n * @param d - A Date object\n * @param timeZone - A timezone string\n */\nfunction relativeTime(d: Date, timeZone: string): Date {\n const utcParts = new Intl.DateTimeFormat(\"en-US\", {\n year: \"numeric\",\n month: \"2-digit\",\n day: \"2-digit\",\n hour: \"2-digit\",\n minute: \"2-digit\",\n second: \"2-digit\",\n timeZone,\n hourCycle: \"h23\",\n })\n .formatToParts(d)\n .map(normStr)\n const parts: {\n year?: string\n month?: string\n day?: string\n hour?: string\n minute?: string\n second?: string\n } = {}\n utcParts.forEach((part) => {\n parts[part.type as keyof typeof parts] = part.value\n })\n return new Date(\n `${parts.year}-${parts.month}-${parts.day}T${parts.hour}:${parts.minute}:${parts.second}Z`\n )\n}\n\n/**\n * Returns the offset between two timezones on a given date. The results are\n * ISO8601 compatible offsets like -0800 or +0530.\n *\n * @param [dateInput] - (default: current time) The date on which to determine the offset\n * @param [tzA] - (default: UTC) The second timezone to compare determine the offset between.\n * @param [tzB] - (default: device) The first timezone to compare determine the offset between.\n */\nexport function offset(\n utcTime?: MaybeDateInput,\n tzA = \"UTC\",\n tzB = \"device\",\n timeZoneToken: TimezoneToken = \"Z\"\n): string {\n tzB = tzB === \"device\" ? deviceTZ() ?? \"utc\" : tzB\n const d = date(utcTime)\n const timeA = relativeTime(d, tzA)\n const timeB = relativeTime(d, tzB)\n const timeDiffInSecs = Math.round((timeB.getTime() - timeA.getTime()) / 1000)\n return secsToOffset(timeDiffInSecs, timeZoneToken)\n}\n"],"mappings":";AAAA,SAAS,YAAY;AACrB,SAAS,SAAS,oBAAmC;AACrD,SAAS,gBAAgB;AASzB,SAAS,aAAa,GAAS,UAAwB;AACrD,QAAM,WAAW,IAAI,KAAK,eAAe,SAAS;AAAA,IAChD,MAAM;AAAA,IACN,OAAO;AAAA,IACP,KAAK;AAAA,IACL,MAAM;AAAA,IACN,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR;AAAA,IACA,WAAW;AAAA,EACb,CAAC,EACE,cAAc,CAAC,EACf,IAAI,OAAO;AACd,QAAM,QAOF,CAAC;AACL,WAAS,QAAQ,CAAC,SAAS;AACzB,UAAM,KAAK,IAA0B,IAAI,KAAK;AAAA,EAChD,CAAC;AACD,SAAO,oBAAI;AAAA,IACT,GAAG,MAAM,IAAI,IAAI,MAAM,KAAK,IAAI,MAAM,GAAG,IAAI,MAAM,IAAI,IAAI,MAAM,MAAM,IAAI,MAAM,MAAM;AAAA,EACzF;AACF;AAUO,SAAS,OACd,SACA,MAAM,OACN,MAAM,UACN,gBAA+B,KACvB;AArDV;AAsDE,QAAM,QAAQ,YAAW,cAAS,MAAT,YAAc,QAAQ;AAC/C,QAAM,IAAI,KAAK,OAAO;AACtB,QAAM,QAAQ,aAAa,GAAG,GAAG;AACjC,QAAM,QAAQ,aAAa,GAAG,GAAG;AACjC,QAAM,iBAAiB,KAAK,OAAO,MAAM,QAAQ,IAAI,MAAM,QAAQ,KAAK,GAAI;AAC5E,SAAO,aAAa,gBAAgB,aAAa;AACnD;","names":[]}
1
+ {"version":3,"sources":["../src/offset.ts"],"sourcesContent":["import { date } from \"./date\"\nimport { secsToOffset, TimezoneToken } from \"./common\"\nimport { deviceTZ } from \"./deviceTZ\"\nimport type { MaybeDateInput } from \"./types\"\n\n/**\n * Converts a date object from one timezone to that same time in UTC. This is\n * only for internal use.\n * @param d - A Date object\n * @param timeZone - A timezone string\n */\nfunction relativeTime(d: Date, timeZone: string): Date {\n const utcParts = new Intl.DateTimeFormat(\"en-US\", {\n era: \"short\",\n year: \"numeric\",\n month: \"numeric\",\n day: \"numeric\",\n hour: \"numeric\",\n minute: \"numeric\",\n second: \"numeric\",\n timeZone,\n hourCycle: \"h23\",\n }).formatToParts(d)\n const p: Record<string, string> = {}\n utcParts.forEach((part) => {\n if (part.type !== \"literal\") p[part.type] = part.value\n })\n // BC year N in Intl = ISO year (1 - N), e.g. 1 BC = year 0, 2 BC = year -1\n const year = p.era === \"BC\" ? 1 - Number(p.year) : Number(p.year)\n const result = new Date(Date.UTC(0, 0, 1, Number(p.hour), Number(p.minute), Number(p.second)))\n // setUTCFullYear with year, month, day together avoids Date.UTC's 0-99 year mapping\n // and ensures leap day validation uses the correct year\n result.setUTCFullYear(year, Number(p.month) - 1, Number(p.day))\n return result\n}\n\n/**\n * Returns the offset between two timezones on a given date. The results are\n * ISO8601 compatible offsets like -0800 or +0530.\n *\n * @param [dateInput] - (default: current time) The date on which to determine the offset\n * @param [tzA] - (default: UTC) The second timezone to compare determine the offset between.\n * @param [tzB] - (default: device) The first timezone to compare determine the offset between.\n */\nexport function offset(\n utcTime?: MaybeDateInput,\n tzA = \"UTC\",\n tzB = \"device\",\n timeZoneToken: TimezoneToken = \"Z\"\n): string {\n tzB = tzB === \"device\" ? deviceTZ() ?? \"utc\" : tzB\n const d = date(utcTime)\n const timeA = relativeTime(d, tzA)\n const timeB = relativeTime(d, tzB)\n const timeDiffInSecs = Math.round((timeB.getTime() - timeA.getTime()) / 1000)\n return secsToOffset(timeDiffInSecs, timeZoneToken)\n}\n"],"mappings":";AAAA,SAAS,YAAY;AACrB,SAAS,oBAAmC;AAC5C,SAAS,gBAAgB;AASzB,SAAS,aAAa,GAAS,UAAwB;AACrD,QAAM,WAAW,IAAI,KAAK,eAAe,SAAS;AAAA,IAChD,KAAK;AAAA,IACL,MAAM;AAAA,IACN,OAAO;AAAA,IACP,KAAK;AAAA,IACL,MAAM;AAAA,IACN,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR;AAAA,IACA,WAAW;AAAA,EACb,CAAC,EAAE,cAAc,CAAC;AAClB,QAAM,IAA4B,CAAC;AACnC,WAAS,QAAQ,CAAC,SAAS;AACzB,QAAI,KAAK,SAAS,UAAW,GAAE,KAAK,IAAI,IAAI,KAAK;AAAA,EACnD,CAAC;AAED,QAAM,OAAO,EAAE,QAAQ,OAAO,IAAI,OAAO,EAAE,IAAI,IAAI,OAAO,EAAE,IAAI;AAChE,QAAM,SAAS,IAAI,KAAK,KAAK,IAAI,GAAG,GAAG,GAAG,OAAO,EAAE,IAAI,GAAG,OAAO,EAAE,MAAM,GAAG,OAAO,EAAE,MAAM,CAAC,CAAC;AAG7F,SAAO,eAAe,MAAM,OAAO,EAAE,KAAK,IAAI,GAAG,OAAO,EAAE,GAAG,CAAC;AAC9D,SAAO;AACT;AAUO,SAAS,OACd,SACA,MAAM,OACN,MAAM,UACN,gBAA+B,KACvB;AAjDV;AAkDE,QAAM,QAAQ,YAAW,cAAS,MAAT,YAAc,QAAQ;AAC/C,QAAM,IAAI,KAAK,OAAO;AACtB,QAAM,QAAQ,aAAa,GAAG,GAAG;AACjC,QAAM,QAAQ,aAAa,GAAG,GAAG;AACjC,QAAM,iBAAiB,KAAK,OAAO,MAAM,QAAQ,IAAI,MAAM,QAAQ,KAAK,GAAI;AAC5E,SAAO,aAAa,gBAAgB,aAAa;AACnD;","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
@@ -147,5 +147,19 @@ interface FormatOptions {
147
147
  */
148
148
  partFilter?: (part: Part) => boolean;
149
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
+ }
150
164
 
151
- export type { DateInput, ExtendedPartTypes, FilledPart, Format, FormatOptions, FormatPattern, FormatStyle, FormatStyleObj, FormatToken, MaybeDateInput, NamedFormatOption, NamedFormats, ParseOptions, Part };
165
+ export type { DateInput, Duration, DurationObj, ExtendedPartTypes, FilledPart, Format, FormatOptions, FormatPattern, FormatStyle, FormatStyleObj, FormatToken, MaybeDateInput, NamedFormatOption, NamedFormats, ParseOptions, Part };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@formkit/tempo",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "packageManager": "pnpm@10.11.0",
5
5
  "description": "The easiest way to work with dates in JavaScript and TypeScript.",
6
6
  "type": "module",
@@ -33,11 +33,11 @@
33
33
  "url": "https://github.com/formkit/tempo/issues"
34
34
  },
35
35
  "scripts": {
36
- "dev": "cd ./docs && pnpm nuxt dev",
36
+ "dev": "npm --prefix ./docs run dev",
37
37
  "build": "tsup",
38
38
  "post:build": "node scripts/size-limit/index.js || echo 'Size limit check skipped'",
39
39
  "test": "TZ=\"America/New_York\" vitest",
40
- "docs-build": "cd ./docs && pnpm run build",
40
+ "docs-build": "npm --prefix ./docs run build",
41
41
  "publint": "publint",
42
42
  "release": "pnpm build && bumpp --push",
43
43
  "size": "npm run build && size-limit"