@formkit/tempo 0.1.1 → 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.
- package/dist/addDay.d.ts +4 -3
- package/dist/addDay.mjs.map +1 -1
- package/dist/addHour.d.ts +4 -3
- package/dist/addHour.mjs.map +1 -1
- package/dist/addMillisecond.d.ts +10 -0
- package/dist/addMillisecond.mjs +11 -0
- package/dist/addMillisecond.mjs.map +1 -0
- package/dist/addMinute.d.ts +5 -4
- package/dist/addMinute.mjs.map +1 -1
- package/dist/addMonth.d.ts +5 -5
- package/dist/addMonth.mjs +1 -2
- package/dist/addMonth.mjs.map +1 -1
- package/dist/addSecond.d.ts +4 -3
- package/dist/addSecond.mjs.map +1 -1
- package/dist/addYear.d.ts +5 -5
- package/dist/addYear.mjs +1 -2
- package/dist/addYear.mjs.map +1 -1
- package/dist/ap.mjs +1 -2
- package/dist/ap.mjs.map +1 -1
- package/dist/applyOffset.d.ts +5 -5
- package/dist/applyOffset.mjs +5 -11
- package/dist/applyOffset.mjs.map +1 -1
- package/dist/bundle.d.ts +256 -115
- package/dist/bundle.mjs +158 -140
- package/dist/bundle.mjs.map +1 -1
- package/dist/common.d.ts +27 -7
- package/dist/common.mjs +47 -42
- package/dist/common.mjs.map +1 -1
- package/dist/date.d.ts +2 -2
- package/dist/date.mjs +1 -3
- package/dist/date.mjs.map +1 -1
- package/dist/dayEnd.d.ts +3 -3
- package/dist/dayEnd.mjs.map +1 -1
- package/dist/dayOfYear.d.ts +3 -3
- package/dist/dayOfYear.mjs.map +1 -1
- package/dist/dayStart.d.ts +3 -3
- package/dist/dayStart.mjs +1 -1
- package/dist/dayStart.mjs.map +1 -1
- package/dist/diffDays.d.ts +12 -5
- package/dist/diffDays.mjs +1 -0
- package/dist/diffDays.mjs.map +1 -1
- package/dist/diffHours.d.ts +12 -5
- package/dist/diffHours.mjs +1 -0
- package/dist/diffHours.mjs.map +1 -1
- package/dist/diffMilliseconds.d.ts +10 -4
- package/dist/diffMilliseconds.mjs.map +1 -1
- package/dist/diffMinutes.d.ts +11 -3
- package/dist/diffMinutes.mjs +5 -1
- package/dist/diffMinutes.mjs.map +1 -1
- package/dist/diffMonths.d.ts +10 -4
- package/dist/diffMonths.mjs.map +1 -1
- package/dist/diffSeconds.d.ts +12 -5
- package/dist/diffSeconds.mjs +5 -1
- package/dist/diffSeconds.mjs.map +1 -1
- package/dist/diffWeeks.d.ts +10 -3
- package/dist/diffWeeks.mjs.map +1 -1
- package/dist/diffYears.d.ts +10 -4
- package/dist/diffYears.mjs +4 -1
- package/dist/diffYears.mjs.map +1 -1
- package/dist/format.mjs +2 -3
- package/dist/format.mjs.map +1 -1
- package/dist/hourEnd.d.ts +3 -3
- package/dist/hourEnd.mjs.map +1 -1
- package/dist/hourStart.d.ts +3 -3
- package/dist/hourStart.mjs +1 -1
- package/dist/hourStart.mjs.map +1 -1
- package/dist/index.cjs +165 -143
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +256 -115
- package/dist/index.d.ts +5 -1
- package/dist/index.mjs +8 -0
- package/dist/index.mjs.map +1 -1
- package/dist/isAfter.d.ts +6 -6
- package/dist/isAfter.mjs.map +1 -1
- package/dist/isBefore.d.ts +5 -5
- package/dist/isBefore.mjs.map +1 -1
- package/dist/isEqual.d.ts +13 -4
- package/dist/isEqual.mjs.map +1 -1
- package/dist/isFuture.d.ts +10 -0
- package/dist/isFuture.mjs +9 -0
- package/dist/isFuture.mjs.map +1 -0
- package/dist/isPast.d.ts +10 -0
- package/dist/isPast.mjs +9 -0
- package/dist/isPast.mjs.map +1 -0
- package/dist/iso8601.d.ts +1 -1
- package/dist/iso8601.mjs +4 -7
- package/dist/iso8601.mjs.map +1 -1
- package/dist/minuteEnd.d.ts +3 -3
- package/dist/minuteEnd.mjs.map +1 -1
- package/dist/minuteStart.d.ts +3 -3
- package/dist/minuteStart.mjs +1 -1
- package/dist/minuteStart.mjs.map +1 -1
- package/dist/monthDays.d.ts +3 -3
- package/dist/monthDays.mjs.map +1 -1
- package/dist/monthEnd.d.ts +3 -3
- package/dist/monthEnd.mjs.map +1 -1
- package/dist/monthStart.d.ts +3 -3
- package/dist/monthStart.mjs +1 -1
- package/dist/monthStart.mjs.map +1 -1
- package/dist/nearestDay.d.ts +3 -3
- package/dist/nearestDay.mjs +2 -4
- package/dist/nearestDay.mjs.map +1 -1
- package/dist/offset.d.ts +5 -5
- package/dist/offset.mjs +3 -3
- package/dist/offset.mjs.map +1 -1
- package/dist/parse.mjs +33 -23
- package/dist/parse.mjs.map +1 -1
- package/dist/parts.mjs +14 -24
- package/dist/parts.mjs.map +1 -1
- package/dist/range.mjs +1 -2
- package/dist/range.mjs.map +1 -1
- package/dist/removeOffset.d.ts +4 -4
- package/dist/removeOffset.mjs.map +1 -1
- package/dist/sameDay.d.ts +8 -2
- package/dist/sameDay.mjs.map +1 -1
- package/dist/sameHour.d.ts +8 -2
- package/dist/sameHour.mjs.map +1 -1
- package/dist/sameMillisecond.d.ts +16 -0
- package/dist/sameMillisecond.mjs +11 -0
- package/dist/sameMillisecond.mjs.map +1 -0
- package/dist/sameMinute.d.ts +8 -2
- package/dist/sameMinute.mjs.map +1 -1
- package/dist/sameMonth.d.ts +16 -0
- package/dist/sameMonth.mjs +11 -0
- package/dist/sameMonth.mjs.map +1 -0
- package/dist/sameSecond.d.ts +8 -2
- package/dist/sameSecond.mjs.map +1 -1
- package/dist/sameYear.d.ts +8 -2
- package/dist/sameYear.mjs.map +1 -1
- package/dist/types.d.ts +15 -7
- package/dist/tzDate.d.ts +5 -3
- package/dist/tzDate.mjs.map +1 -1
- package/dist/weekEnd.d.ts +4 -4
- package/dist/weekEnd.mjs +1 -1
- package/dist/weekEnd.mjs.map +1 -1
- package/dist/weekStart.d.ts +4 -4
- package/dist/weekStart.mjs +2 -3
- package/dist/weekStart.mjs.map +1 -1
- package/dist/yearDays.d.ts +3 -3
- package/dist/yearDays.mjs.map +1 -1
- package/dist/yearEnd.d.ts +3 -3
- package/dist/yearEnd.mjs +1 -2
- package/dist/yearEnd.mjs.map +1 -1
- package/dist/yearStart.d.ts +3 -3
- package/dist/yearStart.mjs +2 -3
- package/dist/yearStart.mjs.map +1 -1
- package/package.json +32 -23
package/dist/addDay.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { MaybeDateInput } from './types.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Returns a new date object 1/n days after the original one.
|
|
5
|
-
* @param inputDate - A date to increment
|
|
5
|
+
* @param [inputDate] - A date to increment or null to increment from the current time.
|
|
6
|
+
* @param [count] - The quantity to add.
|
|
6
7
|
*/
|
|
7
|
-
declare function addDay(inputDate
|
|
8
|
+
declare function addDay(inputDate?: MaybeDateInput, count?: number): Date;
|
|
8
9
|
|
|
9
10
|
export { addDay };
|
package/dist/addDay.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/addDay.ts"],"sourcesContent":["import { date } from \"./date\"\nimport type {
|
|
1
|
+
{"version":3,"sources":["../src/addDay.ts"],"sourcesContent":["import { date } from \"./date\"\nimport type { MaybeDateInput } from \"./types\"\n\n/**\n * Returns a new date object 1/n days after the original one.\n * @param [inputDate] - A date to increment or null to increment from the current time.\n * @param [count] - The quantity to add.\n */\nexport function addDay(inputDate?: MaybeDateInput, count = 1) {\n const d = date(inputDate)\n d.setDate(d.getDate() + count)\n return d\n}\n"],"mappings":";AAAA,SAAS,YAAY;AAQd,SAAS,OAAO,WAA4B,QAAQ,GAAG;AAC5D,QAAM,IAAI,KAAK,SAAS;AACxB,IAAE,QAAQ,EAAE,QAAQ,IAAI,KAAK;AAC7B,SAAO;AACT;","names":[]}
|
package/dist/addHour.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { MaybeDateInput } from './types.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Returns a new date object 1/n hours after the original one.
|
|
5
|
-
* @param inputDate - A date to increment
|
|
5
|
+
* @param [inputDate] - A date to increment or null to increment from the current time.
|
|
6
|
+
* @param [count] - The quantity to add.
|
|
6
7
|
*/
|
|
7
|
-
declare function addHour(inputDate
|
|
8
|
+
declare function addHour(inputDate?: MaybeDateInput, count?: number): Date;
|
|
8
9
|
|
|
9
10
|
export { addHour };
|
package/dist/addHour.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/addHour.ts"],"sourcesContent":["import { date } from \"./date\"\nimport type {
|
|
1
|
+
{"version":3,"sources":["../src/addHour.ts"],"sourcesContent":["import { date } from \"./date\"\nimport type { MaybeDateInput } from \"./types\"\n\n/**\n * Returns a new date object 1/n hours after the original one.\n * @param [inputDate] - A date to increment or null to increment from the current time.\n * @param [count] - The quantity to add.\n */\nexport function addHour(inputDate?: MaybeDateInput, count = 1) {\n const d = date(inputDate)\n d.setHours(d.getHours() + count)\n return d\n}\n"],"mappings":";AAAA,SAAS,YAAY;AAQd,SAAS,QAAQ,WAA4B,QAAQ,GAAG;AAC7D,QAAM,IAAI,KAAK,SAAS;AACxB,IAAE,SAAS,EAAE,SAAS,IAAI,KAAK;AAC/B,SAAO;AACT;","names":[]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { MaybeDateInput } from './types.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Returns a new date object 1/n milliseconds after the original one.
|
|
5
|
+
* @param [inputDate] - A date to increment or null to increment from the current time.
|
|
6
|
+
* @param [count] - The quantity to add.
|
|
7
|
+
*/
|
|
8
|
+
declare function addMillisecond(inputDate?: MaybeDateInput, count?: number): Date;
|
|
9
|
+
|
|
10
|
+
export { addMillisecond };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// src/addMillisecond.ts
|
|
2
|
+
import { date } from "./date.mjs";
|
|
3
|
+
function addMillisecond(inputDate, count = 1) {
|
|
4
|
+
const d = date(inputDate);
|
|
5
|
+
d.setMilliseconds(d.getMilliseconds() + count);
|
|
6
|
+
return d;
|
|
7
|
+
}
|
|
8
|
+
export {
|
|
9
|
+
addMillisecond
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=addMillisecond.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/addMillisecond.ts"],"sourcesContent":["import { date } from \"./date\"\nimport type { MaybeDateInput } from \"./types\"\n\n/**\n * Returns a new date object 1/n milliseconds after the original one.\n * @param [inputDate] - A date to increment or null to increment from the current time.\n * @param [count] - The quantity to add.\n */\nexport function addMillisecond(inputDate?: MaybeDateInput, count = 1) {\n const d = date(inputDate)\n d.setMilliseconds(d.getMilliseconds() + count)\n return d\n}\n"],"mappings":";AAAA,SAAS,YAAY;AAQd,SAAS,eAAe,WAA4B,QAAQ,GAAG;AACpE,QAAM,IAAI,KAAK,SAAS;AACxB,IAAE,gBAAgB,EAAE,gBAAgB,IAAI,KAAK;AAC7C,SAAO;AACT;","names":[]}
|
package/dist/addMinute.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { MaybeDateInput } from './types.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* Returns a new date object 1/n
|
|
5
|
-
* @param inputDate - A date to increment
|
|
4
|
+
* Returns a new date object 1/n minutes after the original one.
|
|
5
|
+
* @param [inputDate] - A date to increment or null to increment from the current time.
|
|
6
|
+
* @param [count] - The quantity to add.
|
|
6
7
|
*/
|
|
7
|
-
declare function addMinute(inputDate
|
|
8
|
+
declare function addMinute(inputDate?: MaybeDateInput, count?: number): Date;
|
|
8
9
|
|
|
9
10
|
export { addMinute };
|
package/dist/addMinute.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/addMinute.ts"],"sourcesContent":["import { date } from \"./date\"\nimport type { DateInput } from \"./types\"\n\n/**\n * Returns a new date object 1/n
|
|
1
|
+
{"version":3,"sources":["../src/addMinute.ts"],"sourcesContent":["import { date } from \"./date\"\nimport type { DateInput, MaybeDateInput } from \"./types\"\n\n/**\n * Returns a new date object 1/n minutes after the original one.\n * @param [inputDate] - A date to increment or null to increment from the current time.\n * @param [count] - The quantity to add.\n */\nexport function addMinute(inputDate?: MaybeDateInput, count = 1) {\n const d = date(inputDate)\n d.setMinutes(d.getMinutes() + count)\n return d\n}\n"],"mappings":";AAAA,SAAS,YAAY;AAQd,SAAS,UAAU,WAA4B,QAAQ,GAAG;AAC/D,QAAM,IAAI,KAAK,SAAS;AACxB,IAAE,WAAW,EAAE,WAAW,IAAI,KAAK;AACnC,SAAO;AACT;","names":[]}
|
package/dist/addMonth.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { MaybeDateInput } from './types.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Returns a new date object 1/n months after the original one. Keep in mind if you
|
|
5
5
|
* start with a date late in a given month you could get a date after the next
|
|
6
6
|
* month.
|
|
7
|
-
* @param inputDate - A date to increment
|
|
8
|
-
* @param count - The quantity to add.
|
|
9
|
-
* @param dateOverflow - Whether or not to allow the date to overflow to another month if the inputDate’s month is out of range of the new month.
|
|
7
|
+
* @param [inputDate] - A date to increment or null to increment from the current time
|
|
8
|
+
* @param [count] - The quantity to add.
|
|
9
|
+
* @param [dateOverflow] - Whether or not to allow the date to overflow to another month if the inputDate’s month is out of range of the new month.
|
|
10
10
|
*/
|
|
11
|
-
declare function addMonth(inputDate
|
|
11
|
+
declare function addMonth(inputDate?: MaybeDateInput, count?: number, dateOverflow?: boolean): Date;
|
|
12
12
|
|
|
13
13
|
export { addMonth };
|
package/dist/addMonth.mjs
CHANGED
|
@@ -4,8 +4,7 @@ import { monthDays } from "./monthDays.mjs";
|
|
|
4
4
|
function addMonth(inputDate, count = 1, dateOverflow = false) {
|
|
5
5
|
const d = date(inputDate);
|
|
6
6
|
const dayOfMonth = d.getDate();
|
|
7
|
-
if (!dateOverflow)
|
|
8
|
-
d.setDate(1);
|
|
7
|
+
if (!dateOverflow) d.setDate(1);
|
|
9
8
|
d.setMonth(d.getMonth() + count);
|
|
10
9
|
if (!dateOverflow) {
|
|
11
10
|
const daysInMonth = monthDays(d);
|
package/dist/addMonth.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/addMonth.ts"],"sourcesContent":["import { date } from \"./date\"\nimport { monthDays } from \"./monthDays\"\nimport type { DateInput } from \"./types\"\n\n/**\n * Returns a new date object 1/n months after the original one. Keep in mind if you\n * start with a date late in a given month you could get a date after the next\n * month.\n * @param inputDate - A date to increment
|
|
1
|
+
{"version":3,"sources":["../src/addMonth.ts"],"sourcesContent":["import { date } from \"./date\"\nimport { monthDays } from \"./monthDays\"\nimport type { DateInput, MaybeDateInput } from \"./types\"\n\n/**\n * Returns a new date object 1/n months after the original one. Keep in mind if you\n * start with a date late in a given month you could get a date after the next\n * month.\n * @param [inputDate] - A date to increment or null to increment from the current time\n * @param [count] - The quantity to add.\n * @param [dateOverflow] - Whether or not to allow the date to overflow to another month if the inputDate’s month is out of range of the new month.\n */\nexport function addMonth(inputDate?: MaybeDateInput, count = 1, dateOverflow = false) {\n const d = date(inputDate)\n const dayOfMonth = d.getDate()\n // If overflowing is disallowed, set the date back to the first of the month\n if (!dateOverflow) d.setDate(1)\n d.setMonth(d.getMonth() + count)\n\n // If overflowing is disallowed, we need to set the date back to the proper\n // day or the last day of the month.\n if (!dateOverflow) {\n const daysInMonth = monthDays(d)\n d.setDate(daysInMonth < dayOfMonth ? daysInMonth : dayOfMonth)\n }\n return d\n}\n"],"mappings":";AAAA,SAAS,YAAY;AACrB,SAAS,iBAAiB;AAWnB,SAAS,SAAS,WAA4B,QAAQ,GAAG,eAAe,OAAO;AACpF,QAAM,IAAI,KAAK,SAAS;AACxB,QAAM,aAAa,EAAE,QAAQ;AAE7B,MAAI,CAAC,aAAc,GAAE,QAAQ,CAAC;AAC9B,IAAE,SAAS,EAAE,SAAS,IAAI,KAAK;AAI/B,MAAI,CAAC,cAAc;AACjB,UAAM,cAAc,UAAU,CAAC;AAC/B,MAAE,QAAQ,cAAc,aAAa,cAAc,UAAU;AAAA,EAC/D;AACA,SAAO;AACT;","names":[]}
|
package/dist/addSecond.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { MaybeDateInput } from './types.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Returns a new date object 1/n seconds after the original one.
|
|
5
|
-
* @param inputDate - A date to increment
|
|
5
|
+
* @param [inputDate] - A date to increment or null to increment from the current time.
|
|
6
|
+
* @param [count] - The quantity to add.
|
|
6
7
|
*/
|
|
7
|
-
declare function addSecond(inputDate
|
|
8
|
+
declare function addSecond(inputDate?: MaybeDateInput, count?: number): Date;
|
|
8
9
|
|
|
9
10
|
export { addSecond };
|
package/dist/addSecond.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/addSecond.ts"],"sourcesContent":["import { date } from \"./date\"\nimport type {
|
|
1
|
+
{"version":3,"sources":["../src/addSecond.ts"],"sourcesContent":["import { date } from \"./date\"\nimport type { MaybeDateInput } from \"./types\"\n\n/**\n * Returns a new date object 1/n seconds after the original one.\n * @param [inputDate] - A date to increment or null to increment from the current time.\n * @param [count] - The quantity to add.\n */\nexport function addSecond(inputDate?: MaybeDateInput, count = 1) {\n const d = date(inputDate)\n d.setSeconds(d.getSeconds() + count)\n return d\n}\n"],"mappings":";AAAA,SAAS,YAAY;AAQd,SAAS,UAAU,WAA4B,QAAQ,GAAG;AAC/D,QAAM,IAAI,KAAK,SAAS;AACxB,IAAE,WAAW,EAAE,WAAW,IAAI,KAAK;AACnC,SAAO;AACT;","names":[]}
|
package/dist/addYear.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { MaybeDateInput } from './types.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Returns a new date object 1/n years after the original one. Keep in mind if
|
|
5
5
|
* you start with a date late in a given month you could get a date after the
|
|
6
6
|
* next month.
|
|
7
|
-
* @param inputDate - A date to increment
|
|
8
|
-
* @param count - The quantity of years add.
|
|
9
|
-
* @param dateOverflow - Whether or not to allow the date to overflow to another month if the inputDate’s month is out of range of the new month.
|
|
7
|
+
* @param [inputDate] - A date to increment or null to increment from the current time.
|
|
8
|
+
* @param [count] - The quantity of years add.
|
|
9
|
+
* @param [dateOverflow] - Whether or not to allow the date to overflow to another month if the inputDate’s month is out of range of the new month.
|
|
10
10
|
*/
|
|
11
|
-
declare function addYear(inputDate
|
|
11
|
+
declare function addYear(inputDate?: MaybeDateInput, count?: number, dateOverflow?: boolean): Date;
|
|
12
12
|
|
|
13
13
|
export { addYear };
|
package/dist/addYear.mjs
CHANGED
|
@@ -4,8 +4,7 @@ import { monthDays } from "./monthDays.mjs";
|
|
|
4
4
|
function addYear(inputDate, count = 1, dateOverflow = false) {
|
|
5
5
|
const d = date(inputDate);
|
|
6
6
|
const dayOfMonth = d.getDate();
|
|
7
|
-
if (!dateOverflow)
|
|
8
|
-
d.setDate(1);
|
|
7
|
+
if (!dateOverflow) d.setDate(1);
|
|
9
8
|
d.setFullYear(d.getFullYear() + count);
|
|
10
9
|
if (!dateOverflow) {
|
|
11
10
|
const daysInMonth = monthDays(d);
|
package/dist/addYear.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/addYear.ts"],"sourcesContent":["import { date } from \"./date\"\nimport { monthDays } from \"./monthDays\"\nimport type {
|
|
1
|
+
{"version":3,"sources":["../src/addYear.ts"],"sourcesContent":["import { date } from \"./date\"\nimport { monthDays } from \"./monthDays\"\nimport type { MaybeDateInput } from \"./types\"\n\n/**\n * Returns a new date object 1/n years after the original one. Keep in mind if\n * you start with a date late in a given month you could get a date after the\n * next month.\n * @param [inputDate] - A date to increment or null to increment from the current time.\n * @param [count] - The quantity of years add.\n * @param [dateOverflow] - Whether or not to allow the date to overflow to another month if the inputDate’s month is out of range of the new month.\n */\nexport function addYear(inputDate?: MaybeDateInput, count = 1, dateOverflow = false) {\n const d = date(inputDate)\n const dayOfMonth = d.getDate()\n // If overflowing is disallowed, set the date back to the first of the month\n if (!dateOverflow) d.setDate(1)\n\n d.setFullYear(d.getFullYear() + count)\n\n // If overflowing is disallowed, we need to set the date back to the proper\n // day or the last day of the month.\n if (!dateOverflow) {\n const daysInMonth = monthDays(d)\n d.setDate(daysInMonth < dayOfMonth ? daysInMonth : dayOfMonth)\n }\n return d\n}\n"],"mappings":";AAAA,SAAS,YAAY;AACrB,SAAS,iBAAiB;AAWnB,SAAS,QAAQ,WAA4B,QAAQ,GAAG,eAAe,OAAO;AACnF,QAAM,IAAI,KAAK,SAAS;AACxB,QAAM,aAAa,EAAE,QAAQ;AAE7B,MAAI,CAAC,aAAc,GAAE,QAAQ,CAAC;AAE9B,IAAE,YAAY,EAAE,YAAY,IAAI,KAAK;AAIrC,MAAI,CAAC,cAAc;AACjB,UAAM,cAAc,UAAU,CAAC;AAC/B,MAAE,QAAQ,cAAc,aAAa,cAAc,UAAU;AAAA,EAC/D;AACA,SAAO;AACT;","names":[]}
|
package/dist/ap.mjs
CHANGED
|
@@ -2,8 +2,7 @@
|
|
|
2
2
|
import { dayPeriodMap, specDate, normStr } from "./common.mjs";
|
|
3
3
|
function ap(ampm, locale) {
|
|
4
4
|
const l = dayPeriodMap.get(locale);
|
|
5
|
-
if (l && l[ampm])
|
|
6
|
-
return l[ampm];
|
|
5
|
+
if (l && l[ampm]) return l[ampm];
|
|
7
6
|
const specimen = new Date(specDate);
|
|
8
7
|
specimen.setUTCHours(ampm === "am" ? 5 : 20);
|
|
9
8
|
const subparts = new Intl.DateTimeFormat(locale, {
|
package/dist/ap.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/ap.ts"],"sourcesContent":["import { dayPeriodMap, specDate, normStr } from \"./common\"\n\n/**\n * Determines the correct value for am/pm by locale and memoizes it.\n * @param ampm - am or pm\n * @param locale - The locale to fetch.\n */\nexport function ap(ampm: \"am\" | \"pm\", locale: string): string {\n const l = dayPeriodMap.get(locale)\n if (l && l[ampm]) return l[ampm] as string\n const specimen = new Date(specDate)\n specimen.setUTCHours(ampm === \"am\" ? 5 : 20)\n const subparts = new Intl.DateTimeFormat(locale, {\n timeStyle: \"full\",\n timeZone: \"UTC\",\n hour12: true,\n })\n .formatToParts(specimen)\n .map(normStr)\n const period = subparts.find((part) => part.type === \"dayPeriod\")\n if (period) {\n const localePeriods: { am?: string; pm?: string } = l || {}\n dayPeriodMap.set(\n locale,\n Object.assign(localePeriods, { [ampm]: period.value })\n )\n return period.value\n }\n return ampm\n}\n"],"mappings":";AAAA,SAAS,cAAc,UAAU,eAAe;AAOzC,SAAS,GAAG,MAAmB,QAAwB;AAC5D,QAAM,IAAI,aAAa,IAAI,MAAM;AACjC,MAAI,KAAK,EAAE,IAAI
|
|
1
|
+
{"version":3,"sources":["../src/ap.ts"],"sourcesContent":["import { dayPeriodMap, specDate, normStr } from \"./common\"\n\n/**\n * Determines the correct value for am/pm by locale and memoizes it.\n * @param ampm - am or pm\n * @param locale - The locale to fetch.\n */\nexport function ap(ampm: \"am\" | \"pm\", locale: string): string {\n const l = dayPeriodMap.get(locale)\n if (l && l[ampm]) return l[ampm] as string\n const specimen = new Date(specDate)\n specimen.setUTCHours(ampm === \"am\" ? 5 : 20)\n const subparts = new Intl.DateTimeFormat(locale, {\n timeStyle: \"full\",\n timeZone: \"UTC\",\n hour12: true,\n })\n .formatToParts(specimen)\n .map(normStr)\n const period = subparts.find((part) => part.type === \"dayPeriod\")\n if (period) {\n const localePeriods: { am?: string; pm?: string } = l || {}\n dayPeriodMap.set(\n locale,\n Object.assign(localePeriods, { [ampm]: period.value })\n )\n return period.value\n }\n return ampm\n}\n"],"mappings":";AAAA,SAAS,cAAc,UAAU,eAAe;AAOzC,SAAS,GAAG,MAAmB,QAAwB;AAC5D,QAAM,IAAI,aAAa,IAAI,MAAM;AACjC,MAAI,KAAK,EAAE,IAAI,EAAG,QAAO,EAAE,IAAI;AAC/B,QAAM,WAAW,IAAI,KAAK,QAAQ;AAClC,WAAS,YAAY,SAAS,OAAO,IAAI,EAAE;AAC3C,QAAM,WAAW,IAAI,KAAK,eAAe,QAAQ;AAAA,IAC/C,WAAW;AAAA,IACX,UAAU;AAAA,IACV,QAAQ;AAAA,EACV,CAAC,EACE,cAAc,QAAQ,EACtB,IAAI,OAAO;AACd,QAAM,SAAS,SAAS,KAAK,CAAC,SAAS,KAAK,SAAS,WAAW;AAChE,MAAI,QAAQ;AACV,UAAM,gBAA8C,KAAK,CAAC;AAC1D,iBAAa;AAAA,MACX;AAAA,MACA,OAAO,OAAO,eAAe,EAAE,CAAC,IAAI,GAAG,OAAO,MAAM,CAAC;AAAA,IACvD;AACA,WAAO,OAAO;AAAA,EAChB;AACA,SAAO;AACT;","names":[]}
|
package/dist/applyOffset.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { MaybeDateInput } from './types.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Apply a given offset to a date, returning a new date with the offset
|
|
5
|
-
* applied by adding or subtracting the given number of
|
|
6
|
-
* @param dateInput - The date to apply the offset to.
|
|
7
|
-
* @param offset - The offset to apply in the +-HHmm or +-HH:mm format.
|
|
5
|
+
* applied by adding or subtracting the given number of seconds.
|
|
6
|
+
* @param [dateInput] - The date to apply the offset to. (default: current time)
|
|
7
|
+
* @param [offset] - The offset to apply in the +-HHmm, +-HH:mm, +-HHmmss, or +-HH:mm:ss format.
|
|
8
8
|
*/
|
|
9
|
-
declare function applyOffset(dateInput
|
|
9
|
+
declare function applyOffset(dateInput?: MaybeDateInput, offset?: string): Date;
|
|
10
10
|
|
|
11
11
|
export { applyOffset };
|
package/dist/applyOffset.mjs
CHANGED
|
@@ -1,18 +1,12 @@
|
|
|
1
1
|
// src/applyOffset.ts
|
|
2
2
|
import { date } from "./date.mjs";
|
|
3
|
-
import { fixedLengthByOffset,
|
|
3
|
+
import { fixedLengthByOffset, offsetToSecs } from "./common.mjs";
|
|
4
4
|
function applyOffset(dateInput, offset = "+00:00") {
|
|
5
5
|
const d = date(dateInput);
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
case 6:
|
|
11
|
-
return "Z";
|
|
12
|
-
}
|
|
13
|
-
})();
|
|
14
|
-
const timeDiffInMins = offsetToMins(offset, token);
|
|
15
|
-
return new Date(d.getTime() + timeDiffInMins * 1e3 * 60);
|
|
6
|
+
const len = fixedLengthByOffset(offset);
|
|
7
|
+
const token = len === 5 || len === 8 ? "ZZ" : "Z";
|
|
8
|
+
const timeDiffInSecs = offsetToSecs(offset, token);
|
|
9
|
+
return new Date(d.getTime() + timeDiffInSecs * 1e3);
|
|
16
10
|
}
|
|
17
11
|
export {
|
|
18
12
|
applyOffset
|
package/dist/applyOffset.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/applyOffset.ts"],"sourcesContent":["import { date } from \"./date\"\nimport { TimezoneToken, fixedLengthByOffset,
|
|
1
|
+
{"version":3,"sources":["../src/applyOffset.ts"],"sourcesContent":["import { date } from \"./date\"\nimport { TimezoneToken, fixedLengthByOffset, offsetToSecs } from \"./common\"\nimport type { MaybeDateInput } from \"./types\"\n\n/**\n * Apply a given offset to a date, returning a new date with the offset\n * applied by adding or subtracting the given number of seconds.\n * @param [dateInput] - The date to apply the offset to. (default: current time)\n * @param [offset] - The offset to apply in the +-HHmm, +-HH:mm, +-HHmmss, or +-HH:mm:ss format.\n */\nexport function applyOffset(dateInput?: MaybeDateInput, offset = \"+00:00\"): Date {\n const d = date(dateInput)\n const len = fixedLengthByOffset(offset)\n // 5 or 8 chars = no colons (ZZ format), 6 or 9 chars = with colons (Z format)\n const token: TimezoneToken = len === 5 || len === 8 ? \"ZZ\" : \"Z\"\n const timeDiffInSecs = offsetToSecs(offset, token)\n return new Date(d.getTime() + timeDiffInSecs * 1000)\n}\n"],"mappings":";AAAA,SAAS,YAAY;AACrB,SAAwB,qBAAqB,oBAAoB;AAS1D,SAAS,YAAY,WAA4B,SAAS,UAAgB;AAC/E,QAAM,IAAI,KAAK,SAAS;AACxB,QAAM,MAAM,oBAAoB,MAAM;AAEtC,QAAM,QAAuB,QAAQ,KAAK,QAAQ,IAAI,OAAO;AAC7D,QAAM,iBAAiB,aAAa,QAAQ,KAAK;AACjD,SAAO,IAAI,KAAK,EAAE,QAAQ,IAAI,iBAAiB,GAAI;AACrD;","names":[]}
|