@formkit/tempo 1.2.0 → 1.4.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.
- package/dist/bundle.d.ts +826 -0
- package/dist/bundle.mjs +33 -23
- package/dist/bundle.mjs.map +1 -1
- package/dist/common.mjs +3 -2
- package/dist/common.mjs.map +1 -1
- package/dist/dayOfYear.mjs +1 -3
- package/dist/dayOfYear.mjs.map +1 -1
- package/dist/diffDays.mjs +5 -7
- package/dist/diffDays.mjs.map +1 -1
- package/dist/diffMonths.mjs +4 -1
- package/dist/diffMonths.mjs.map +1 -1
- package/dist/diffWeeks.d.ts +5 -5
- package/dist/diffWeeks.mjs +5 -6
- package/dist/diffWeeks.mjs.map +1 -1
- package/dist/hourEnd.mjs +5 -0
- package/dist/hourEnd.mjs.map +1 -1
- package/dist/hourStart.mjs +4 -0
- package/dist/hourStart.mjs.map +1 -1
- package/dist/index.cjs +33 -23
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -4
- package/dist/minuteEnd.mjs +3 -1
- package/dist/minuteEnd.mjs.map +1 -1
- package/dist/minuteStart.mjs +1 -1
- package/dist/minuteStart.mjs.map +1 -1
- package/dist/nearestDay.mjs +4 -4
- package/dist/nearestDay.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -748,19 +748,19 @@ declare function diffDays(dateA: DateInput, dateB?: MaybeDateInput, roundingMeth
|
|
|
748
748
|
declare function diffDays(dateA: MaybeDateInput, dateB: DateInput, roundingMethod?: DiffRoundingMethod): number;
|
|
749
749
|
|
|
750
750
|
/**
|
|
751
|
-
* Returns the difference between 2 dates in
|
|
751
|
+
* Returns the difference between 2 dates in weeks.
|
|
752
752
|
* @param dateA - A date to compare with the right date
|
|
753
753
|
* @param [dateB] - A date to compare with the left date or nothing to compare with the current time
|
|
754
754
|
* @param [roundingMethod] - the rounding method to use, default: trunc
|
|
755
755
|
*/
|
|
756
|
-
declare function diffWeeks(dateA: DateInput, dateB
|
|
756
|
+
declare function diffWeeks(dateA: DateInput, dateB?: MaybeDateInput, roundingMethod?: DiffRoundingMethod): number;
|
|
757
757
|
/**
|
|
758
|
-
* Returns the difference between 2 dates in
|
|
758
|
+
* Returns the difference between 2 dates in weeks.
|
|
759
759
|
* @param [dateA] - A date to compare with the right date or null to compare with the current time
|
|
760
760
|
* @param dateB - A date to compare with the left date
|
|
761
761
|
* @param [roundingMethod] - the rounding method to use, default: trunc
|
|
762
762
|
*/
|
|
763
|
-
declare function diffWeeks(dateA:
|
|
763
|
+
declare function diffWeeks(dateA: MaybeDateInput, dateB: DateInput, roundingMethod?: DiffRoundingMethod): number;
|
|
764
764
|
|
|
765
765
|
/**
|
|
766
766
|
* Returns the difference between 2 dates in months.
|
package/dist/minuteEnd.mjs
CHANGED
package/dist/minuteEnd.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/minuteEnd.ts"],"sourcesContent":["import { date } from \"./date\"\nimport type { MaybeDateInput } from \"./types\"\n\n/**\n * Returns a Date object for end of the given minute.\n * @param [inputDate] - A string, Date object or nothing for the current time\n */\nexport function minuteEnd(inputDate?: MaybeDateInput): Date {\n const d = date(inputDate)\n d.
|
|
1
|
+
{"version":3,"sources":["../src/minuteEnd.ts"],"sourcesContent":["import { date } from \"./date\"\nimport type { MaybeDateInput } from \"./types\"\n\n/**\n * Returns a Date object for end of the given minute.\n * @param [inputDate] - A string, Date object or nothing for the current time\n */\nexport function minuteEnd(inputDate?: MaybeDateInput): Date {\n const d = date(inputDate)\n // Shift the timestamp instead of using local setters, which pick the first\n // occurrence of a repeated hour (DST fall-back).\n d.setTime(\n d.getTime() + (59 - d.getSeconds()) * 1000 + (999 - d.getMilliseconds())\n )\n return d\n}\n"],"mappings":";AAAA,SAAS,YAAY;AAOd,SAAS,UAAU,WAAkC;AAC1D,QAAM,IAAI,KAAK,SAAS;AAGxB,IAAE;AAAA,IACA,EAAE,QAAQ,KAAK,KAAK,EAAE,WAAW,KAAK,OAAQ,MAAM,EAAE,gBAAgB;AAAA,EACxE;AACA,SAAO;AACT;","names":[]}
|
package/dist/minuteStart.mjs
CHANGED
package/dist/minuteStart.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/minuteStart.ts"],"sourcesContent":["import { date } from \"./date\"\nimport type { MaybeDateInput } from \"./types\"\n\n/**\n * Returns a Date object for start of the given minute.\n * @param [inputDate] - A string, Date object or nothing for the current time\n */\nexport function minuteStart(inputDate?: MaybeDateInput): Date {\n const d = date(inputDate)\n d.
|
|
1
|
+
{"version":3,"sources":["../src/minuteStart.ts"],"sourcesContent":["import { date } from \"./date\"\nimport type { MaybeDateInput } from \"./types\"\n\n/**\n * Returns a Date object for start of the given minute.\n * @param [inputDate] - A string, Date object or nothing for the current time\n */\nexport function minuteStart(inputDate?: MaybeDateInput): Date {\n const d = date(inputDate)\n // Shift the timestamp instead of using local setters, which pick the first\n // occurrence of a repeated hour (DST fall-back).\n d.setTime(d.getTime() - d.getSeconds() * 1000 - d.getMilliseconds())\n return d\n}\n"],"mappings":";AAAA,SAAS,YAAY;AAOd,SAAS,YAAY,WAAkC;AAC5D,QAAM,IAAI,KAAK,SAAS;AAGxB,IAAE,QAAQ,EAAE,QAAQ,IAAI,EAAE,WAAW,IAAI,MAAO,EAAE,gBAAgB,CAAC;AACnE,SAAO;AACT;","names":[]}
|
package/dist/nearestDay.mjs
CHANGED
|
@@ -10,23 +10,23 @@ function nearestDay(inputDate, search, constraint = 7) {
|
|
|
10
10
|
const d = date(inputDate);
|
|
11
11
|
switch (constraint) {
|
|
12
12
|
case "month":
|
|
13
|
-
decrements = d.getDate();
|
|
13
|
+
decrements = d.getDate() - 1;
|
|
14
14
|
increments = monthDays(d) - d.getDate();
|
|
15
15
|
break;
|
|
16
16
|
case "week":
|
|
17
|
-
decrements = d.getDay()
|
|
17
|
+
decrements = d.getDay();
|
|
18
18
|
increments = 6 - d.getDay();
|
|
19
19
|
break;
|
|
20
20
|
case "year":
|
|
21
21
|
const total = yearDays(d);
|
|
22
22
|
const day = dayOfYear(d);
|
|
23
|
-
decrements = day;
|
|
23
|
+
decrements = day - 1;
|
|
24
24
|
increments = total - day;
|
|
25
25
|
break;
|
|
26
26
|
default:
|
|
27
27
|
increments = decrements = constraint;
|
|
28
28
|
}
|
|
29
|
-
for (let i = 0; i <= increments || i
|
|
29
|
+
for (let i = 0; i <= increments || i <= decrements; i++) {
|
|
30
30
|
if (i <= increments) {
|
|
31
31
|
const next = addDay(d, i);
|
|
32
32
|
if (search(next)) return next;
|
package/dist/nearestDay.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/nearestDay.ts"],"sourcesContent":["import { date } from \"./date\"\nimport { monthDays } from \"./monthDays\"\nimport { yearDays } from \"./yearDays\"\nimport { dayOfYear } from \"./dayOfYear\"\nimport { addDay } from \"./addDay\"\nimport type { MaybeDateInput } from \"./types\"\n\n/**\n * Performs a bidirectional search for the nearest date that passes a function.\n * @param [inputDate] - Performs a search for the nearest passing date.\n * @param search - The search function to use, given a date returns a boolean.\n * @param constraint - The number of iterations to perform before giving up, or logical constraint like \"month\", or \"week\".\n *\n */\nexport function nearestDay(\n inputDate: MaybeDateInput,\n search: (date: Date) => boolean,\n constraint: number | \"month\" | \"week\" | \"year\" = 7\n): Date | null {\n let increments: number\n let decrements: number\n const d = date(inputDate)\n switch (constraint) {\n case \"month\":\n decrements = d.getDate()\n increments = monthDays(d) - d.getDate()\n break\n case \"week\":\n decrements = d.getDay()
|
|
1
|
+
{"version":3,"sources":["../src/nearestDay.ts"],"sourcesContent":["import { date } from \"./date\"\nimport { monthDays } from \"./monthDays\"\nimport { yearDays } from \"./yearDays\"\nimport { dayOfYear } from \"./dayOfYear\"\nimport { addDay } from \"./addDay\"\nimport type { MaybeDateInput } from \"./types\"\n\n/**\n * Performs a bidirectional search for the nearest date that passes a function.\n * @param [inputDate] - Performs a search for the nearest passing date.\n * @param search - The search function to use, given a date returns a boolean.\n * @param constraint - The number of iterations to perform before giving up, or logical constraint like \"month\", or \"week\".\n *\n */\nexport function nearestDay(\n inputDate: MaybeDateInput,\n search: (date: Date) => boolean,\n constraint: number | \"month\" | \"week\" | \"year\" = 7\n): Date | null {\n let increments: number\n let decrements: number\n const d = date(inputDate)\n switch (constraint) {\n case \"month\":\n decrements = d.getDate() - 1\n increments = monthDays(d) - d.getDate()\n break\n case \"week\":\n decrements = d.getDay()\n increments = 6 - d.getDay()\n break\n case \"year\":\n const total = yearDays(d)\n const day = dayOfYear(d)\n decrements = day - 1\n increments = total - day\n break\n default:\n increments = decrements = constraint\n }\n\n for (let i = 0; i <= increments || i <= decrements; i++) {\n if (i <= increments) {\n const next = addDay(d, i)\n if (search(next)) return next\n }\n if (i && i <= decrements) {\n const prev = addDay(d, -i)\n if (search(prev)) return prev\n }\n }\n return null\n}\n"],"mappings":";AAAA,SAAS,YAAY;AACrB,SAAS,iBAAiB;AAC1B,SAAS,gBAAgB;AACzB,SAAS,iBAAiB;AAC1B,SAAS,cAAc;AAUhB,SAAS,WACd,WACA,QACA,aAAiD,GACpC;AACb,MAAI;AACJ,MAAI;AACJ,QAAM,IAAI,KAAK,SAAS;AACxB,UAAQ,YAAY;AAAA,IAClB,KAAK;AACH,mBAAa,EAAE,QAAQ,IAAI;AAC3B,mBAAa,UAAU,CAAC,IAAI,EAAE,QAAQ;AACtC;AAAA,IACF,KAAK;AACH,mBAAa,EAAE,OAAO;AACtB,mBAAa,IAAI,EAAE,OAAO;AAC1B;AAAA,IACF,KAAK;AACH,YAAM,QAAQ,SAAS,CAAC;AACxB,YAAM,MAAM,UAAU,CAAC;AACvB,mBAAa,MAAM;AACnB,mBAAa,QAAQ;AACrB;AAAA,IACF;AACE,mBAAa,aAAa;AAAA,EAC9B;AAEA,WAAS,IAAI,GAAG,KAAK,cAAc,KAAK,YAAY,KAAK;AACvD,QAAI,KAAK,YAAY;AACnB,YAAM,OAAO,OAAO,GAAG,CAAC;AACxB,UAAI,OAAO,IAAI,EAAG,QAAO;AAAA,IAC3B;AACA,QAAI,KAAK,KAAK,YAAY;AACxB,YAAM,OAAO,OAAO,GAAG,CAAC,CAAC;AACzB,UAAI,OAAO,IAAI,EAAG,QAAO;AAAA,IAC3B;AAAA,EACF;AACA,SAAO;AACT;","names":[]}
|