@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.
- 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 -142
- 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 -145
- 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 -5
- 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/diffSeconds.d.ts
CHANGED
|
@@ -1,12 +1,19 @@
|
|
|
1
1
|
import { DiffRoundingMethod } from './diffRound.js';
|
|
2
|
-
import { DateInput } from './types.js';
|
|
2
|
+
import { DateInput, MaybeDateInput } from './types.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Returns the difference between 2 dates in seconds.
|
|
6
|
-
* @param dateA A date to compare with the right date
|
|
7
|
-
* @param dateB A date to compare with the left date
|
|
8
|
-
* @param roundingMethod the rounding method to use, default: trunc
|
|
6
|
+
* @param dateA - A date to compare with the right date
|
|
7
|
+
* @param [dateB] - A date to compare with the left date or nothing to compare with the current time.
|
|
8
|
+
* @param [roundingMethod] - the rounding method to use, default: trunc
|
|
9
9
|
*/
|
|
10
|
-
declare function diffSeconds(dateA: DateInput, dateB
|
|
10
|
+
declare function diffSeconds(dateA: DateInput, dateB?: MaybeDateInput, roundingMethod?: DiffRoundingMethod): number;
|
|
11
|
+
/**
|
|
12
|
+
* Returns the difference between 2 dates in seconds.
|
|
13
|
+
* @param [dateA] - A date to compare with the right date or null to compare with the current time
|
|
14
|
+
* @param dateB - A date to compare with the left date
|
|
15
|
+
* @param [roundingMethod] - the rounding method to use, default: trunc
|
|
16
|
+
*/
|
|
17
|
+
declare function diffSeconds(dateA: MaybeDateInput, dateB: DateInput, roundingMethod?: DiffRoundingMethod): number;
|
|
11
18
|
|
|
12
19
|
export { diffSeconds };
|
package/dist/diffSeconds.mjs
CHANGED
|
@@ -2,7 +2,11 @@
|
|
|
2
2
|
import { diffMilliseconds } from "./diffMilliseconds.mjs";
|
|
3
3
|
import { diffRound } from "./diffRound.mjs";
|
|
4
4
|
function diffSeconds(dateA, dateB, roundingMethod) {
|
|
5
|
-
return diffRound(
|
|
5
|
+
return diffRound(
|
|
6
|
+
// @ts-ignore
|
|
7
|
+
diffMilliseconds(dateA, dateB) / 1e3,
|
|
8
|
+
roundingMethod
|
|
9
|
+
);
|
|
6
10
|
}
|
|
7
11
|
export {
|
|
8
12
|
diffSeconds
|
package/dist/diffSeconds.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/diffSeconds.ts"],"sourcesContent":["import { diffMilliseconds } from \"./diffMilliseconds\"\nimport { DiffRoundingMethod, diffRound } from \"./diffRound\"\nimport { DateInput } from \"./types\"\n\n/**\n * Returns the difference between 2 dates in seconds.\n * @param dateA A date to compare with the right date\n * @param dateB A date to compare with the left date
|
|
1
|
+
{"version":3,"sources":["../src/diffSeconds.ts"],"sourcesContent":["import { diffMilliseconds } from \"./diffMilliseconds\"\nimport { DiffRoundingMethod, diffRound } from \"./diffRound\"\nimport type { DateInput, MaybeDateInput } from \"./types\"\n\n/**\n * Returns the difference between 2 dates in seconds.\n * @param dateA - A date to compare with the right date\n * @param [dateB] - A date to compare with the left date or nothing to compare with the current time.\n * @param [roundingMethod] - the rounding method to use, default: trunc\n */\nexport function diffSeconds(\n dateA: DateInput,\n dateB?: MaybeDateInput,\n roundingMethod?: DiffRoundingMethod\n): number\n\n/**\n * Returns the difference between 2 dates in seconds.\n * @param [dateA] - A date to compare with the right date or null to compare with the current time\n * @param dateB - A date to compare with the left date\n * @param [roundingMethod] - the rounding method to use, default: trunc\n */\nexport function diffSeconds(\n dateA: MaybeDateInput,\n dateB: DateInput,\n roundingMethod?: DiffRoundingMethod\n): number\n\nexport function diffSeconds(\n dateA: MaybeDateInput,\n dateB?: MaybeDateInput,\n roundingMethod?: DiffRoundingMethod\n): number {\n return diffRound(\n // @ts-ignore\n diffMilliseconds(dateA, dateB) / 1000,\n roundingMethod\n )\n}\n"],"mappings":";AAAA,SAAS,wBAAwB;AACjC,SAA6B,iBAAiB;AA2BvC,SAAS,YACd,OACA,OACA,gBACQ;AACR,SAAO;AAAA;AAAA,IAEL,iBAAiB,OAAO,KAAK,IAAI;AAAA,IACjC;AAAA,EACF;AACF;","names":[]}
|
package/dist/diffWeeks.d.ts
CHANGED
|
@@ -3,9 +3,16 @@ import { DiffRoundingMethod } from './diffRound.js';
|
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Returns the difference between 2 dates in days.
|
|
6
|
-
* @param dateA A date to compare with the right date
|
|
7
|
-
* @param dateB A date to compare with the left date
|
|
8
|
-
* @param roundingMethod the rounding method to use, default: trunc
|
|
6
|
+
* @param dateA - A date to compare with the right date
|
|
7
|
+
* @param [dateB] - A date to compare with the left date or nothing to compare with the current time
|
|
8
|
+
* @param [roundingMethod] - the rounding method to use, default: trunc
|
|
9
|
+
*/
|
|
10
|
+
declare function diffWeeks(dateA: DateInput, dateB: DateInput, roundingMethod?: DiffRoundingMethod): number;
|
|
11
|
+
/**
|
|
12
|
+
* Returns the difference between 2 dates in days.
|
|
13
|
+
* @param [dateA] - A date to compare with the right date or null to compare with the current time
|
|
14
|
+
* @param dateB - A date to compare with the left date
|
|
15
|
+
* @param [roundingMethod] - the rounding method to use, default: trunc
|
|
9
16
|
*/
|
|
10
17
|
declare function diffWeeks(dateA: DateInput, dateB: DateInput, roundingMethod?: DiffRoundingMethod): number;
|
|
11
18
|
|
package/dist/diffWeeks.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/diffWeeks.ts"],"sourcesContent":["import { diffMilliseconds } from \"./diffMilliseconds\"\nimport { DateInput } from \"./types\"\nimport { diffRound, type DiffRoundingMethod } from \"./diffRound\"\n\n/**\n * Returns the difference between 2 dates in days.\n * @param dateA A date to compare with the right date\n * @param dateB A date to compare with the left date\n * @param roundingMethod the rounding method to use, default: trunc\n */\nexport function diffWeeks(\n dateA: DateInput,\n dateB: DateInput,\n roundingMethod?: DiffRoundingMethod\n) {\n return diffRound(\n diffMilliseconds(dateA, dateB) / 604800000, // day * 7\n roundingMethod\n )\n}\n"],"mappings":";AAAA,SAAS,wBAAwB;AAEjC,SAAS,iBAA0C;
|
|
1
|
+
{"version":3,"sources":["../src/diffWeeks.ts"],"sourcesContent":["import { diffMilliseconds } from \"./diffMilliseconds\"\nimport { DateInput, MaybeDateInput } from \"./types\"\nimport { diffRound, type DiffRoundingMethod } from \"./diffRound\"\n\n/**\n * Returns the difference between 2 dates in days.\n * @param dateA - A date to compare with the right date\n * @param [dateB] - A date to compare with the left date or nothing to compare with the current time\n * @param [roundingMethod] - the rounding method to use, default: trunc\n */\nexport function diffWeeks(\n dateA: DateInput,\n dateB: DateInput,\n roundingMethod?: DiffRoundingMethod\n): number\n\n/**\n * Returns the difference between 2 dates in days.\n * @param [dateA] - A date to compare with the right date or null to compare with the current time\n * @param dateB - A date to compare with the left date\n * @param [roundingMethod] - the rounding method to use, default: trunc\n */\nexport function diffWeeks(\n dateA: DateInput,\n dateB: DateInput,\n roundingMethod?: DiffRoundingMethod\n): number\n\nexport function diffWeeks(\n dateA: MaybeDateInput,\n dateB: DateInput,\n roundingMethod?: DiffRoundingMethod\n): number {\n return diffRound(\n diffMilliseconds(dateA, dateB) / 604800000, // day * 7\n roundingMethod\n )\n}\n"],"mappings":";AAAA,SAAS,wBAAwB;AAEjC,SAAS,iBAA0C;AA0B5C,SAAS,UACd,OACA,OACA,gBACQ;AACR,SAAO;AAAA,IACL,iBAAiB,OAAO,KAAK,IAAI;AAAA;AAAA,IACjC;AAAA,EACF;AACF;","names":[]}
|
package/dist/diffYears.d.ts
CHANGED
|
@@ -1,10 +1,16 @@
|
|
|
1
|
-
import { DateInput } from './types.js';
|
|
1
|
+
import { DateInput, MaybeDateInput } from './types.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Returns the difference between 2 dates in years.
|
|
5
|
-
* @param dateA A date to compare with the dateB date
|
|
6
|
-
* @param dateB A date to compare with the dateA date
|
|
5
|
+
* @param dateA - A date to compare with the dateB date
|
|
6
|
+
* @param [dateB] - A date to compare with the dateA date or nothing to compare with the current time
|
|
7
7
|
*/
|
|
8
|
-
declare function diffYears(dateA: DateInput, dateB
|
|
8
|
+
declare function diffYears(dateA: DateInput, dateB?: MaybeDateInput): number;
|
|
9
|
+
/**
|
|
10
|
+
* Returns the difference between 2 dates in years.
|
|
11
|
+
* @param [dateA] - A date to compare with the dateB date or null to compare with the current time
|
|
12
|
+
* @param dateB - A date to compare with the dateA date
|
|
13
|
+
*/
|
|
14
|
+
declare function diffYears(dateA: MaybeDateInput, dateB: DateInput): number;
|
|
9
15
|
|
|
10
16
|
export { diffYears };
|
package/dist/diffYears.mjs
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
// src/diffYears.ts
|
|
2
2
|
import { diffMonths } from "./diffMonths.mjs";
|
|
3
3
|
function diffYears(dateA, dateB) {
|
|
4
|
-
const r = Math.trunc(
|
|
4
|
+
const r = Math.trunc(
|
|
5
|
+
//@ts-ignore
|
|
6
|
+
diffMonths(dateA, dateB) / 12
|
|
7
|
+
);
|
|
5
8
|
return r == 0 ? 0 : r;
|
|
6
9
|
}
|
|
7
10
|
export {
|
package/dist/diffYears.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/diffYears.ts"],"sourcesContent":["import { diffMonths } from \"./diffMonths\"\nimport { DateInput } from \"./types\"\n\n/**\n * Returns the difference between 2 dates in years.\n * @param dateA A date to compare with the dateB date\n * @param dateB A date to compare with the dateA date\n */\nexport function diffYears(dateA: DateInput, dateB: DateInput): number {\n const r = Math.trunc(diffMonths(dateA, dateB) / 12)\n //ensures we don't give back -0\n return r == 0 ? 0 : r\n}\n"],"mappings":";AAAA,SAAS,kBAAkB;
|
|
1
|
+
{"version":3,"sources":["../src/diffYears.ts"],"sourcesContent":["import { diffMonths } from \"./diffMonths\"\nimport type { DateInput, MaybeDateInput } from \"./types\"\n\n/**\n * Returns the difference between 2 dates in years.\n * @param dateA - A date to compare with the dateB date\n * @param [dateB] - A date to compare with the dateA date or nothing to compare with the current time\n */\nexport function diffYears(dateA: DateInput, dateB?: MaybeDateInput): number\n\n/**\n * Returns the difference between 2 dates in years.\n * @param [dateA] - A date to compare with the dateB date or null to compare with the current time\n * @param dateB - A date to compare with the dateA date\n */\nexport function diffYears(dateA: MaybeDateInput, dateB: DateInput): number\nexport function diffYears(dateA: MaybeDateInput, dateB?: MaybeDateInput): number {\n const r = Math.trunc(\n //@ts-ignore\n diffMonths(dateA, dateB) / 12\n )\n //ensures we don't give back -0\n return r == 0 ? 0 : r\n}\n"],"mappings":";AAAA,SAAS,kBAAkB;AAgBpB,SAAS,UAAU,OAAuB,OAAgC;AAC/E,QAAM,IAAI,KAAK;AAAA;AAAA,IAEb,WAAW,OAAO,KAAK,IAAI;AAAA,EAC7B;AAEA,SAAO,KAAK,IAAI,IAAI;AACtB;","names":[]}
|
package/dist/format.mjs
CHANGED
|
@@ -19,8 +19,7 @@ function format(inputDateOrOptions, format2 = "long", locale = "device", genitiv
|
|
|
19
19
|
tz
|
|
20
20
|
} = inputDateOrOptions);
|
|
21
21
|
}
|
|
22
|
-
if (format2 === "ISO8601")
|
|
23
|
-
return date(inputDateOrOptions).toISOString();
|
|
22
|
+
if (format2 === "ISO8601") return date(inputDateOrOptions).toISOString();
|
|
24
23
|
if (tz) {
|
|
25
24
|
forceOffset = offset(inputDateOrOptions, "utc", tz, getOffsetFormat(format2));
|
|
26
25
|
}
|
|
@@ -36,7 +35,7 @@ function format(inputDateOrOptions, format2 = "long", locale = "device", genitiv
|
|
|
36
35
|
}
|
|
37
36
|
return fill(
|
|
38
37
|
inputDateOrOptions,
|
|
39
|
-
parts(format2, locale).filter(partFilter != null ? partFilter : () => true),
|
|
38
|
+
parts(format2, locale).filter(partFilter != null ? partFilter : (() => true)),
|
|
40
39
|
locale,
|
|
41
40
|
genitive,
|
|
42
41
|
forceOffset
|
package/dist/format.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/format.ts"],"sourcesContent":["import { date } from \"./date\"\nimport { parts } from \"./parts\"\nimport { fill, getOffsetFormat } from \"./common\"\nimport type {\n DateInput,\n Format,\n FormatOptions,\n FormatStyle,\n Part,\n} from \"./types\"\nimport { offset } from \"./offset\"\nimport { removeOffset } from \"./removeOffset\"\nimport { deviceLocale } from \"./deviceLocale\"\nimport { deviceTZ } from \"./deviceTZ\"\n\n/**\n * Produce a formatted string. Available strings:\n * token | description\n * ------|------------\n * YY | 2 digit year\n * YYYY | 4 digit year\n * M | The month 1-12\n * MM | The month 01-12\n * MMM | Short name Jan-Dec\n * MMMM | Full name January | December\n * D | The day of the month 1-31\n * DD | The day of the month 01-31\n * d | Single digit day \"T\"\n * ddd | Short day name Thu\n * dddd | Full day name Wednesday\n * H | Minimum hour digits, 24 hour, 0-23\n * HH | 2 hour digits, 24 hour, 00-23\n * h | Minimum hour digits, 12 hour clock, 1-12\n * hh | 2 hour digits, 12 hour clock, 01-12\n * m | The minute 0-59\n * mm | The minute 00-59\n * s | The second 0-59\n * ss | The second 00-59\n * a | am/pm\n * A | AM/PM\n * Z | +0800, +0530, -1345\n *\n * @param inputDate - A date object or ISO 8601 string\n * @param format - A format\n */\nexport function format(options: FormatOptions): string\nexport function format(\n inputDate: DateInput,\n format?: Format,\n locale?: string,\n genitive?: boolean,\n partFilter?: (part: Part) => boolean\n): string\nexport function format(\n inputDateOrOptions: DateInput | FormatOptions,\n format: Format = \"long\",\n locale: string | undefined = \"device\",\n genitive: boolean | undefined = false,\n partFilter?: (part: Part) => boolean\n): string {\n let tz: string | undefined, forceOffset: string | undefined\n\n if (\n typeof inputDateOrOptions === \"object\" &&\n !(inputDateOrOptions instanceof Date)\n ) {\n // Extract options from the object.\n ;({\n date: inputDateOrOptions,\n format,\n locale,\n genitive,\n partFilter,\n tz,\n } = inputDateOrOptions)\n }\n // ISO 8601 is a special case because it doesn't require a format.\n if (format === \"ISO8601\") return date(inputDateOrOptions).toISOString()\n\n if (tz) {\n forceOffset = offset(inputDateOrOptions, \"utc\", tz, getOffsetFormat(format))\n }\n\n // We need to apply an offset to the date so that it can be formatted as UTC.\n tz ??= deviceTZ()\n if (tz?.toLowerCase() !== \"utc\") {\n inputDateOrOptions = removeOffset(\n inputDateOrOptions,\n offset(inputDateOrOptions, tz, \"utc\")\n )\n }\n\n if (!locale || locale === \"device\") {\n locale = deviceLocale()\n }\n\n return fill(\n inputDateOrOptions,\n parts(format, locale).filter(partFilter ?? (() => true)),\n locale,\n genitive,\n forceOffset\n )\n .map((p) => p.value)\n .join(\"\")\n}\n"],"mappings":";AAAA,SAAS,YAAY;AACrB,SAAS,aAAa;AACtB,SAAS,MAAM,uBAAuB;AAQtC,SAAS,cAAc;AACvB,SAAS,oBAAoB;AAC7B,SAAS,oBAAoB;AAC7B,SAAS,gBAAgB;AAwClB,SAAS,OACd,oBACAA,UAAiB,QACjB,SAA6B,UAC7B,WAAgC,OAChC,YACQ;AACR,MAAI,IAAwB;AAE5B,MACE,OAAO,uBAAuB,YAC9B,EAAE,8BAA8B,OAChC;AAEA;AAAC,KAAC;AAAA,MACA,MAAM;AAAA,MACN,QAAAA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF,IAAI;AAAA,EACN;AAEA,MAAIA,YAAW
|
|
1
|
+
{"version":3,"sources":["../src/format.ts"],"sourcesContent":["import { date } from \"./date\"\nimport { parts } from \"./parts\"\nimport { fill, getOffsetFormat } from \"./common\"\nimport type {\n DateInput,\n Format,\n FormatOptions,\n FormatStyle,\n Part,\n} from \"./types\"\nimport { offset } from \"./offset\"\nimport { removeOffset } from \"./removeOffset\"\nimport { deviceLocale } from \"./deviceLocale\"\nimport { deviceTZ } from \"./deviceTZ\"\n\n/**\n * Produce a formatted string. Available strings:\n * token | description\n * ------|------------\n * YY | 2 digit year\n * YYYY | 4 digit year\n * M | The month 1-12\n * MM | The month 01-12\n * MMM | Short name Jan-Dec\n * MMMM | Full name January | December\n * D | The day of the month 1-31\n * DD | The day of the month 01-31\n * d | Single digit day \"T\"\n * ddd | Short day name Thu\n * dddd | Full day name Wednesday\n * H | Minimum hour digits, 24 hour, 0-23\n * HH | 2 hour digits, 24 hour, 00-23\n * h | Minimum hour digits, 12 hour clock, 1-12\n * hh | 2 hour digits, 12 hour clock, 01-12\n * m | The minute 0-59\n * mm | The minute 00-59\n * s | The second 0-59\n * ss | The second 00-59\n * a | am/pm\n * A | AM/PM\n * Z | +0800, +0530, -1345\n *\n * @param inputDate - A date object or ISO 8601 string\n * @param format - A format\n */\nexport function format(options: FormatOptions): string\nexport function format(\n inputDate: DateInput,\n format?: Format,\n locale?: string,\n genitive?: boolean,\n partFilter?: (part: Part) => boolean\n): string\nexport function format(\n inputDateOrOptions: DateInput | FormatOptions,\n format: Format = \"long\",\n locale: string | undefined = \"device\",\n genitive: boolean | undefined = false,\n partFilter?: (part: Part) => boolean\n): string {\n let tz: string | undefined, forceOffset: string | undefined\n\n if (\n typeof inputDateOrOptions === \"object\" &&\n !(inputDateOrOptions instanceof Date)\n ) {\n // Extract options from the object.\n ;({\n date: inputDateOrOptions,\n format,\n locale,\n genitive,\n partFilter,\n tz,\n } = inputDateOrOptions)\n }\n // ISO 8601 is a special case because it doesn't require a format.\n if (format === \"ISO8601\") return date(inputDateOrOptions).toISOString()\n\n if (tz) {\n forceOffset = offset(inputDateOrOptions, \"utc\", tz, getOffsetFormat(format))\n }\n\n // We need to apply an offset to the date so that it can be formatted as UTC.\n tz ??= deviceTZ()\n if (tz?.toLowerCase() !== \"utc\") {\n inputDateOrOptions = removeOffset(\n inputDateOrOptions,\n offset(inputDateOrOptions, tz, \"utc\")\n )\n }\n\n if (!locale || locale === \"device\") {\n locale = deviceLocale()\n }\n\n return fill(\n inputDateOrOptions,\n parts(format, locale).filter(partFilter ?? (() => true)),\n locale,\n genitive,\n forceOffset\n )\n .map((p) => p.value)\n .join(\"\")\n}\n"],"mappings":";AAAA,SAAS,YAAY;AACrB,SAAS,aAAa;AACtB,SAAS,MAAM,uBAAuB;AAQtC,SAAS,cAAc;AACvB,SAAS,oBAAoB;AAC7B,SAAS,oBAAoB;AAC7B,SAAS,gBAAgB;AAwClB,SAAS,OACd,oBACAA,UAAiB,QACjB,SAA6B,UAC7B,WAAgC,OAChC,YACQ;AACR,MAAI,IAAwB;AAE5B,MACE,OAAO,uBAAuB,YAC9B,EAAE,8BAA8B,OAChC;AAEA;AAAC,KAAC;AAAA,MACA,MAAM;AAAA,MACN,QAAAA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF,IAAI;AAAA,EACN;AAEA,MAAIA,YAAW,UAAW,QAAO,KAAK,kBAAkB,EAAE,YAAY;AAEtE,MAAI,IAAI;AACN,kBAAc,OAAO,oBAAoB,OAAO,IAAI,gBAAgBA,OAAM,CAAC;AAAA,EAC7E;AAGA,yBAAO,SAAS;AAChB,OAAI,yBAAI,mBAAkB,OAAO;AAC/B,yBAAqB;AAAA,MACnB;AAAA,MACA,OAAO,oBAAoB,IAAI,KAAK;AAAA,IACtC;AAAA,EACF;AAEA,MAAI,CAAC,UAAU,WAAW,UAAU;AAClC,aAAS,aAAa;AAAA,EACxB;AAEA,SAAO;AAAA,IACL;AAAA,IACA,MAAMA,SAAQ,MAAM,EAAE,OAAO,mCAAe,MAAM,KAAK;AAAA,IACvD;AAAA,IACA;AAAA,IACA;AAAA,EACF,EACG,IAAI,CAAC,MAAM,EAAE,KAAK,EAClB,KAAK,EAAE;AACZ;","names":["format"]}
|
package/dist/hourEnd.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { MaybeDateInput } from './types.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Returns a Date object for end of the given hour.
|
|
5
|
-
* @param inputDate - A string or
|
|
5
|
+
* @param [inputDate] - A string, Date object or nothing for the current time
|
|
6
6
|
*/
|
|
7
|
-
declare function hourEnd(inputDate
|
|
7
|
+
declare function hourEnd(inputDate?: MaybeDateInput): Date;
|
|
8
8
|
|
|
9
9
|
export { hourEnd };
|
package/dist/hourEnd.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/hourEnd.ts"],"sourcesContent":["import { date } from \"./date\"\nimport type {
|
|
1
|
+
{"version":3,"sources":["../src/hourEnd.ts"],"sourcesContent":["import { date } from \"./date\"\nimport type { MaybeDateInput } from \"./types\"\n\n/**\n * Returns a Date object for end of the given hour.\n * @param [inputDate] - A string, Date object or nothing for the current time\n */\nexport function hourEnd(inputDate?: MaybeDateInput): Date {\n const d = date(inputDate)\n d.setMinutes(59, 59, 999)\n return d\n}\n"],"mappings":";AAAA,SAAS,YAAY;AAOd,SAAS,QAAQ,WAAkC;AACxD,QAAM,IAAI,KAAK,SAAS;AACxB,IAAE,WAAW,IAAI,IAAI,GAAG;AACxB,SAAO;AACT;","names":[]}
|
package/dist/hourStart.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { MaybeDateInput } from './types.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Returns a Date object for start of the given hour.
|
|
5
|
-
* @param inputDate - A string or
|
|
5
|
+
* @param [inputDate] - A string, Date object or nothing for the current time
|
|
6
6
|
*/
|
|
7
|
-
declare function hourStart(inputDate
|
|
7
|
+
declare function hourStart(inputDate?: MaybeDateInput): Date;
|
|
8
8
|
|
|
9
9
|
export { hourStart };
|
package/dist/hourStart.mjs
CHANGED
package/dist/hourStart.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/hourStart.ts"],"sourcesContent":["import { date } from \"./date\"\nimport type {
|
|
1
|
+
{"version":3,"sources":["../src/hourStart.ts"],"sourcesContent":["import { date } from \"./date\"\nimport type { MaybeDateInput } from \"./types\"\n\n/**\n * Returns a Date object for start of the given hour.\n * @param [inputDate] - A string, Date object or nothing for the current time\n */\nexport function hourStart(inputDate?: MaybeDateInput): Date {\n const d = date(inputDate)\n d.setMinutes(0, 0, 0)\n return d\n}\n"],"mappings":";AAAA,SAAS,YAAY;AAOd,SAAS,UAAU,WAAkC;AAC1D,QAAM,IAAI,KAAK,SAAS;AACxB,IAAE,WAAW,GAAG,GAAG,CAAC;AACpB,SAAO;AACT;","names":[]}
|