Spaces:
Configuration error
Configuration error
luigi12345
commited on
Commit
•
54d4f5c
1
Parent(s):
61025ca
a891d9a1def64c5167b1adec28ad14f0c20ce63d36ab0ad4d0d880e687012b21
Browse files- workers1/auto3d/node_modules/date-fns/endOfSecond.mjs +30 -0
- workers1/auto3d/node_modules/date-fns/endOfToday.d.mts +19 -0
- workers1/auto3d/node_modules/date-fns/endOfToday.d.ts +19 -0
- workers1/auto3d/node_modules/date-fns/endOfToday.js +25 -0
- workers1/auto3d/node_modules/date-fns/endOfToday.mjs +26 -0
- workers1/auto3d/node_modules/date-fns/endOfTomorrow.d.mts +19 -0
- workers1/auto3d/node_modules/date-fns/endOfTomorrow.d.ts +19 -0
- workers1/auto3d/node_modules/date-fns/endOfTomorrow.js +30 -0
- workers1/auto3d/node_modules/date-fns/endOfTomorrow.mjs +32 -0
- workers1/auto3d/node_modules/date-fns/endOfWeek.d.mts +37 -0
- workers1/auto3d/node_modules/date-fns/endOfWeek.d.ts +37 -0
- workers1/auto3d/node_modules/date-fns/endOfWeek.js +53 -0
- workers1/auto3d/node_modules/date-fns/endOfWeek.mjs +53 -0
- workers1/auto3d/node_modules/date-fns/endOfYear.d.mts +23 -0
- workers1/auto3d/node_modules/date-fns/endOfYear.d.ts +23 -0
- workers1/auto3d/node_modules/date-fns/endOfYear.js +31 -0
- workers1/auto3d/node_modules/date-fns/endOfYear.mjs +32 -0
- workers1/auto3d/node_modules/date-fns/endOfYesterday.d.mts +19 -0
- workers1/auto3d/node_modules/date-fns/endOfYesterday.d.ts +19 -0
- workers1/auto3d/node_modules/date-fns/endOfYesterday.js +30 -0
- workers1/auto3d/node_modules/date-fns/endOfYesterday.mjs +32 -0
- workers1/auto3d/node_modules/date-fns/format.d.mts +310 -0
- workers1/auto3d/node_modules/date-fns/format.d.ts +310 -0
- workers1/auto3d/node_modules/date-fns/format.js +442 -0
- workers1/auto3d/node_modules/date-fns/format.mjs +436 -0
- workers1/auto3d/node_modules/date-fns/formatDistance.d.mts +96 -0
- workers1/auto3d/node_modules/date-fns/formatDistance.d.ts +96 -0
- workers1/auto3d/node_modules/date-fns/formatDistance.js +210 -0
- workers1/auto3d/node_modules/date-fns/formatDistance.mjs +209 -0
- workers1/auto3d/node_modules/date-fns/formatDistanceStrict.d.mts +106 -0
- workers1/auto3d/node_modules/date-fns/formatDistanceStrict.d.ts +106 -0
- workers1/auto3d/node_modules/date-fns/formatDistanceStrict.js +196 -0
- workers1/auto3d/node_modules/date-fns/formatDistanceStrict.mjs +196 -0
- workers1/auto3d/node_modules/date-fns/formatDistanceToNow.d.mts +92 -0
- workers1/auto3d/node_modules/date-fns/formatDistanceToNow.d.ts +92 -0
- workers1/auto3d/node_modules/date-fns/formatDistanceToNow.js +100 -0
- workers1/auto3d/node_modules/date-fns/formatDistanceToNow.mjs +96 -0
- workers1/auto3d/node_modules/date-fns/formatDistanceToNowStrict.d.mts +83 -0
- workers1/auto3d/node_modules/date-fns/formatDistanceToNowStrict.d.ts +83 -0
- workers1/auto3d/node_modules/date-fns/formatDistanceToNowStrict.js +89 -0
- workers1/auto3d/node_modules/date-fns/formatDistanceToNowStrict.mjs +86 -0
- workers1/auto3d/node_modules/date-fns/formatDuration.d.mts +77 -0
- workers1/auto3d/node_modules/date-fns/formatDuration.d.ts +77 -0
- workers1/auto3d/node_modules/date-fns/formatDuration.js +105 -0
- workers1/auto3d/node_modules/date-fns/formatDuration.mjs +104 -0
- workers1/auto3d/node_modules/date-fns/formatISO.d.mts +46 -0
- workers1/auto3d/node_modules/date-fns/formatISO.d.ts +46 -0
- workers1/auto3d/node_modules/date-fns/formatISO.js +109 -0
- workers1/auto3d/node_modules/date-fns/formatISO.mjs +106 -0
- workers1/auto3d/node_modules/date-fns/formatISO9075.d.mts +46 -0
workers1/auto3d/node_modules/date-fns/endOfSecond.mjs
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { toDate } from "./toDate.mjs";
|
2 |
+
|
3 |
+
/**
|
4 |
+
* @name endOfSecond
|
5 |
+
* @category Second Helpers
|
6 |
+
* @summary Return the end of a second for the given date.
|
7 |
+
*
|
8 |
+
* @description
|
9 |
+
* Return the end of a second for the given date.
|
10 |
+
* The result will be in the local timezone.
|
11 |
+
*
|
12 |
+
* @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
|
13 |
+
*
|
14 |
+
* @param date - The original date
|
15 |
+
*
|
16 |
+
* @returns The end of a second
|
17 |
+
*
|
18 |
+
* @example
|
19 |
+
* // The end of a second for 1 December 2014 22:15:45.400:
|
20 |
+
* const result = endOfSecond(new Date(2014, 11, 1, 22, 15, 45, 400))
|
21 |
+
* //=> Mon Dec 01 2014 22:15:45.999
|
22 |
+
*/
|
23 |
+
export function endOfSecond(date) {
|
24 |
+
const _date = toDate(date);
|
25 |
+
_date.setMilliseconds(999);
|
26 |
+
return _date;
|
27 |
+
}
|
28 |
+
|
29 |
+
// Fallback for modularized imports:
|
30 |
+
export default endOfSecond;
|
workers1/auto3d/node_modules/date-fns/endOfToday.d.mts
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* @name endOfToday
|
3 |
+
* @category Day Helpers
|
4 |
+
* @summary Return the end of today.
|
5 |
+
* @pure false
|
6 |
+
*
|
7 |
+
* @description
|
8 |
+
* Return the end of today.
|
9 |
+
*
|
10 |
+
* @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
|
11 |
+
*
|
12 |
+
* @returns The end of today
|
13 |
+
*
|
14 |
+
* @example
|
15 |
+
* // If today is 6 October 2014:
|
16 |
+
* const result = endOfToday()
|
17 |
+
* //=> Mon Oct 6 2014 23:59:59.999
|
18 |
+
*/
|
19 |
+
export declare function endOfToday(): Date;
|
workers1/auto3d/node_modules/date-fns/endOfToday.d.ts
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* @name endOfToday
|
3 |
+
* @category Day Helpers
|
4 |
+
* @summary Return the end of today.
|
5 |
+
* @pure false
|
6 |
+
*
|
7 |
+
* @description
|
8 |
+
* Return the end of today.
|
9 |
+
*
|
10 |
+
* @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
|
11 |
+
*
|
12 |
+
* @returns The end of today
|
13 |
+
*
|
14 |
+
* @example
|
15 |
+
* // If today is 6 October 2014:
|
16 |
+
* const result = endOfToday()
|
17 |
+
* //=> Mon Oct 6 2014 23:59:59.999
|
18 |
+
*/
|
19 |
+
export declare function endOfToday(): Date;
|
workers1/auto3d/node_modules/date-fns/endOfToday.js
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"use strict";
|
2 |
+
exports.endOfToday = endOfToday;
|
3 |
+
var _index = require("./endOfDay.js");
|
4 |
+
|
5 |
+
/**
|
6 |
+
* @name endOfToday
|
7 |
+
* @category Day Helpers
|
8 |
+
* @summary Return the end of today.
|
9 |
+
* @pure false
|
10 |
+
*
|
11 |
+
* @description
|
12 |
+
* Return the end of today.
|
13 |
+
*
|
14 |
+
* @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
|
15 |
+
*
|
16 |
+
* @returns The end of today
|
17 |
+
*
|
18 |
+
* @example
|
19 |
+
* // If today is 6 October 2014:
|
20 |
+
* const result = endOfToday()
|
21 |
+
* //=> Mon Oct 6 2014 23:59:59.999
|
22 |
+
*/
|
23 |
+
function endOfToday() {
|
24 |
+
return (0, _index.endOfDay)(Date.now());
|
25 |
+
}
|
workers1/auto3d/node_modules/date-fns/endOfToday.mjs
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { endOfDay } from "./endOfDay.mjs";
|
2 |
+
|
3 |
+
/**
|
4 |
+
* @name endOfToday
|
5 |
+
* @category Day Helpers
|
6 |
+
* @summary Return the end of today.
|
7 |
+
* @pure false
|
8 |
+
*
|
9 |
+
* @description
|
10 |
+
* Return the end of today.
|
11 |
+
*
|
12 |
+
* @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
|
13 |
+
*
|
14 |
+
* @returns The end of today
|
15 |
+
*
|
16 |
+
* @example
|
17 |
+
* // If today is 6 October 2014:
|
18 |
+
* const result = endOfToday()
|
19 |
+
* //=> Mon Oct 6 2014 23:59:59.999
|
20 |
+
*/
|
21 |
+
export function endOfToday() {
|
22 |
+
return endOfDay(Date.now());
|
23 |
+
}
|
24 |
+
|
25 |
+
// Fallback for modularized imports:
|
26 |
+
export default endOfToday;
|
workers1/auto3d/node_modules/date-fns/endOfTomorrow.d.mts
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* @name endOfTomorrow
|
3 |
+
* @category Day Helpers
|
4 |
+
* @summary Return the end of tomorrow.
|
5 |
+
* @pure false
|
6 |
+
*
|
7 |
+
* @description
|
8 |
+
* Return the end of tomorrow.
|
9 |
+
*
|
10 |
+
* @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
|
11 |
+
*
|
12 |
+
* @returns The end of tomorrow
|
13 |
+
*
|
14 |
+
* @example
|
15 |
+
* // If today is 6 October 2014:
|
16 |
+
* const result = endOfTomorrow()
|
17 |
+
* //=> Tue Oct 7 2014 23:59:59.999
|
18 |
+
*/
|
19 |
+
export declare function endOfTomorrow(): Date;
|
workers1/auto3d/node_modules/date-fns/endOfTomorrow.d.ts
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* @name endOfTomorrow
|
3 |
+
* @category Day Helpers
|
4 |
+
* @summary Return the end of tomorrow.
|
5 |
+
* @pure false
|
6 |
+
*
|
7 |
+
* @description
|
8 |
+
* Return the end of tomorrow.
|
9 |
+
*
|
10 |
+
* @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
|
11 |
+
*
|
12 |
+
* @returns The end of tomorrow
|
13 |
+
*
|
14 |
+
* @example
|
15 |
+
* // If today is 6 October 2014:
|
16 |
+
* const result = endOfTomorrow()
|
17 |
+
* //=> Tue Oct 7 2014 23:59:59.999
|
18 |
+
*/
|
19 |
+
export declare function endOfTomorrow(): Date;
|
workers1/auto3d/node_modules/date-fns/endOfTomorrow.js
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"use strict";
|
2 |
+
exports.endOfTomorrow = endOfTomorrow; /**
|
3 |
+
* @name endOfTomorrow
|
4 |
+
* @category Day Helpers
|
5 |
+
* @summary Return the end of tomorrow.
|
6 |
+
* @pure false
|
7 |
+
*
|
8 |
+
* @description
|
9 |
+
* Return the end of tomorrow.
|
10 |
+
*
|
11 |
+
* @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
|
12 |
+
*
|
13 |
+
* @returns The end of tomorrow
|
14 |
+
*
|
15 |
+
* @example
|
16 |
+
* // If today is 6 October 2014:
|
17 |
+
* const result = endOfTomorrow()
|
18 |
+
* //=> Tue Oct 7 2014 23:59:59.999
|
19 |
+
*/
|
20 |
+
function endOfTomorrow() {
|
21 |
+
const now = new Date();
|
22 |
+
const year = now.getFullYear();
|
23 |
+
const month = now.getMonth();
|
24 |
+
const day = now.getDate();
|
25 |
+
|
26 |
+
const date = new Date(0);
|
27 |
+
date.setFullYear(year, month, day + 1);
|
28 |
+
date.setHours(23, 59, 59, 999);
|
29 |
+
return date;
|
30 |
+
}
|
workers1/auto3d/node_modules/date-fns/endOfTomorrow.mjs
ADDED
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* @name endOfTomorrow
|
3 |
+
* @category Day Helpers
|
4 |
+
* @summary Return the end of tomorrow.
|
5 |
+
* @pure false
|
6 |
+
*
|
7 |
+
* @description
|
8 |
+
* Return the end of tomorrow.
|
9 |
+
*
|
10 |
+
* @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
|
11 |
+
*
|
12 |
+
* @returns The end of tomorrow
|
13 |
+
*
|
14 |
+
* @example
|
15 |
+
* // If today is 6 October 2014:
|
16 |
+
* const result = endOfTomorrow()
|
17 |
+
* //=> Tue Oct 7 2014 23:59:59.999
|
18 |
+
*/
|
19 |
+
export function endOfTomorrow() {
|
20 |
+
const now = new Date();
|
21 |
+
const year = now.getFullYear();
|
22 |
+
const month = now.getMonth();
|
23 |
+
const day = now.getDate();
|
24 |
+
|
25 |
+
const date = new Date(0);
|
26 |
+
date.setFullYear(year, month, day + 1);
|
27 |
+
date.setHours(23, 59, 59, 999);
|
28 |
+
return date;
|
29 |
+
}
|
30 |
+
|
31 |
+
// Fallback for modularized imports:
|
32 |
+
export default endOfTomorrow;
|
workers1/auto3d/node_modules/date-fns/endOfWeek.d.mts
ADDED
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import type { LocalizedOptions, WeekOptions } from "./types.js";
|
2 |
+
/**
|
3 |
+
* The {@link endOfWeek} function options.
|
4 |
+
*/
|
5 |
+
export interface EndOfWeekOptions
|
6 |
+
extends WeekOptions,
|
7 |
+
LocalizedOptions<"options"> {}
|
8 |
+
/**
|
9 |
+
* @name endOfWeek
|
10 |
+
* @category Week Helpers
|
11 |
+
* @summary Return the end of a week for the given date.
|
12 |
+
*
|
13 |
+
* @description
|
14 |
+
* Return the end of a week for the given date.
|
15 |
+
* The result will be in the local timezone.
|
16 |
+
*
|
17 |
+
* @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
|
18 |
+
*
|
19 |
+
* @param date - The original date
|
20 |
+
* @param options - An object with options
|
21 |
+
*
|
22 |
+
* @returns The end of a week
|
23 |
+
*
|
24 |
+
* @example
|
25 |
+
* // The end of a week for 2 September 2014 11:55:00:
|
26 |
+
* const result = endOfWeek(new Date(2014, 8, 2, 11, 55, 0))
|
27 |
+
* //=> Sat Sep 06 2014 23:59:59.999
|
28 |
+
*
|
29 |
+
* @example
|
30 |
+
* // If the week starts on Monday, the end of the week for 2 September 2014 11:55:00:
|
31 |
+
* const result = endOfWeek(new Date(2014, 8, 2, 11, 55, 0), { weekStartsOn: 1 })
|
32 |
+
* //=> Sun Sep 07 2014 23:59:59.999
|
33 |
+
*/
|
34 |
+
export declare function endOfWeek<DateType extends Date>(
|
35 |
+
date: DateType | number | string,
|
36 |
+
options?: EndOfWeekOptions,
|
37 |
+
): DateType;
|
workers1/auto3d/node_modules/date-fns/endOfWeek.d.ts
ADDED
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import type { LocalizedOptions, WeekOptions } from "./types.js";
|
2 |
+
/**
|
3 |
+
* The {@link endOfWeek} function options.
|
4 |
+
*/
|
5 |
+
export interface EndOfWeekOptions
|
6 |
+
extends WeekOptions,
|
7 |
+
LocalizedOptions<"options"> {}
|
8 |
+
/**
|
9 |
+
* @name endOfWeek
|
10 |
+
* @category Week Helpers
|
11 |
+
* @summary Return the end of a week for the given date.
|
12 |
+
*
|
13 |
+
* @description
|
14 |
+
* Return the end of a week for the given date.
|
15 |
+
* The result will be in the local timezone.
|
16 |
+
*
|
17 |
+
* @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
|
18 |
+
*
|
19 |
+
* @param date - The original date
|
20 |
+
* @param options - An object with options
|
21 |
+
*
|
22 |
+
* @returns The end of a week
|
23 |
+
*
|
24 |
+
* @example
|
25 |
+
* // The end of a week for 2 September 2014 11:55:00:
|
26 |
+
* const result = endOfWeek(new Date(2014, 8, 2, 11, 55, 0))
|
27 |
+
* //=> Sat Sep 06 2014 23:59:59.999
|
28 |
+
*
|
29 |
+
* @example
|
30 |
+
* // If the week starts on Monday, the end of the week for 2 September 2014 11:55:00:
|
31 |
+
* const result = endOfWeek(new Date(2014, 8, 2, 11, 55, 0), { weekStartsOn: 1 })
|
32 |
+
* //=> Sun Sep 07 2014 23:59:59.999
|
33 |
+
*/
|
34 |
+
export declare function endOfWeek<DateType extends Date>(
|
35 |
+
date: DateType | number | string,
|
36 |
+
options?: EndOfWeekOptions,
|
37 |
+
): DateType;
|
workers1/auto3d/node_modules/date-fns/endOfWeek.js
ADDED
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"use strict";
|
2 |
+
exports.endOfWeek = endOfWeek;
|
3 |
+
var _index = require("./toDate.js");
|
4 |
+
|
5 |
+
var _index2 = require("./_lib/defaultOptions.js");
|
6 |
+
|
7 |
+
/**
|
8 |
+
* The {@link endOfWeek} function options.
|
9 |
+
*/
|
10 |
+
|
11 |
+
/**
|
12 |
+
* @name endOfWeek
|
13 |
+
* @category Week Helpers
|
14 |
+
* @summary Return the end of a week for the given date.
|
15 |
+
*
|
16 |
+
* @description
|
17 |
+
* Return the end of a week for the given date.
|
18 |
+
* The result will be in the local timezone.
|
19 |
+
*
|
20 |
+
* @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
|
21 |
+
*
|
22 |
+
* @param date - The original date
|
23 |
+
* @param options - An object with options
|
24 |
+
*
|
25 |
+
* @returns The end of a week
|
26 |
+
*
|
27 |
+
* @example
|
28 |
+
* // The end of a week for 2 September 2014 11:55:00:
|
29 |
+
* const result = endOfWeek(new Date(2014, 8, 2, 11, 55, 0))
|
30 |
+
* //=> Sat Sep 06 2014 23:59:59.999
|
31 |
+
*
|
32 |
+
* @example
|
33 |
+
* // If the week starts on Monday, the end of the week for 2 September 2014 11:55:00:
|
34 |
+
* const result = endOfWeek(new Date(2014, 8, 2, 11, 55, 0), { weekStartsOn: 1 })
|
35 |
+
* //=> Sun Sep 07 2014 23:59:59.999
|
36 |
+
*/
|
37 |
+
function endOfWeek(date, options) {
|
38 |
+
const defaultOptions = (0, _index2.getDefaultOptions)();
|
39 |
+
const weekStartsOn =
|
40 |
+
options?.weekStartsOn ??
|
41 |
+
options?.locale?.options?.weekStartsOn ??
|
42 |
+
defaultOptions.weekStartsOn ??
|
43 |
+
defaultOptions.locale?.options?.weekStartsOn ??
|
44 |
+
0;
|
45 |
+
|
46 |
+
const _date = (0, _index.toDate)(date);
|
47 |
+
const day = _date.getDay();
|
48 |
+
const diff = (day < weekStartsOn ? -7 : 0) + 6 - (day - weekStartsOn);
|
49 |
+
|
50 |
+
_date.setDate(_date.getDate() + diff);
|
51 |
+
_date.setHours(23, 59, 59, 999);
|
52 |
+
return _date;
|
53 |
+
}
|
workers1/auto3d/node_modules/date-fns/endOfWeek.mjs
ADDED
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { toDate } from "./toDate.mjs";
|
2 |
+
import { getDefaultOptions } from "./_lib/defaultOptions.mjs";
|
3 |
+
|
4 |
+
/**
|
5 |
+
* The {@link endOfWeek} function options.
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* @name endOfWeek
|
10 |
+
* @category Week Helpers
|
11 |
+
* @summary Return the end of a week for the given date.
|
12 |
+
*
|
13 |
+
* @description
|
14 |
+
* Return the end of a week for the given date.
|
15 |
+
* The result will be in the local timezone.
|
16 |
+
*
|
17 |
+
* @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
|
18 |
+
*
|
19 |
+
* @param date - The original date
|
20 |
+
* @param options - An object with options
|
21 |
+
*
|
22 |
+
* @returns The end of a week
|
23 |
+
*
|
24 |
+
* @example
|
25 |
+
* // The end of a week for 2 September 2014 11:55:00:
|
26 |
+
* const result = endOfWeek(new Date(2014, 8, 2, 11, 55, 0))
|
27 |
+
* //=> Sat Sep 06 2014 23:59:59.999
|
28 |
+
*
|
29 |
+
* @example
|
30 |
+
* // If the week starts on Monday, the end of the week for 2 September 2014 11:55:00:
|
31 |
+
* const result = endOfWeek(new Date(2014, 8, 2, 11, 55, 0), { weekStartsOn: 1 })
|
32 |
+
* //=> Sun Sep 07 2014 23:59:59.999
|
33 |
+
*/
|
34 |
+
export function endOfWeek(date, options) {
|
35 |
+
const defaultOptions = getDefaultOptions();
|
36 |
+
const weekStartsOn =
|
37 |
+
options?.weekStartsOn ??
|
38 |
+
options?.locale?.options?.weekStartsOn ??
|
39 |
+
defaultOptions.weekStartsOn ??
|
40 |
+
defaultOptions.locale?.options?.weekStartsOn ??
|
41 |
+
0;
|
42 |
+
|
43 |
+
const _date = toDate(date);
|
44 |
+
const day = _date.getDay();
|
45 |
+
const diff = (day < weekStartsOn ? -7 : 0) + 6 - (day - weekStartsOn);
|
46 |
+
|
47 |
+
_date.setDate(_date.getDate() + diff);
|
48 |
+
_date.setHours(23, 59, 59, 999);
|
49 |
+
return _date;
|
50 |
+
}
|
51 |
+
|
52 |
+
// Fallback for modularized imports:
|
53 |
+
export default endOfWeek;
|
workers1/auto3d/node_modules/date-fns/endOfYear.d.mts
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* @name endOfYear
|
3 |
+
* @category Year Helpers
|
4 |
+
* @summary Return the end of a year for the given date.
|
5 |
+
*
|
6 |
+
* @description
|
7 |
+
* Return the end of a year for the given date.
|
8 |
+
* The result will be in the local timezone.
|
9 |
+
*
|
10 |
+
* @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
|
11 |
+
*
|
12 |
+
* @param date - The original date
|
13 |
+
*
|
14 |
+
* @returns The end of a year
|
15 |
+
*
|
16 |
+
* @example
|
17 |
+
* // The end of a year for 2 September 2014 11:55:00:
|
18 |
+
* const result = endOfYear(new Date(2014, 8, 2, 11, 55, 00))
|
19 |
+
* //=> Wed Dec 31 2014 23:59:59.999
|
20 |
+
*/
|
21 |
+
export declare function endOfYear<DateType extends Date>(
|
22 |
+
date: DateType | number | string,
|
23 |
+
): DateType;
|
workers1/auto3d/node_modules/date-fns/endOfYear.d.ts
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* @name endOfYear
|
3 |
+
* @category Year Helpers
|
4 |
+
* @summary Return the end of a year for the given date.
|
5 |
+
*
|
6 |
+
* @description
|
7 |
+
* Return the end of a year for the given date.
|
8 |
+
* The result will be in the local timezone.
|
9 |
+
*
|
10 |
+
* @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
|
11 |
+
*
|
12 |
+
* @param date - The original date
|
13 |
+
*
|
14 |
+
* @returns The end of a year
|
15 |
+
*
|
16 |
+
* @example
|
17 |
+
* // The end of a year for 2 September 2014 11:55:00:
|
18 |
+
* const result = endOfYear(new Date(2014, 8, 2, 11, 55, 00))
|
19 |
+
* //=> Wed Dec 31 2014 23:59:59.999
|
20 |
+
*/
|
21 |
+
export declare function endOfYear<DateType extends Date>(
|
22 |
+
date: DateType | number | string,
|
23 |
+
): DateType;
|
workers1/auto3d/node_modules/date-fns/endOfYear.js
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"use strict";
|
2 |
+
exports.endOfYear = endOfYear;
|
3 |
+
var _index = require("./toDate.js");
|
4 |
+
|
5 |
+
/**
|
6 |
+
* @name endOfYear
|
7 |
+
* @category Year Helpers
|
8 |
+
* @summary Return the end of a year for the given date.
|
9 |
+
*
|
10 |
+
* @description
|
11 |
+
* Return the end of a year for the given date.
|
12 |
+
* The result will be in the local timezone.
|
13 |
+
*
|
14 |
+
* @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
|
15 |
+
*
|
16 |
+
* @param date - The original date
|
17 |
+
*
|
18 |
+
* @returns The end of a year
|
19 |
+
*
|
20 |
+
* @example
|
21 |
+
* // The end of a year for 2 September 2014 11:55:00:
|
22 |
+
* const result = endOfYear(new Date(2014, 8, 2, 11, 55, 00))
|
23 |
+
* //=> Wed Dec 31 2014 23:59:59.999
|
24 |
+
*/
|
25 |
+
function endOfYear(date) {
|
26 |
+
const _date = (0, _index.toDate)(date);
|
27 |
+
const year = _date.getFullYear();
|
28 |
+
_date.setFullYear(year + 1, 0, 0);
|
29 |
+
_date.setHours(23, 59, 59, 999);
|
30 |
+
return _date;
|
31 |
+
}
|
workers1/auto3d/node_modules/date-fns/endOfYear.mjs
ADDED
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { toDate } from "./toDate.mjs";
|
2 |
+
|
3 |
+
/**
|
4 |
+
* @name endOfYear
|
5 |
+
* @category Year Helpers
|
6 |
+
* @summary Return the end of a year for the given date.
|
7 |
+
*
|
8 |
+
* @description
|
9 |
+
* Return the end of a year for the given date.
|
10 |
+
* The result will be in the local timezone.
|
11 |
+
*
|
12 |
+
* @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
|
13 |
+
*
|
14 |
+
* @param date - The original date
|
15 |
+
*
|
16 |
+
* @returns The end of a year
|
17 |
+
*
|
18 |
+
* @example
|
19 |
+
* // The end of a year for 2 September 2014 11:55:00:
|
20 |
+
* const result = endOfYear(new Date(2014, 8, 2, 11, 55, 00))
|
21 |
+
* //=> Wed Dec 31 2014 23:59:59.999
|
22 |
+
*/
|
23 |
+
export function endOfYear(date) {
|
24 |
+
const _date = toDate(date);
|
25 |
+
const year = _date.getFullYear();
|
26 |
+
_date.setFullYear(year + 1, 0, 0);
|
27 |
+
_date.setHours(23, 59, 59, 999);
|
28 |
+
return _date;
|
29 |
+
}
|
30 |
+
|
31 |
+
// Fallback for modularized imports:
|
32 |
+
export default endOfYear;
|
workers1/auto3d/node_modules/date-fns/endOfYesterday.d.mts
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* @name endOfYesterday
|
3 |
+
* @category Day Helpers
|
4 |
+
* @summary Return the end of yesterday.
|
5 |
+
* @pure false
|
6 |
+
*
|
7 |
+
* @description
|
8 |
+
* Return the end of yesterday.
|
9 |
+
*
|
10 |
+
* @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
|
11 |
+
*
|
12 |
+
* @returns The end of yesterday
|
13 |
+
*
|
14 |
+
* @example
|
15 |
+
* // If today is 6 October 2014:
|
16 |
+
* const result = endOfYesterday()
|
17 |
+
* //=> Sun Oct 5 2014 23:59:59.999
|
18 |
+
*/
|
19 |
+
export declare function endOfYesterday(): Date;
|
workers1/auto3d/node_modules/date-fns/endOfYesterday.d.ts
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* @name endOfYesterday
|
3 |
+
* @category Day Helpers
|
4 |
+
* @summary Return the end of yesterday.
|
5 |
+
* @pure false
|
6 |
+
*
|
7 |
+
* @description
|
8 |
+
* Return the end of yesterday.
|
9 |
+
*
|
10 |
+
* @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
|
11 |
+
*
|
12 |
+
* @returns The end of yesterday
|
13 |
+
*
|
14 |
+
* @example
|
15 |
+
* // If today is 6 October 2014:
|
16 |
+
* const result = endOfYesterday()
|
17 |
+
* //=> Sun Oct 5 2014 23:59:59.999
|
18 |
+
*/
|
19 |
+
export declare function endOfYesterday(): Date;
|
workers1/auto3d/node_modules/date-fns/endOfYesterday.js
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"use strict";
|
2 |
+
exports.endOfYesterday = endOfYesterday; /**
|
3 |
+
* @name endOfYesterday
|
4 |
+
* @category Day Helpers
|
5 |
+
* @summary Return the end of yesterday.
|
6 |
+
* @pure false
|
7 |
+
*
|
8 |
+
* @description
|
9 |
+
* Return the end of yesterday.
|
10 |
+
*
|
11 |
+
* @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
|
12 |
+
*
|
13 |
+
* @returns The end of yesterday
|
14 |
+
*
|
15 |
+
* @example
|
16 |
+
* // If today is 6 October 2014:
|
17 |
+
* const result = endOfYesterday()
|
18 |
+
* //=> Sun Oct 5 2014 23:59:59.999
|
19 |
+
*/
|
20 |
+
function endOfYesterday() {
|
21 |
+
const now = new Date();
|
22 |
+
const year = now.getFullYear();
|
23 |
+
const month = now.getMonth();
|
24 |
+
const day = now.getDate();
|
25 |
+
|
26 |
+
const date = new Date(0);
|
27 |
+
date.setFullYear(year, month, day - 1);
|
28 |
+
date.setHours(23, 59, 59, 999);
|
29 |
+
return date;
|
30 |
+
}
|
workers1/auto3d/node_modules/date-fns/endOfYesterday.mjs
ADDED
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* @name endOfYesterday
|
3 |
+
* @category Day Helpers
|
4 |
+
* @summary Return the end of yesterday.
|
5 |
+
* @pure false
|
6 |
+
*
|
7 |
+
* @description
|
8 |
+
* Return the end of yesterday.
|
9 |
+
*
|
10 |
+
* @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
|
11 |
+
*
|
12 |
+
* @returns The end of yesterday
|
13 |
+
*
|
14 |
+
* @example
|
15 |
+
* // If today is 6 October 2014:
|
16 |
+
* const result = endOfYesterday()
|
17 |
+
* //=> Sun Oct 5 2014 23:59:59.999
|
18 |
+
*/
|
19 |
+
export function endOfYesterday() {
|
20 |
+
const now = new Date();
|
21 |
+
const year = now.getFullYear();
|
22 |
+
const month = now.getMonth();
|
23 |
+
const day = now.getDate();
|
24 |
+
|
25 |
+
const date = new Date(0);
|
26 |
+
date.setFullYear(year, month, day - 1);
|
27 |
+
date.setHours(23, 59, 59, 999);
|
28 |
+
return date;
|
29 |
+
}
|
30 |
+
|
31 |
+
// Fallback for modularized imports:
|
32 |
+
export default endOfYesterday;
|
workers1/auto3d/node_modules/date-fns/format.d.mts
ADDED
@@ -0,0 +1,310 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { formatters } from "./_lib/format/formatters.js";
|
2 |
+
import { longFormatters } from "./_lib/format/longFormatters.js";
|
3 |
+
import type {
|
4 |
+
AdditionalTokensOptions,
|
5 |
+
FirstWeekContainsDateOptions,
|
6 |
+
LocalizedOptions,
|
7 |
+
WeekOptions,
|
8 |
+
} from "./types.js";
|
9 |
+
export { formatters, longFormatters };
|
10 |
+
export { format as formatDate };
|
11 |
+
export type { FormatOptions as FormatDateOptions };
|
12 |
+
/**
|
13 |
+
* The {@link format} function options.
|
14 |
+
*/
|
15 |
+
export interface FormatOptions
|
16 |
+
extends LocalizedOptions<"options" | "localize" | "formatLong">,
|
17 |
+
WeekOptions,
|
18 |
+
FirstWeekContainsDateOptions,
|
19 |
+
AdditionalTokensOptions {}
|
20 |
+
/**
|
21 |
+
* @name format
|
22 |
+
* @alias formatDate
|
23 |
+
* @category Common Helpers
|
24 |
+
* @summary Format the date.
|
25 |
+
*
|
26 |
+
* @description
|
27 |
+
* Return the formatted date string in the given format. The result may vary by locale.
|
28 |
+
*
|
29 |
+
* > ⚠️ Please note that the `format` tokens differ from Moment.js and other libraries.
|
30 |
+
* > See: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
|
31 |
+
*
|
32 |
+
* The characters wrapped between two single quotes characters (') are escaped.
|
33 |
+
* Two single quotes in a row, whether inside or outside a quoted sequence, represent a 'real' single quote.
|
34 |
+
* (see the last example)
|
35 |
+
*
|
36 |
+
* Format of the string is based on Unicode Technical Standard #35:
|
37 |
+
* https://www.unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table
|
38 |
+
* with a few additions (see note 7 below the table).
|
39 |
+
*
|
40 |
+
* Accepted patterns:
|
41 |
+
* | Unit | Pattern | Result examples | Notes |
|
42 |
+
* |---------------------------------|---------|-----------------------------------|-------|
|
43 |
+
* | Era | G..GGG | AD, BC | |
|
44 |
+
* | | GGGG | Anno Domini, Before Christ | 2 |
|
45 |
+
* | | GGGGG | A, B | |
|
46 |
+
* | Calendar year | y | 44, 1, 1900, 2017 | 5 |
|
47 |
+
* | | yo | 44th, 1st, 0th, 17th | 5,7 |
|
48 |
+
* | | yy | 44, 01, 00, 17 | 5 |
|
49 |
+
* | | yyy | 044, 001, 1900, 2017 | 5 |
|
50 |
+
* | | yyyy | 0044, 0001, 1900, 2017 | 5 |
|
51 |
+
* | | yyyyy | ... | 3,5 |
|
52 |
+
* | Local week-numbering year | Y | 44, 1, 1900, 2017 | 5 |
|
53 |
+
* | | Yo | 44th, 1st, 1900th, 2017th | 5,7 |
|
54 |
+
* | | YY | 44, 01, 00, 17 | 5,8 |
|
55 |
+
* | | YYY | 044, 001, 1900, 2017 | 5 |
|
56 |
+
* | | YYYY | 0044, 0001, 1900, 2017 | 5,8 |
|
57 |
+
* | | YYYYY | ... | 3,5 |
|
58 |
+
* | ISO week-numbering year | R | -43, 0, 1, 1900, 2017 | 5,7 |
|
59 |
+
* | | RR | -43, 00, 01, 1900, 2017 | 5,7 |
|
60 |
+
* | | RRR | -043, 000, 001, 1900, 2017 | 5,7 |
|
61 |
+
* | | RRRR | -0043, 0000, 0001, 1900, 2017 | 5,7 |
|
62 |
+
* | | RRRRR | ... | 3,5,7 |
|
63 |
+
* | Extended year | u | -43, 0, 1, 1900, 2017 | 5 |
|
64 |
+
* | | uu | -43, 01, 1900, 2017 | 5 |
|
65 |
+
* | | uuu | -043, 001, 1900, 2017 | 5 |
|
66 |
+
* | | uuuu | -0043, 0001, 1900, 2017 | 5 |
|
67 |
+
* | | uuuuu | ... | 3,5 |
|
68 |
+
* | Quarter (formatting) | Q | 1, 2, 3, 4 | |
|
69 |
+
* | | Qo | 1st, 2nd, 3rd, 4th | 7 |
|
70 |
+
* | | QQ | 01, 02, 03, 04 | |
|
71 |
+
* | | QQQ | Q1, Q2, Q3, Q4 | |
|
72 |
+
* | | QQQQ | 1st quarter, 2nd quarter, ... | 2 |
|
73 |
+
* | | QQQQQ | 1, 2, 3, 4 | 4 |
|
74 |
+
* | Quarter (stand-alone) | q | 1, 2, 3, 4 | |
|
75 |
+
* | | qo | 1st, 2nd, 3rd, 4th | 7 |
|
76 |
+
* | | qq | 01, 02, 03, 04 | |
|
77 |
+
* | | qqq | Q1, Q2, Q3, Q4 | |
|
78 |
+
* | | qqqq | 1st quarter, 2nd quarter, ... | 2 |
|
79 |
+
* | | qqqqq | 1, 2, 3, 4 | 4 |
|
80 |
+
* | Month (formatting) | M | 1, 2, ..., 12 | |
|
81 |
+
* | | Mo | 1st, 2nd, ..., 12th | 7 |
|
82 |
+
* | | MM | 01, 02, ..., 12 | |
|
83 |
+
* | | MMM | Jan, Feb, ..., Dec | |
|
84 |
+
* | | MMMM | January, February, ..., December | 2 |
|
85 |
+
* | | MMMMM | J, F, ..., D | |
|
86 |
+
* | Month (stand-alone) | L | 1, 2, ..., 12 | |
|
87 |
+
* | | Lo | 1st, 2nd, ..., 12th | 7 |
|
88 |
+
* | | LL | 01, 02, ..., 12 | |
|
89 |
+
* | | LLL | Jan, Feb, ..., Dec | |
|
90 |
+
* | | LLLL | January, February, ..., December | 2 |
|
91 |
+
* | | LLLLL | J, F, ..., D | |
|
92 |
+
* | Local week of year | w | 1, 2, ..., 53 | |
|
93 |
+
* | | wo | 1st, 2nd, ..., 53th | 7 |
|
94 |
+
* | | ww | 01, 02, ..., 53 | |
|
95 |
+
* | ISO week of year | I | 1, 2, ..., 53 | 7 |
|
96 |
+
* | | Io | 1st, 2nd, ..., 53th | 7 |
|
97 |
+
* | | II | 01, 02, ..., 53 | 7 |
|
98 |
+
* | Day of month | d | 1, 2, ..., 31 | |
|
99 |
+
* | | do | 1st, 2nd, ..., 31st | 7 |
|
100 |
+
* | | dd | 01, 02, ..., 31 | |
|
101 |
+
* | Day of year | D | 1, 2, ..., 365, 366 | 9 |
|
102 |
+
* | | Do | 1st, 2nd, ..., 365th, 366th | 7 |
|
103 |
+
* | | DD | 01, 02, ..., 365, 366 | 9 |
|
104 |
+
* | | DDD | 001, 002, ..., 365, 366 | |
|
105 |
+
* | | DDDD | ... | 3 |
|
106 |
+
* | Day of week (formatting) | E..EEE | Mon, Tue, Wed, ..., Sun | |
|
107 |
+
* | | EEEE | Monday, Tuesday, ..., Sunday | 2 |
|
108 |
+
* | | EEEEE | M, T, W, T, F, S, S | |
|
109 |
+
* | | EEEEEE | Mo, Tu, We, Th, Fr, Sa, Su | |
|
110 |
+
* | ISO day of week (formatting) | i | 1, 2, 3, ..., 7 | 7 |
|
111 |
+
* | | io | 1st, 2nd, ..., 7th | 7 |
|
112 |
+
* | | ii | 01, 02, ..., 07 | 7 |
|
113 |
+
* | | iii | Mon, Tue, Wed, ..., Sun | 7 |
|
114 |
+
* | | iiii | Monday, Tuesday, ..., Sunday | 2,7 |
|
115 |
+
* | | iiiii | M, T, W, T, F, S, S | 7 |
|
116 |
+
* | | iiiiii | Mo, Tu, We, Th, Fr, Sa, Su | 7 |
|
117 |
+
* | Local day of week (formatting) | e | 2, 3, 4, ..., 1 | |
|
118 |
+
* | | eo | 2nd, 3rd, ..., 1st | 7 |
|
119 |
+
* | | ee | 02, 03, ..., 01 | |
|
120 |
+
* | | eee | Mon, Tue, Wed, ..., Sun | |
|
121 |
+
* | | eeee | Monday, Tuesday, ..., Sunday | 2 |
|
122 |
+
* | | eeeee | M, T, W, T, F, S, S | |
|
123 |
+
* | | eeeeee | Mo, Tu, We, Th, Fr, Sa, Su | |
|
124 |
+
* | Local day of week (stand-alone) | c | 2, 3, 4, ..., 1 | |
|
125 |
+
* | | co | 2nd, 3rd, ..., 1st | 7 |
|
126 |
+
* | | cc | 02, 03, ..., 01 | |
|
127 |
+
* | | ccc | Mon, Tue, Wed, ..., Sun | |
|
128 |
+
* | | cccc | Monday, Tuesday, ..., Sunday | 2 |
|
129 |
+
* | | ccccc | M, T, W, T, F, S, S | |
|
130 |
+
* | | cccccc | Mo, Tu, We, Th, Fr, Sa, Su | |
|
131 |
+
* | AM, PM | a..aa | AM, PM | |
|
132 |
+
* | | aaa | am, pm | |
|
133 |
+
* | | aaaa | a.m., p.m. | 2 |
|
134 |
+
* | | aaaaa | a, p | |
|
135 |
+
* | AM, PM, noon, midnight | b..bb | AM, PM, noon, midnight | |
|
136 |
+
* | | bbb | am, pm, noon, midnight | |
|
137 |
+
* | | bbbb | a.m., p.m., noon, midnight | 2 |
|
138 |
+
* | | bbbbb | a, p, n, mi | |
|
139 |
+
* | Flexible day period | B..BBB | at night, in the morning, ... | |
|
140 |
+
* | | BBBB | at night, in the morning, ... | 2 |
|
141 |
+
* | | BBBBB | at night, in the morning, ... | |
|
142 |
+
* | Hour [1-12] | h | 1, 2, ..., 11, 12 | |
|
143 |
+
* | | ho | 1st, 2nd, ..., 11th, 12th | 7 |
|
144 |
+
* | | hh | 01, 02, ..., 11, 12 | |
|
145 |
+
* | Hour [0-23] | H | 0, 1, 2, ..., 23 | |
|
146 |
+
* | | Ho | 0th, 1st, 2nd, ..., 23rd | 7 |
|
147 |
+
* | | HH | 00, 01, 02, ..., 23 | |
|
148 |
+
* | Hour [0-11] | K | 1, 2, ..., 11, 0 | |
|
149 |
+
* | | Ko | 1st, 2nd, ..., 11th, 0th | 7 |
|
150 |
+
* | | KK | 01, 02, ..., 11, 00 | |
|
151 |
+
* | Hour [1-24] | k | 24, 1, 2, ..., 23 | |
|
152 |
+
* | | ko | 24th, 1st, 2nd, ..., 23rd | 7 |
|
153 |
+
* | | kk | 24, 01, 02, ..., 23 | |
|
154 |
+
* | Minute | m | 0, 1, ..., 59 | |
|
155 |
+
* | | mo | 0th, 1st, ..., 59th | 7 |
|
156 |
+
* | | mm | 00, 01, ..., 59 | |
|
157 |
+
* | Second | s | 0, 1, ..., 59 | |
|
158 |
+
* | | so | 0th, 1st, ..., 59th | 7 |
|
159 |
+
* | | ss | 00, 01, ..., 59 | |
|
160 |
+
* | Fraction of second | S | 0, 1, ..., 9 | |
|
161 |
+
* | | SS | 00, 01, ..., 99 | |
|
162 |
+
* | | SSS | 000, 001, ..., 999 | |
|
163 |
+
* | | SSSS | ... | 3 |
|
164 |
+
* | Timezone (ISO-8601 w/ Z) | X | -08, +0530, Z | |
|
165 |
+
* | | XX | -0800, +0530, Z | |
|
166 |
+
* | | XXX | -08:00, +05:30, Z | |
|
167 |
+
* | | XXXX | -0800, +0530, Z, +123456 | 2 |
|
168 |
+
* | | XXXXX | -08:00, +05:30, Z, +12:34:56 | |
|
169 |
+
* | Timezone (ISO-8601 w/o Z) | x | -08, +0530, +00 | |
|
170 |
+
* | | xx | -0800, +0530, +0000 | |
|
171 |
+
* | | xxx | -08:00, +05:30, +00:00 | 2 |
|
172 |
+
* | | xxxx | -0800, +0530, +0000, +123456 | |
|
173 |
+
* | | xxxxx | -08:00, +05:30, +00:00, +12:34:56 | |
|
174 |
+
* | Timezone (GMT) | O...OOO | GMT-8, GMT+5:30, GMT+0 | |
|
175 |
+
* | | OOOO | GMT-08:00, GMT+05:30, GMT+00:00 | 2 |
|
176 |
+
* | Timezone (specific non-locat.) | z...zzz | GMT-8, GMT+5:30, GMT+0 | 6 |
|
177 |
+
* | | zzzz | GMT-08:00, GMT+05:30, GMT+00:00 | 2,6 |
|
178 |
+
* | Seconds timestamp | t | 512969520 | 7 |
|
179 |
+
* | | tt | ... | 3,7 |
|
180 |
+
* | Milliseconds timestamp | T | 512969520900 | 7 |
|
181 |
+
* | | TT | ... | 3,7 |
|
182 |
+
* | Long localized date | P | 04/29/1453 | 7 |
|
183 |
+
* | | PP | Apr 29, 1453 | 7 |
|
184 |
+
* | | PPP | April 29th, 1453 | 7 |
|
185 |
+
* | | PPPP | Friday, April 29th, 1453 | 2,7 |
|
186 |
+
* | Long localized time | p | 12:00 AM | 7 |
|
187 |
+
* | | pp | 12:00:00 AM | 7 |
|
188 |
+
* | | ppp | 12:00:00 AM GMT+2 | 7 |
|
189 |
+
* | | pppp | 12:00:00 AM GMT+02:00 | 2,7 |
|
190 |
+
* | Combination of date and time | Pp | 04/29/1453, 12:00 AM | 7 |
|
191 |
+
* | | PPpp | Apr 29, 1453, 12:00:00 AM | 7 |
|
192 |
+
* | | PPPppp | April 29th, 1453 at ... | 7 |
|
193 |
+
* | | PPPPpppp| Friday, April 29th, 1453 at ... | 2,7 |
|
194 |
+
* Notes:
|
195 |
+
* 1. "Formatting" units (e.g. formatting quarter) in the default en-US locale
|
196 |
+
* are the same as "stand-alone" units, but are different in some languages.
|
197 |
+
* "Formatting" units are declined according to the rules of the language
|
198 |
+
* in the context of a date. "Stand-alone" units are always nominative singular:
|
199 |
+
*
|
200 |
+
* `format(new Date(2017, 10, 6), 'do LLLL', {locale: cs}) //=> '6. listopad'`
|
201 |
+
*
|
202 |
+
* `format(new Date(2017, 10, 6), 'do MMMM', {locale: cs}) //=> '6. listopadu'`
|
203 |
+
*
|
204 |
+
* 2. Any sequence of the identical letters is a pattern, unless it is escaped by
|
205 |
+
* the single quote characters (see below).
|
206 |
+
* If the sequence is longer than listed in table (e.g. `EEEEEEEEEEE`)
|
207 |
+
* the output will be the same as default pattern for this unit, usually
|
208 |
+
* the longest one (in case of ISO weekdays, `EEEE`). Default patterns for units
|
209 |
+
* are marked with "2" in the last column of the table.
|
210 |
+
*
|
211 |
+
* `format(new Date(2017, 10, 6), 'MMM') //=> 'Nov'`
|
212 |
+
*
|
213 |
+
* `format(new Date(2017, 10, 6), 'MMMM') //=> 'November'`
|
214 |
+
*
|
215 |
+
* `format(new Date(2017, 10, 6), 'MMMMM') //=> 'N'`
|
216 |
+
*
|
217 |
+
* `format(new Date(2017, 10, 6), 'MMMMMM') //=> 'November'`
|
218 |
+
*
|
219 |
+
* `format(new Date(2017, 10, 6), 'MMMMMMM') //=> 'November'`
|
220 |
+
*
|
221 |
+
* 3. Some patterns could be unlimited length (such as `yyyyyyyy`).
|
222 |
+
* The output will be padded with zeros to match the length of the pattern.
|
223 |
+
*
|
224 |
+
* `format(new Date(2017, 10, 6), 'yyyyyyyy') //=> '00002017'`
|
225 |
+
*
|
226 |
+
* 4. `QQQQQ` and `qqqqq` could be not strictly numerical in some locales.
|
227 |
+
* These tokens represent the shortest form of the quarter.
|
228 |
+
*
|
229 |
+
* 5. The main difference between `y` and `u` patterns are B.C. years:
|
230 |
+
*
|
231 |
+
* | Year | `y` | `u` |
|
232 |
+
* |------|-----|-----|
|
233 |
+
* | AC 1 | 1 | 1 |
|
234 |
+
* | BC 1 | 1 | 0 |
|
235 |
+
* | BC 2 | 2 | -1 |
|
236 |
+
*
|
237 |
+
* Also `yy` always returns the last two digits of a year,
|
238 |
+
* while `uu` pads single digit years to 2 characters and returns other years unchanged:
|
239 |
+
*
|
240 |
+
* | Year | `yy` | `uu` |
|
241 |
+
* |------|------|------|
|
242 |
+
* | 1 | 01 | 01 |
|
243 |
+
* | 14 | 14 | 14 |
|
244 |
+
* | 376 | 76 | 376 |
|
245 |
+
* | 1453 | 53 | 1453 |
|
246 |
+
*
|
247 |
+
* The same difference is true for local and ISO week-numbering years (`Y` and `R`),
|
248 |
+
* except local week-numbering years are dependent on `options.weekStartsOn`
|
249 |
+
* and `options.firstWeekContainsDate` (compare [getISOWeekYear](https://date-fns.org/docs/getISOWeekYear)
|
250 |
+
* and [getWeekYear](https://date-fns.org/docs/getWeekYear)).
|
251 |
+
*
|
252 |
+
* 6. Specific non-location timezones are currently unavailable in `date-fns`,
|
253 |
+
* so right now these tokens fall back to GMT timezones.
|
254 |
+
*
|
255 |
+
* 7. These patterns are not in the Unicode Technical Standard #35:
|
256 |
+
* - `i`: ISO day of week
|
257 |
+
* - `I`: ISO week of year
|
258 |
+
* - `R`: ISO week-numbering year
|
259 |
+
* - `t`: seconds timestamp
|
260 |
+
* - `T`: milliseconds timestamp
|
261 |
+
* - `o`: ordinal number modifier
|
262 |
+
* - `P`: long localized date
|
263 |
+
* - `p`: long localized time
|
264 |
+
*
|
265 |
+
* 8. `YY` and `YYYY` tokens represent week-numbering years but they are often confused with years.
|
266 |
+
* You should enable `options.useAdditionalWeekYearTokens` to use them. See: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
|
267 |
+
*
|
268 |
+
* 9. `D` and `DD` tokens represent days of the year but they are often confused with days of the month.
|
269 |
+
* You should enable `options.useAdditionalDayOfYearTokens` to use them. See: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
|
270 |
+
*
|
271 |
+
* @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
|
272 |
+
*
|
273 |
+
* @param date - The original date
|
274 |
+
* @param format - The string of tokens
|
275 |
+
* @param options - An object with options
|
276 |
+
*
|
277 |
+
* @returns The formatted date string
|
278 |
+
*
|
279 |
+
* @throws `date` must not be Invalid Date
|
280 |
+
* @throws `options.locale` must contain `localize` property
|
281 |
+
* @throws `options.locale` must contain `formatLong` property
|
282 |
+
* @throws use `yyyy` instead of `YYYY` for formatting years using [format provided] to the input [input provided]; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
|
283 |
+
* @throws use `yy` instead of `YY` for formatting years using [format provided] to the input [input provided]; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
|
284 |
+
* @throws use `d` instead of `D` for formatting days of the month using [format provided] to the input [input provided]; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
|
285 |
+
* @throws use `dd` instead of `DD` for formatting days of the month using [format provided] to the input [input provided]; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
|
286 |
+
* @throws format string contains an unescaped latin alphabet character
|
287 |
+
*
|
288 |
+
* @example
|
289 |
+
* // Represent 11 February 2014 in middle-endian format:
|
290 |
+
* const result = format(new Date(2014, 1, 11), 'MM/dd/yyyy')
|
291 |
+
* //=> '02/11/2014'
|
292 |
+
*
|
293 |
+
* @example
|
294 |
+
* // Represent 2 July 2014 in Esperanto:
|
295 |
+
* import { eoLocale } from 'date-fns/locale/eo'
|
296 |
+
* const result = format(new Date(2014, 6, 2), "do 'de' MMMM yyyy", {
|
297 |
+
* locale: eoLocale
|
298 |
+
* })
|
299 |
+
* //=> '2-a de julio 2014'
|
300 |
+
*
|
301 |
+
* @example
|
302 |
+
* // Escape string by single quote characters:
|
303 |
+
* const result = format(new Date(2014, 6, 2, 15), "h 'o''clock'")
|
304 |
+
* //=> "3 o'clock"
|
305 |
+
*/
|
306 |
+
export declare function format<DateType extends Date>(
|
307 |
+
date: DateType | number | string,
|
308 |
+
formatStr: string,
|
309 |
+
options?: FormatOptions,
|
310 |
+
): string;
|
workers1/auto3d/node_modules/date-fns/format.d.ts
ADDED
@@ -0,0 +1,310 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { formatters } from "./_lib/format/formatters.js";
|
2 |
+
import { longFormatters } from "./_lib/format/longFormatters.js";
|
3 |
+
import type {
|
4 |
+
AdditionalTokensOptions,
|
5 |
+
FirstWeekContainsDateOptions,
|
6 |
+
LocalizedOptions,
|
7 |
+
WeekOptions,
|
8 |
+
} from "./types.js";
|
9 |
+
export { formatters, longFormatters };
|
10 |
+
export { format as formatDate };
|
11 |
+
export type { FormatOptions as FormatDateOptions };
|
12 |
+
/**
|
13 |
+
* The {@link format} function options.
|
14 |
+
*/
|
15 |
+
export interface FormatOptions
|
16 |
+
extends LocalizedOptions<"options" | "localize" | "formatLong">,
|
17 |
+
WeekOptions,
|
18 |
+
FirstWeekContainsDateOptions,
|
19 |
+
AdditionalTokensOptions {}
|
20 |
+
/**
|
21 |
+
* @name format
|
22 |
+
* @alias formatDate
|
23 |
+
* @category Common Helpers
|
24 |
+
* @summary Format the date.
|
25 |
+
*
|
26 |
+
* @description
|
27 |
+
* Return the formatted date string in the given format. The result may vary by locale.
|
28 |
+
*
|
29 |
+
* > ⚠️ Please note that the `format` tokens differ from Moment.js and other libraries.
|
30 |
+
* > See: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
|
31 |
+
*
|
32 |
+
* The characters wrapped between two single quotes characters (') are escaped.
|
33 |
+
* Two single quotes in a row, whether inside or outside a quoted sequence, represent a 'real' single quote.
|
34 |
+
* (see the last example)
|
35 |
+
*
|
36 |
+
* Format of the string is based on Unicode Technical Standard #35:
|
37 |
+
* https://www.unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table
|
38 |
+
* with a few additions (see note 7 below the table).
|
39 |
+
*
|
40 |
+
* Accepted patterns:
|
41 |
+
* | Unit | Pattern | Result examples | Notes |
|
42 |
+
* |---------------------------------|---------|-----------------------------------|-------|
|
43 |
+
* | Era | G..GGG | AD, BC | |
|
44 |
+
* | | GGGG | Anno Domini, Before Christ | 2 |
|
45 |
+
* | | GGGGG | A, B | |
|
46 |
+
* | Calendar year | y | 44, 1, 1900, 2017 | 5 |
|
47 |
+
* | | yo | 44th, 1st, 0th, 17th | 5,7 |
|
48 |
+
* | | yy | 44, 01, 00, 17 | 5 |
|
49 |
+
* | | yyy | 044, 001, 1900, 2017 | 5 |
|
50 |
+
* | | yyyy | 0044, 0001, 1900, 2017 | 5 |
|
51 |
+
* | | yyyyy | ... | 3,5 |
|
52 |
+
* | Local week-numbering year | Y | 44, 1, 1900, 2017 | 5 |
|
53 |
+
* | | Yo | 44th, 1st, 1900th, 2017th | 5,7 |
|
54 |
+
* | | YY | 44, 01, 00, 17 | 5,8 |
|
55 |
+
* | | YYY | 044, 001, 1900, 2017 | 5 |
|
56 |
+
* | | YYYY | 0044, 0001, 1900, 2017 | 5,8 |
|
57 |
+
* | | YYYYY | ... | 3,5 |
|
58 |
+
* | ISO week-numbering year | R | -43, 0, 1, 1900, 2017 | 5,7 |
|
59 |
+
* | | RR | -43, 00, 01, 1900, 2017 | 5,7 |
|
60 |
+
* | | RRR | -043, 000, 001, 1900, 2017 | 5,7 |
|
61 |
+
* | | RRRR | -0043, 0000, 0001, 1900, 2017 | 5,7 |
|
62 |
+
* | | RRRRR | ... | 3,5,7 |
|
63 |
+
* | Extended year | u | -43, 0, 1, 1900, 2017 | 5 |
|
64 |
+
* | | uu | -43, 01, 1900, 2017 | 5 |
|
65 |
+
* | | uuu | -043, 001, 1900, 2017 | 5 |
|
66 |
+
* | | uuuu | -0043, 0001, 1900, 2017 | 5 |
|
67 |
+
* | | uuuuu | ... | 3,5 |
|
68 |
+
* | Quarter (formatting) | Q | 1, 2, 3, 4 | |
|
69 |
+
* | | Qo | 1st, 2nd, 3rd, 4th | 7 |
|
70 |
+
* | | QQ | 01, 02, 03, 04 | |
|
71 |
+
* | | QQQ | Q1, Q2, Q3, Q4 | |
|
72 |
+
* | | QQQQ | 1st quarter, 2nd quarter, ... | 2 |
|
73 |
+
* | | QQQQQ | 1, 2, 3, 4 | 4 |
|
74 |
+
* | Quarter (stand-alone) | q | 1, 2, 3, 4 | |
|
75 |
+
* | | qo | 1st, 2nd, 3rd, 4th | 7 |
|
76 |
+
* | | qq | 01, 02, 03, 04 | |
|
77 |
+
* | | qqq | Q1, Q2, Q3, Q4 | |
|
78 |
+
* | | qqqq | 1st quarter, 2nd quarter, ... | 2 |
|
79 |
+
* | | qqqqq | 1, 2, 3, 4 | 4 |
|
80 |
+
* | Month (formatting) | M | 1, 2, ..., 12 | |
|
81 |
+
* | | Mo | 1st, 2nd, ..., 12th | 7 |
|
82 |
+
* | | MM | 01, 02, ..., 12 | |
|
83 |
+
* | | MMM | Jan, Feb, ..., Dec | |
|
84 |
+
* | | MMMM | January, February, ..., December | 2 |
|
85 |
+
* | | MMMMM | J, F, ..., D | |
|
86 |
+
* | Month (stand-alone) | L | 1, 2, ..., 12 | |
|
87 |
+
* | | Lo | 1st, 2nd, ..., 12th | 7 |
|
88 |
+
* | | LL | 01, 02, ..., 12 | |
|
89 |
+
* | | LLL | Jan, Feb, ..., Dec | |
|
90 |
+
* | | LLLL | January, February, ..., December | 2 |
|
91 |
+
* | | LLLLL | J, F, ..., D | |
|
92 |
+
* | Local week of year | w | 1, 2, ..., 53 | |
|
93 |
+
* | | wo | 1st, 2nd, ..., 53th | 7 |
|
94 |
+
* | | ww | 01, 02, ..., 53 | |
|
95 |
+
* | ISO week of year | I | 1, 2, ..., 53 | 7 |
|
96 |
+
* | | Io | 1st, 2nd, ..., 53th | 7 |
|
97 |
+
* | | II | 01, 02, ..., 53 | 7 |
|
98 |
+
* | Day of month | d | 1, 2, ..., 31 | |
|
99 |
+
* | | do | 1st, 2nd, ..., 31st | 7 |
|
100 |
+
* | | dd | 01, 02, ..., 31 | |
|
101 |
+
* | Day of year | D | 1, 2, ..., 365, 366 | 9 |
|
102 |
+
* | | Do | 1st, 2nd, ..., 365th, 366th | 7 |
|
103 |
+
* | | DD | 01, 02, ..., 365, 366 | 9 |
|
104 |
+
* | | DDD | 001, 002, ..., 365, 366 | |
|
105 |
+
* | | DDDD | ... | 3 |
|
106 |
+
* | Day of week (formatting) | E..EEE | Mon, Tue, Wed, ..., Sun | |
|
107 |
+
* | | EEEE | Monday, Tuesday, ..., Sunday | 2 |
|
108 |
+
* | | EEEEE | M, T, W, T, F, S, S | |
|
109 |
+
* | | EEEEEE | Mo, Tu, We, Th, Fr, Sa, Su | |
|
110 |
+
* | ISO day of week (formatting) | i | 1, 2, 3, ..., 7 | 7 |
|
111 |
+
* | | io | 1st, 2nd, ..., 7th | 7 |
|
112 |
+
* | | ii | 01, 02, ..., 07 | 7 |
|
113 |
+
* | | iii | Mon, Tue, Wed, ..., Sun | 7 |
|
114 |
+
* | | iiii | Monday, Tuesday, ..., Sunday | 2,7 |
|
115 |
+
* | | iiiii | M, T, W, T, F, S, S | 7 |
|
116 |
+
* | | iiiiii | Mo, Tu, We, Th, Fr, Sa, Su | 7 |
|
117 |
+
* | Local day of week (formatting) | e | 2, 3, 4, ..., 1 | |
|
118 |
+
* | | eo | 2nd, 3rd, ..., 1st | 7 |
|
119 |
+
* | | ee | 02, 03, ..., 01 | |
|
120 |
+
* | | eee | Mon, Tue, Wed, ..., Sun | |
|
121 |
+
* | | eeee | Monday, Tuesday, ..., Sunday | 2 |
|
122 |
+
* | | eeeee | M, T, W, T, F, S, S | |
|
123 |
+
* | | eeeeee | Mo, Tu, We, Th, Fr, Sa, Su | |
|
124 |
+
* | Local day of week (stand-alone) | c | 2, 3, 4, ..., 1 | |
|
125 |
+
* | | co | 2nd, 3rd, ..., 1st | 7 |
|
126 |
+
* | | cc | 02, 03, ..., 01 | |
|
127 |
+
* | | ccc | Mon, Tue, Wed, ..., Sun | |
|
128 |
+
* | | cccc | Monday, Tuesday, ..., Sunday | 2 |
|
129 |
+
* | | ccccc | M, T, W, T, F, S, S | |
|
130 |
+
* | | cccccc | Mo, Tu, We, Th, Fr, Sa, Su | |
|
131 |
+
* | AM, PM | a..aa | AM, PM | |
|
132 |
+
* | | aaa | am, pm | |
|
133 |
+
* | | aaaa | a.m., p.m. | 2 |
|
134 |
+
* | | aaaaa | a, p | |
|
135 |
+
* | AM, PM, noon, midnight | b..bb | AM, PM, noon, midnight | |
|
136 |
+
* | | bbb | am, pm, noon, midnight | |
|
137 |
+
* | | bbbb | a.m., p.m., noon, midnight | 2 |
|
138 |
+
* | | bbbbb | a, p, n, mi | |
|
139 |
+
* | Flexible day period | B..BBB | at night, in the morning, ... | |
|
140 |
+
* | | BBBB | at night, in the morning, ... | 2 |
|
141 |
+
* | | BBBBB | at night, in the morning, ... | |
|
142 |
+
* | Hour [1-12] | h | 1, 2, ..., 11, 12 | |
|
143 |
+
* | | ho | 1st, 2nd, ..., 11th, 12th | 7 |
|
144 |
+
* | | hh | 01, 02, ..., 11, 12 | |
|
145 |
+
* | Hour [0-23] | H | 0, 1, 2, ..., 23 | |
|
146 |
+
* | | Ho | 0th, 1st, 2nd, ..., 23rd | 7 |
|
147 |
+
* | | HH | 00, 01, 02, ..., 23 | |
|
148 |
+
* | Hour [0-11] | K | 1, 2, ..., 11, 0 | |
|
149 |
+
* | | Ko | 1st, 2nd, ..., 11th, 0th | 7 |
|
150 |
+
* | | KK | 01, 02, ..., 11, 00 | |
|
151 |
+
* | Hour [1-24] | k | 24, 1, 2, ..., 23 | |
|
152 |
+
* | | ko | 24th, 1st, 2nd, ..., 23rd | 7 |
|
153 |
+
* | | kk | 24, 01, 02, ..., 23 | |
|
154 |
+
* | Minute | m | 0, 1, ..., 59 | |
|
155 |
+
* | | mo | 0th, 1st, ..., 59th | 7 |
|
156 |
+
* | | mm | 00, 01, ..., 59 | |
|
157 |
+
* | Second | s | 0, 1, ..., 59 | |
|
158 |
+
* | | so | 0th, 1st, ..., 59th | 7 |
|
159 |
+
* | | ss | 00, 01, ..., 59 | |
|
160 |
+
* | Fraction of second | S | 0, 1, ..., 9 | |
|
161 |
+
* | | SS | 00, 01, ..., 99 | |
|
162 |
+
* | | SSS | 000, 001, ..., 999 | |
|
163 |
+
* | | SSSS | ... | 3 |
|
164 |
+
* | Timezone (ISO-8601 w/ Z) | X | -08, +0530, Z | |
|
165 |
+
* | | XX | -0800, +0530, Z | |
|
166 |
+
* | | XXX | -08:00, +05:30, Z | |
|
167 |
+
* | | XXXX | -0800, +0530, Z, +123456 | 2 |
|
168 |
+
* | | XXXXX | -08:00, +05:30, Z, +12:34:56 | |
|
169 |
+
* | Timezone (ISO-8601 w/o Z) | x | -08, +0530, +00 | |
|
170 |
+
* | | xx | -0800, +0530, +0000 | |
|
171 |
+
* | | xxx | -08:00, +05:30, +00:00 | 2 |
|
172 |
+
* | | xxxx | -0800, +0530, +0000, +123456 | |
|
173 |
+
* | | xxxxx | -08:00, +05:30, +00:00, +12:34:56 | |
|
174 |
+
* | Timezone (GMT) | O...OOO | GMT-8, GMT+5:30, GMT+0 | |
|
175 |
+
* | | OOOO | GMT-08:00, GMT+05:30, GMT+00:00 | 2 |
|
176 |
+
* | Timezone (specific non-locat.) | z...zzz | GMT-8, GMT+5:30, GMT+0 | 6 |
|
177 |
+
* | | zzzz | GMT-08:00, GMT+05:30, GMT+00:00 | 2,6 |
|
178 |
+
* | Seconds timestamp | t | 512969520 | 7 |
|
179 |
+
* | | tt | ... | 3,7 |
|
180 |
+
* | Milliseconds timestamp | T | 512969520900 | 7 |
|
181 |
+
* | | TT | ... | 3,7 |
|
182 |
+
* | Long localized date | P | 04/29/1453 | 7 |
|
183 |
+
* | | PP | Apr 29, 1453 | 7 |
|
184 |
+
* | | PPP | April 29th, 1453 | 7 |
|
185 |
+
* | | PPPP | Friday, April 29th, 1453 | 2,7 |
|
186 |
+
* | Long localized time | p | 12:00 AM | 7 |
|
187 |
+
* | | pp | 12:00:00 AM | 7 |
|
188 |
+
* | | ppp | 12:00:00 AM GMT+2 | 7 |
|
189 |
+
* | | pppp | 12:00:00 AM GMT+02:00 | 2,7 |
|
190 |
+
* | Combination of date and time | Pp | 04/29/1453, 12:00 AM | 7 |
|
191 |
+
* | | PPpp | Apr 29, 1453, 12:00:00 AM | 7 |
|
192 |
+
* | | PPPppp | April 29th, 1453 at ... | 7 |
|
193 |
+
* | | PPPPpppp| Friday, April 29th, 1453 at ... | 2,7 |
|
194 |
+
* Notes:
|
195 |
+
* 1. "Formatting" units (e.g. formatting quarter) in the default en-US locale
|
196 |
+
* are the same as "stand-alone" units, but are different in some languages.
|
197 |
+
* "Formatting" units are declined according to the rules of the language
|
198 |
+
* in the context of a date. "Stand-alone" units are always nominative singular:
|
199 |
+
*
|
200 |
+
* `format(new Date(2017, 10, 6), 'do LLLL', {locale: cs}) //=> '6. listopad'`
|
201 |
+
*
|
202 |
+
* `format(new Date(2017, 10, 6), 'do MMMM', {locale: cs}) //=> '6. listopadu'`
|
203 |
+
*
|
204 |
+
* 2. Any sequence of the identical letters is a pattern, unless it is escaped by
|
205 |
+
* the single quote characters (see below).
|
206 |
+
* If the sequence is longer than listed in table (e.g. `EEEEEEEEEEE`)
|
207 |
+
* the output will be the same as default pattern for this unit, usually
|
208 |
+
* the longest one (in case of ISO weekdays, `EEEE`). Default patterns for units
|
209 |
+
* are marked with "2" in the last column of the table.
|
210 |
+
*
|
211 |
+
* `format(new Date(2017, 10, 6), 'MMM') //=> 'Nov'`
|
212 |
+
*
|
213 |
+
* `format(new Date(2017, 10, 6), 'MMMM') //=> 'November'`
|
214 |
+
*
|
215 |
+
* `format(new Date(2017, 10, 6), 'MMMMM') //=> 'N'`
|
216 |
+
*
|
217 |
+
* `format(new Date(2017, 10, 6), 'MMMMMM') //=> 'November'`
|
218 |
+
*
|
219 |
+
* `format(new Date(2017, 10, 6), 'MMMMMMM') //=> 'November'`
|
220 |
+
*
|
221 |
+
* 3. Some patterns could be unlimited length (such as `yyyyyyyy`).
|
222 |
+
* The output will be padded with zeros to match the length of the pattern.
|
223 |
+
*
|
224 |
+
* `format(new Date(2017, 10, 6), 'yyyyyyyy') //=> '00002017'`
|
225 |
+
*
|
226 |
+
* 4. `QQQQQ` and `qqqqq` could be not strictly numerical in some locales.
|
227 |
+
* These tokens represent the shortest form of the quarter.
|
228 |
+
*
|
229 |
+
* 5. The main difference between `y` and `u` patterns are B.C. years:
|
230 |
+
*
|
231 |
+
* | Year | `y` | `u` |
|
232 |
+
* |------|-----|-----|
|
233 |
+
* | AC 1 | 1 | 1 |
|
234 |
+
* | BC 1 | 1 | 0 |
|
235 |
+
* | BC 2 | 2 | -1 |
|
236 |
+
*
|
237 |
+
* Also `yy` always returns the last two digits of a year,
|
238 |
+
* while `uu` pads single digit years to 2 characters and returns other years unchanged:
|
239 |
+
*
|
240 |
+
* | Year | `yy` | `uu` |
|
241 |
+
* |------|------|------|
|
242 |
+
* | 1 | 01 | 01 |
|
243 |
+
* | 14 | 14 | 14 |
|
244 |
+
* | 376 | 76 | 376 |
|
245 |
+
* | 1453 | 53 | 1453 |
|
246 |
+
*
|
247 |
+
* The same difference is true for local and ISO week-numbering years (`Y` and `R`),
|
248 |
+
* except local week-numbering years are dependent on `options.weekStartsOn`
|
249 |
+
* and `options.firstWeekContainsDate` (compare [getISOWeekYear](https://date-fns.org/docs/getISOWeekYear)
|
250 |
+
* and [getWeekYear](https://date-fns.org/docs/getWeekYear)).
|
251 |
+
*
|
252 |
+
* 6. Specific non-location timezones are currently unavailable in `date-fns`,
|
253 |
+
* so right now these tokens fall back to GMT timezones.
|
254 |
+
*
|
255 |
+
* 7. These patterns are not in the Unicode Technical Standard #35:
|
256 |
+
* - `i`: ISO day of week
|
257 |
+
* - `I`: ISO week of year
|
258 |
+
* - `R`: ISO week-numbering year
|
259 |
+
* - `t`: seconds timestamp
|
260 |
+
* - `T`: milliseconds timestamp
|
261 |
+
* - `o`: ordinal number modifier
|
262 |
+
* - `P`: long localized date
|
263 |
+
* - `p`: long localized time
|
264 |
+
*
|
265 |
+
* 8. `YY` and `YYYY` tokens represent week-numbering years but they are often confused with years.
|
266 |
+
* You should enable `options.useAdditionalWeekYearTokens` to use them. See: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
|
267 |
+
*
|
268 |
+
* 9. `D` and `DD` tokens represent days of the year but they are often confused with days of the month.
|
269 |
+
* You should enable `options.useAdditionalDayOfYearTokens` to use them. See: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
|
270 |
+
*
|
271 |
+
* @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
|
272 |
+
*
|
273 |
+
* @param date - The original date
|
274 |
+
* @param format - The string of tokens
|
275 |
+
* @param options - An object with options
|
276 |
+
*
|
277 |
+
* @returns The formatted date string
|
278 |
+
*
|
279 |
+
* @throws `date` must not be Invalid Date
|
280 |
+
* @throws `options.locale` must contain `localize` property
|
281 |
+
* @throws `options.locale` must contain `formatLong` property
|
282 |
+
* @throws use `yyyy` instead of `YYYY` for formatting years using [format provided] to the input [input provided]; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
|
283 |
+
* @throws use `yy` instead of `YY` for formatting years using [format provided] to the input [input provided]; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
|
284 |
+
* @throws use `d` instead of `D` for formatting days of the month using [format provided] to the input [input provided]; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
|
285 |
+
* @throws use `dd` instead of `DD` for formatting days of the month using [format provided] to the input [input provided]; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
|
286 |
+
* @throws format string contains an unescaped latin alphabet character
|
287 |
+
*
|
288 |
+
* @example
|
289 |
+
* // Represent 11 February 2014 in middle-endian format:
|
290 |
+
* const result = format(new Date(2014, 1, 11), 'MM/dd/yyyy')
|
291 |
+
* //=> '02/11/2014'
|
292 |
+
*
|
293 |
+
* @example
|
294 |
+
* // Represent 2 July 2014 in Esperanto:
|
295 |
+
* import { eoLocale } from 'date-fns/locale/eo'
|
296 |
+
* const result = format(new Date(2014, 6, 2), "do 'de' MMMM yyyy", {
|
297 |
+
* locale: eoLocale
|
298 |
+
* })
|
299 |
+
* //=> '2-a de julio 2014'
|
300 |
+
*
|
301 |
+
* @example
|
302 |
+
* // Escape string by single quote characters:
|
303 |
+
* const result = format(new Date(2014, 6, 2, 15), "h 'o''clock'")
|
304 |
+
* //=> "3 o'clock"
|
305 |
+
*/
|
306 |
+
export declare function format<DateType extends Date>(
|
307 |
+
date: DateType | number | string,
|
308 |
+
formatStr: string,
|
309 |
+
options?: FormatOptions,
|
310 |
+
): string;
|
workers1/auto3d/node_modules/date-fns/format.js
ADDED
@@ -0,0 +1,442 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"use strict";
|
2 |
+
exports.format = exports.formatDate = format;
|
3 |
+
Object.defineProperty(exports, "formatters", {
|
4 |
+
enumerable: true,
|
5 |
+
get: function () {
|
6 |
+
return _index3.formatters;
|
7 |
+
},
|
8 |
+
});
|
9 |
+
Object.defineProperty(exports, "longFormatters", {
|
10 |
+
enumerable: true,
|
11 |
+
get: function () {
|
12 |
+
return _index4.longFormatters;
|
13 |
+
},
|
14 |
+
});
|
15 |
+
var _index = require("./_lib/defaultLocale.js");
|
16 |
+
var _index2 = require("./_lib/defaultOptions.js");
|
17 |
+
var _index3 = require("./_lib/format/formatters.js");
|
18 |
+
var _index4 = require("./_lib/format/longFormatters.js");
|
19 |
+
var _index5 = require("./_lib/protectedTokens.js");
|
20 |
+
|
21 |
+
var _index6 = require("./isValid.js");
|
22 |
+
var _index7 = require("./toDate.js");
|
23 |
+
|
24 |
+
// Rexports of internal for libraries to use.
|
25 |
+
// See: https://github.com/date-fns/date-fns/issues/3638#issuecomment-1877082874
|
26 |
+
|
27 |
+
// This RegExp consists of three parts separated by `|`:
|
28 |
+
// - [yYQqMLwIdDecihHKkms]o matches any available ordinal number token
|
29 |
+
// (one of the certain letters followed by `o`)
|
30 |
+
// - (\w)\1* matches any sequences of the same letter
|
31 |
+
// - '' matches two quote characters in a row
|
32 |
+
// - '(''|[^'])+('|$) matches anything surrounded by two quote characters ('),
|
33 |
+
// except a single quote symbol, which ends the sequence.
|
34 |
+
// Two quote characters do not end the sequence.
|
35 |
+
// If there is no matching single quote
|
36 |
+
// then the sequence will continue until the end of the string.
|
37 |
+
// - . matches any single character unmatched by previous parts of the RegExps
|
38 |
+
const formattingTokensRegExp =
|
39 |
+
/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g;
|
40 |
+
|
41 |
+
// This RegExp catches symbols escaped by quotes, and also
|
42 |
+
// sequences of symbols P, p, and the combinations like `PPPPPPPppppp`
|
43 |
+
const longFormattingTokensRegExp = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g;
|
44 |
+
|
45 |
+
const escapedStringRegExp = /^'([^]*?)'?$/;
|
46 |
+
const doubleQuoteRegExp = /''/g;
|
47 |
+
const unescapedLatinCharacterRegExp = /[a-zA-Z]/;
|
48 |
+
|
49 |
+
/**
|
50 |
+
* The {@link format} function options.
|
51 |
+
*/
|
52 |
+
|
53 |
+
/**
|
54 |
+
* @name format
|
55 |
+
* @alias formatDate
|
56 |
+
* @category Common Helpers
|
57 |
+
* @summary Format the date.
|
58 |
+
*
|
59 |
+
* @description
|
60 |
+
* Return the formatted date string in the given format. The result may vary by locale.
|
61 |
+
*
|
62 |
+
* > ⚠️ Please note that the `format` tokens differ from Moment.js and other libraries.
|
63 |
+
* > See: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
|
64 |
+
*
|
65 |
+
* The characters wrapped between two single quotes characters (') are escaped.
|
66 |
+
* Two single quotes in a row, whether inside or outside a quoted sequence, represent a 'real' single quote.
|
67 |
+
* (see the last example)
|
68 |
+
*
|
69 |
+
* Format of the string is based on Unicode Technical Standard #35:
|
70 |
+
* https://www.unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table
|
71 |
+
* with a few additions (see note 7 below the table).
|
72 |
+
*
|
73 |
+
* Accepted patterns:
|
74 |
+
* | Unit | Pattern | Result examples | Notes |
|
75 |
+
* |---------------------------------|---------|-----------------------------------|-------|
|
76 |
+
* | Era | G..GGG | AD, BC | |
|
77 |
+
* | | GGGG | Anno Domini, Before Christ | 2 |
|
78 |
+
* | | GGGGG | A, B | |
|
79 |
+
* | Calendar year | y | 44, 1, 1900, 2017 | 5 |
|
80 |
+
* | | yo | 44th, 1st, 0th, 17th | 5,7 |
|
81 |
+
* | | yy | 44, 01, 00, 17 | 5 |
|
82 |
+
* | | yyy | 044, 001, 1900, 2017 | 5 |
|
83 |
+
* | | yyyy | 0044, 0001, 1900, 2017 | 5 |
|
84 |
+
* | | yyyyy | ... | 3,5 |
|
85 |
+
* | Local week-numbering year | Y | 44, 1, 1900, 2017 | 5 |
|
86 |
+
* | | Yo | 44th, 1st, 1900th, 2017th | 5,7 |
|
87 |
+
* | | YY | 44, 01, 00, 17 | 5,8 |
|
88 |
+
* | | YYY | 044, 001, 1900, 2017 | 5 |
|
89 |
+
* | | YYYY | 0044, 0001, 1900, 2017 | 5,8 |
|
90 |
+
* | | YYYYY | ... | 3,5 |
|
91 |
+
* | ISO week-numbering year | R | -43, 0, 1, 1900, 2017 | 5,7 |
|
92 |
+
* | | RR | -43, 00, 01, 1900, 2017 | 5,7 |
|
93 |
+
* | | RRR | -043, 000, 001, 1900, 2017 | 5,7 |
|
94 |
+
* | | RRRR | -0043, 0000, 0001, 1900, 2017 | 5,7 |
|
95 |
+
* | | RRRRR | ... | 3,5,7 |
|
96 |
+
* | Extended year | u | -43, 0, 1, 1900, 2017 | 5 |
|
97 |
+
* | | uu | -43, 01, 1900, 2017 | 5 |
|
98 |
+
* | | uuu | -043, 001, 1900, 2017 | 5 |
|
99 |
+
* | | uuuu | -0043, 0001, 1900, 2017 | 5 |
|
100 |
+
* | | uuuuu | ... | 3,5 |
|
101 |
+
* | Quarter (formatting) | Q | 1, 2, 3, 4 | |
|
102 |
+
* | | Qo | 1st, 2nd, 3rd, 4th | 7 |
|
103 |
+
* | | QQ | 01, 02, 03, 04 | |
|
104 |
+
* | | QQQ | Q1, Q2, Q3, Q4 | |
|
105 |
+
* | | QQQQ | 1st quarter, 2nd quarter, ... | 2 |
|
106 |
+
* | | QQQQQ | 1, 2, 3, 4 | 4 |
|
107 |
+
* | Quarter (stand-alone) | q | 1, 2, 3, 4 | |
|
108 |
+
* | | qo | 1st, 2nd, 3rd, 4th | 7 |
|
109 |
+
* | | qq | 01, 02, 03, 04 | |
|
110 |
+
* | | qqq | Q1, Q2, Q3, Q4 | |
|
111 |
+
* | | qqqq | 1st quarter, 2nd quarter, ... | 2 |
|
112 |
+
* | | qqqqq | 1, 2, 3, 4 | 4 |
|
113 |
+
* | Month (formatting) | M | 1, 2, ..., 12 | |
|
114 |
+
* | | Mo | 1st, 2nd, ..., 12th | 7 |
|
115 |
+
* | | MM | 01, 02, ..., 12 | |
|
116 |
+
* | | MMM | Jan, Feb, ..., Dec | |
|
117 |
+
* | | MMMM | January, February, ..., December | 2 |
|
118 |
+
* | | MMMMM | J, F, ..., D | |
|
119 |
+
* | Month (stand-alone) | L | 1, 2, ..., 12 | |
|
120 |
+
* | | Lo | 1st, 2nd, ..., 12th | 7 |
|
121 |
+
* | | LL | 01, 02, ..., 12 | |
|
122 |
+
* | | LLL | Jan, Feb, ..., Dec | |
|
123 |
+
* | | LLLL | January, February, ..., December | 2 |
|
124 |
+
* | | LLLLL | J, F, ..., D | |
|
125 |
+
* | Local week of year | w | 1, 2, ..., 53 | |
|
126 |
+
* | | wo | 1st, 2nd, ..., 53th | 7 |
|
127 |
+
* | | ww | 01, 02, ..., 53 | |
|
128 |
+
* | ISO week of year | I | 1, 2, ..., 53 | 7 |
|
129 |
+
* | | Io | 1st, 2nd, ..., 53th | 7 |
|
130 |
+
* | | II | 01, 02, ..., 53 | 7 |
|
131 |
+
* | Day of month | d | 1, 2, ..., 31 | |
|
132 |
+
* | | do | 1st, 2nd, ..., 31st | 7 |
|
133 |
+
* | | dd | 01, 02, ..., 31 | |
|
134 |
+
* | Day of year | D | 1, 2, ..., 365, 366 | 9 |
|
135 |
+
* | | Do | 1st, 2nd, ..., 365th, 366th | 7 |
|
136 |
+
* | | DD | 01, 02, ..., 365, 366 | 9 |
|
137 |
+
* | | DDD | 001, 002, ..., 365, 366 | |
|
138 |
+
* | | DDDD | ... | 3 |
|
139 |
+
* | Day of week (formatting) | E..EEE | Mon, Tue, Wed, ..., Sun | |
|
140 |
+
* | | EEEE | Monday, Tuesday, ..., Sunday | 2 |
|
141 |
+
* | | EEEEE | M, T, W, T, F, S, S | |
|
142 |
+
* | | EEEEEE | Mo, Tu, We, Th, Fr, Sa, Su | |
|
143 |
+
* | ISO day of week (formatting) | i | 1, 2, 3, ..., 7 | 7 |
|
144 |
+
* | | io | 1st, 2nd, ..., 7th | 7 |
|
145 |
+
* | | ii | 01, 02, ..., 07 | 7 |
|
146 |
+
* | | iii | Mon, Tue, Wed, ..., Sun | 7 |
|
147 |
+
* | | iiii | Monday, Tuesday, ..., Sunday | 2,7 |
|
148 |
+
* | | iiiii | M, T, W, T, F, S, S | 7 |
|
149 |
+
* | | iiiiii | Mo, Tu, We, Th, Fr, Sa, Su | 7 |
|
150 |
+
* | Local day of week (formatting) | e | 2, 3, 4, ..., 1 | |
|
151 |
+
* | | eo | 2nd, 3rd, ..., 1st | 7 |
|
152 |
+
* | | ee | 02, 03, ..., 01 | |
|
153 |
+
* | | eee | Mon, Tue, Wed, ..., Sun | |
|
154 |
+
* | | eeee | Monday, Tuesday, ..., Sunday | 2 |
|
155 |
+
* | | eeeee | M, T, W, T, F, S, S | |
|
156 |
+
* | | eeeeee | Mo, Tu, We, Th, Fr, Sa, Su | |
|
157 |
+
* | Local day of week (stand-alone) | c | 2, 3, 4, ..., 1 | |
|
158 |
+
* | | co | 2nd, 3rd, ..., 1st | 7 |
|
159 |
+
* | | cc | 02, 03, ..., 01 | |
|
160 |
+
* | | ccc | Mon, Tue, Wed, ..., Sun | |
|
161 |
+
* | | cccc | Monday, Tuesday, ..., Sunday | 2 |
|
162 |
+
* | | ccccc | M, T, W, T, F, S, S | |
|
163 |
+
* | | cccccc | Mo, Tu, We, Th, Fr, Sa, Su | |
|
164 |
+
* | AM, PM | a..aa | AM, PM | |
|
165 |
+
* | | aaa | am, pm | |
|
166 |
+
* | | aaaa | a.m., p.m. | 2 |
|
167 |
+
* | | aaaaa | a, p | |
|
168 |
+
* | AM, PM, noon, midnight | b..bb | AM, PM, noon, midnight | |
|
169 |
+
* | | bbb | am, pm, noon, midnight | |
|
170 |
+
* | | bbbb | a.m., p.m., noon, midnight | 2 |
|
171 |
+
* | | bbbbb | a, p, n, mi | |
|
172 |
+
* | Flexible day period | B..BBB | at night, in the morning, ... | |
|
173 |
+
* | | BBBB | at night, in the morning, ... | 2 |
|
174 |
+
* | | BBBBB | at night, in the morning, ... | |
|
175 |
+
* | Hour [1-12] | h | 1, 2, ..., 11, 12 | |
|
176 |
+
* | | ho | 1st, 2nd, ..., 11th, 12th | 7 |
|
177 |
+
* | | hh | 01, 02, ..., 11, 12 | |
|
178 |
+
* | Hour [0-23] | H | 0, 1, 2, ..., 23 | |
|
179 |
+
* | | Ho | 0th, 1st, 2nd, ..., 23rd | 7 |
|
180 |
+
* | | HH | 00, 01, 02, ..., 23 | |
|
181 |
+
* | Hour [0-11] | K | 1, 2, ..., 11, 0 | |
|
182 |
+
* | | Ko | 1st, 2nd, ..., 11th, 0th | 7 |
|
183 |
+
* | | KK | 01, 02, ..., 11, 00 | |
|
184 |
+
* | Hour [1-24] | k | 24, 1, 2, ..., 23 | |
|
185 |
+
* | | ko | 24th, 1st, 2nd, ..., 23rd | 7 |
|
186 |
+
* | | kk | 24, 01, 02, ..., 23 | |
|
187 |
+
* | Minute | m | 0, 1, ..., 59 | |
|
188 |
+
* | | mo | 0th, 1st, ..., 59th | 7 |
|
189 |
+
* | | mm | 00, 01, ..., 59 | |
|
190 |
+
* | Second | s | 0, 1, ..., 59 | |
|
191 |
+
* | | so | 0th, 1st, ..., 59th | 7 |
|
192 |
+
* | | ss | 00, 01, ..., 59 | |
|
193 |
+
* | Fraction of second | S | 0, 1, ..., 9 | |
|
194 |
+
* | | SS | 00, 01, ..., 99 | |
|
195 |
+
* | | SSS | 000, 001, ..., 999 | |
|
196 |
+
* | | SSSS | ... | 3 |
|
197 |
+
* | Timezone (ISO-8601 w/ Z) | X | -08, +0530, Z | |
|
198 |
+
* | | XX | -0800, +0530, Z | |
|
199 |
+
* | | XXX | -08:00, +05:30, Z | |
|
200 |
+
* | | XXXX | -0800, +0530, Z, +123456 | 2 |
|
201 |
+
* | | XXXXX | -08:00, +05:30, Z, +12:34:56 | |
|
202 |
+
* | Timezone (ISO-8601 w/o Z) | x | -08, +0530, +00 | |
|
203 |
+
* | | xx | -0800, +0530, +0000 | |
|
204 |
+
* | | xxx | -08:00, +05:30, +00:00 | 2 |
|
205 |
+
* | | xxxx | -0800, +0530, +0000, +123456 | |
|
206 |
+
* | | xxxxx | -08:00, +05:30, +00:00, +12:34:56 | |
|
207 |
+
* | Timezone (GMT) | O...OOO | GMT-8, GMT+5:30, GMT+0 | |
|
208 |
+
* | | OOOO | GMT-08:00, GMT+05:30, GMT+00:00 | 2 |
|
209 |
+
* | Timezone (specific non-locat.) | z...zzz | GMT-8, GMT+5:30, GMT+0 | 6 |
|
210 |
+
* | | zzzz | GMT-08:00, GMT+05:30, GMT+00:00 | 2,6 |
|
211 |
+
* | Seconds timestamp | t | 512969520 | 7 |
|
212 |
+
* | | tt | ... | 3,7 |
|
213 |
+
* | Milliseconds timestamp | T | 512969520900 | 7 |
|
214 |
+
* | | TT | ... | 3,7 |
|
215 |
+
* | Long localized date | P | 04/29/1453 | 7 |
|
216 |
+
* | | PP | Apr 29, 1453 | 7 |
|
217 |
+
* | | PPP | April 29th, 1453 | 7 |
|
218 |
+
* | | PPPP | Friday, April 29th, 1453 | 2,7 |
|
219 |
+
* | Long localized time | p | 12:00 AM | 7 |
|
220 |
+
* | | pp | 12:00:00 AM | 7 |
|
221 |
+
* | | ppp | 12:00:00 AM GMT+2 | 7 |
|
222 |
+
* | | pppp | 12:00:00 AM GMT+02:00 | 2,7 |
|
223 |
+
* | Combination of date and time | Pp | 04/29/1453, 12:00 AM | 7 |
|
224 |
+
* | | PPpp | Apr 29, 1453, 12:00:00 AM | 7 |
|
225 |
+
* | | PPPppp | April 29th, 1453 at ... | 7 |
|
226 |
+
* | | PPPPpppp| Friday, April 29th, 1453 at ... | 2,7 |
|
227 |
+
* Notes:
|
228 |
+
* 1. "Formatting" units (e.g. formatting quarter) in the default en-US locale
|
229 |
+
* are the same as "stand-alone" units, but are different in some languages.
|
230 |
+
* "Formatting" units are declined according to the rules of the language
|
231 |
+
* in the context of a date. "Stand-alone" units are always nominative singular:
|
232 |
+
*
|
233 |
+
* `format(new Date(2017, 10, 6), 'do LLLL', {locale: cs}) //=> '6. listopad'`
|
234 |
+
*
|
235 |
+
* `format(new Date(2017, 10, 6), 'do MMMM', {locale: cs}) //=> '6. listopadu'`
|
236 |
+
*
|
237 |
+
* 2. Any sequence of the identical letters is a pattern, unless it is escaped by
|
238 |
+
* the single quote characters (see below).
|
239 |
+
* If the sequence is longer than listed in table (e.g. `EEEEEEEEEEE`)
|
240 |
+
* the output will be the same as default pattern for this unit, usually
|
241 |
+
* the longest one (in case of ISO weekdays, `EEEE`). Default patterns for units
|
242 |
+
* are marked with "2" in the last column of the table.
|
243 |
+
*
|
244 |
+
* `format(new Date(2017, 10, 6), 'MMM') //=> 'Nov'`
|
245 |
+
*
|
246 |
+
* `format(new Date(2017, 10, 6), 'MMMM') //=> 'November'`
|
247 |
+
*
|
248 |
+
* `format(new Date(2017, 10, 6), 'MMMMM') //=> 'N'`
|
249 |
+
*
|
250 |
+
* `format(new Date(2017, 10, 6), 'MMMMMM') //=> 'November'`
|
251 |
+
*
|
252 |
+
* `format(new Date(2017, 10, 6), 'MMMMMMM') //=> 'November'`
|
253 |
+
*
|
254 |
+
* 3. Some patterns could be unlimited length (such as `yyyyyyyy`).
|
255 |
+
* The output will be padded with zeros to match the length of the pattern.
|
256 |
+
*
|
257 |
+
* `format(new Date(2017, 10, 6), 'yyyyyyyy') //=> '00002017'`
|
258 |
+
*
|
259 |
+
* 4. `QQQQQ` and `qqqqq` could be not strictly numerical in some locales.
|
260 |
+
* These tokens represent the shortest form of the quarter.
|
261 |
+
*
|
262 |
+
* 5. The main difference between `y` and `u` patterns are B.C. years:
|
263 |
+
*
|
264 |
+
* | Year | `y` | `u` |
|
265 |
+
* |------|-----|-----|
|
266 |
+
* | AC 1 | 1 | 1 |
|
267 |
+
* | BC 1 | 1 | 0 |
|
268 |
+
* | BC 2 | 2 | -1 |
|
269 |
+
*
|
270 |
+
* Also `yy` always returns the last two digits of a year,
|
271 |
+
* while `uu` pads single digit years to 2 characters and returns other years unchanged:
|
272 |
+
*
|
273 |
+
* | Year | `yy` | `uu` |
|
274 |
+
* |------|------|------|
|
275 |
+
* | 1 | 01 | 01 |
|
276 |
+
* | 14 | 14 | 14 |
|
277 |
+
* | 376 | 76 | 376 |
|
278 |
+
* | 1453 | 53 | 1453 |
|
279 |
+
*
|
280 |
+
* The same difference is true for local and ISO week-numbering years (`Y` and `R`),
|
281 |
+
* except local week-numbering years are dependent on `options.weekStartsOn`
|
282 |
+
* and `options.firstWeekContainsDate` (compare [getISOWeekYear](https://date-fns.org/docs/getISOWeekYear)
|
283 |
+
* and [getWeekYear](https://date-fns.org/docs/getWeekYear)).
|
284 |
+
*
|
285 |
+
* 6. Specific non-location timezones are currently unavailable in `date-fns`,
|
286 |
+
* so right now these tokens fall back to GMT timezones.
|
287 |
+
*
|
288 |
+
* 7. These patterns are not in the Unicode Technical Standard #35:
|
289 |
+
* - `i`: ISO day of week
|
290 |
+
* - `I`: ISO week of year
|
291 |
+
* - `R`: ISO week-numbering year
|
292 |
+
* - `t`: seconds timestamp
|
293 |
+
* - `T`: milliseconds timestamp
|
294 |
+
* - `o`: ordinal number modifier
|
295 |
+
* - `P`: long localized date
|
296 |
+
* - `p`: long localized time
|
297 |
+
*
|
298 |
+
* 8. `YY` and `YYYY` tokens represent week-numbering years but they are often confused with years.
|
299 |
+
* You should enable `options.useAdditionalWeekYearTokens` to use them. See: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
|
300 |
+
*
|
301 |
+
* 9. `D` and `DD` tokens represent days of the year but they are often confused with days of the month.
|
302 |
+
* You should enable `options.useAdditionalDayOfYearTokens` to use them. See: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
|
303 |
+
*
|
304 |
+
* @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
|
305 |
+
*
|
306 |
+
* @param date - The original date
|
307 |
+
* @param format - The string of tokens
|
308 |
+
* @param options - An object with options
|
309 |
+
*
|
310 |
+
* @returns The formatted date string
|
311 |
+
*
|
312 |
+
* @throws `date` must not be Invalid Date
|
313 |
+
* @throws `options.locale` must contain `localize` property
|
314 |
+
* @throws `options.locale` must contain `formatLong` property
|
315 |
+
* @throws use `yyyy` instead of `YYYY` for formatting years using [format provided] to the input [input provided]; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
|
316 |
+
* @throws use `yy` instead of `YY` for formatting years using [format provided] to the input [input provided]; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
|
317 |
+
* @throws use `d` instead of `D` for formatting days of the month using [format provided] to the input [input provided]; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
|
318 |
+
* @throws use `dd` instead of `DD` for formatting days of the month using [format provided] to the input [input provided]; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
|
319 |
+
* @throws format string contains an unescaped latin alphabet character
|
320 |
+
*
|
321 |
+
* @example
|
322 |
+
* // Represent 11 February 2014 in middle-endian format:
|
323 |
+
* const result = format(new Date(2014, 1, 11), 'MM/dd/yyyy')
|
324 |
+
* //=> '02/11/2014'
|
325 |
+
*
|
326 |
+
* @example
|
327 |
+
* // Represent 2 July 2014 in Esperanto:
|
328 |
+
* import { eoLocale } from 'date-fns/locale/eo'
|
329 |
+
* const result = format(new Date(2014, 6, 2), "do 'de' MMMM yyyy", {
|
330 |
+
* locale: eoLocale
|
331 |
+
* })
|
332 |
+
* //=> '2-a de julio 2014'
|
333 |
+
*
|
334 |
+
* @example
|
335 |
+
* // Escape string by single quote characters:
|
336 |
+
* const result = format(new Date(2014, 6, 2, 15), "h 'o''clock'")
|
337 |
+
* //=> "3 o'clock"
|
338 |
+
*/
|
339 |
+
function format(date, formatStr, options) {
|
340 |
+
const defaultOptions = (0, _index2.getDefaultOptions)();
|
341 |
+
const locale =
|
342 |
+
options?.locale ?? defaultOptions.locale ?? _index.defaultLocale;
|
343 |
+
|
344 |
+
const firstWeekContainsDate =
|
345 |
+
options?.firstWeekContainsDate ??
|
346 |
+
options?.locale?.options?.firstWeekContainsDate ??
|
347 |
+
defaultOptions.firstWeekContainsDate ??
|
348 |
+
defaultOptions.locale?.options?.firstWeekContainsDate ??
|
349 |
+
1;
|
350 |
+
|
351 |
+
const weekStartsOn =
|
352 |
+
options?.weekStartsOn ??
|
353 |
+
options?.locale?.options?.weekStartsOn ??
|
354 |
+
defaultOptions.weekStartsOn ??
|
355 |
+
defaultOptions.locale?.options?.weekStartsOn ??
|
356 |
+
0;
|
357 |
+
|
358 |
+
const originalDate = (0, _index7.toDate)(date);
|
359 |
+
|
360 |
+
if (!(0, _index6.isValid)(originalDate)) {
|
361 |
+
throw new RangeError("Invalid time value");
|
362 |
+
}
|
363 |
+
|
364 |
+
let parts = formatStr
|
365 |
+
.match(longFormattingTokensRegExp)
|
366 |
+
.map((substring) => {
|
367 |
+
const firstCharacter = substring[0];
|
368 |
+
if (firstCharacter === "p" || firstCharacter === "P") {
|
369 |
+
const longFormatter = _index4.longFormatters[firstCharacter];
|
370 |
+
return longFormatter(substring, locale.formatLong);
|
371 |
+
}
|
372 |
+
return substring;
|
373 |
+
})
|
374 |
+
.join("")
|
375 |
+
.match(formattingTokensRegExp)
|
376 |
+
.map((substring) => {
|
377 |
+
// Replace two single quote characters with one single quote character
|
378 |
+
if (substring === "''") {
|
379 |
+
return { isToken: false, value: "'" };
|
380 |
+
}
|
381 |
+
|
382 |
+
const firstCharacter = substring[0];
|
383 |
+
if (firstCharacter === "'") {
|
384 |
+
return { isToken: false, value: cleanEscapedString(substring) };
|
385 |
+
}
|
386 |
+
|
387 |
+
if (_index3.formatters[firstCharacter]) {
|
388 |
+
return { isToken: true, value: substring };
|
389 |
+
}
|
390 |
+
|
391 |
+
if (firstCharacter.match(unescapedLatinCharacterRegExp)) {
|
392 |
+
throw new RangeError(
|
393 |
+
"Format string contains an unescaped latin alphabet character `" +
|
394 |
+
firstCharacter +
|
395 |
+
"`",
|
396 |
+
);
|
397 |
+
}
|
398 |
+
|
399 |
+
return { isToken: false, value: substring };
|
400 |
+
});
|
401 |
+
|
402 |
+
// invoke localize preprocessor (only for french locales at the moment)
|
403 |
+
if (locale.localize.preprocessor) {
|
404 |
+
parts = locale.localize.preprocessor(originalDate, parts);
|
405 |
+
}
|
406 |
+
|
407 |
+
const formatterOptions = {
|
408 |
+
firstWeekContainsDate,
|
409 |
+
weekStartsOn,
|
410 |
+
locale,
|
411 |
+
};
|
412 |
+
|
413 |
+
return parts
|
414 |
+
.map((part) => {
|
415 |
+
if (!part.isToken) return part.value;
|
416 |
+
|
417 |
+
const token = part.value;
|
418 |
+
|
419 |
+
if (
|
420 |
+
(!options?.useAdditionalWeekYearTokens &&
|
421 |
+
(0, _index5.isProtectedWeekYearToken)(token)) ||
|
422 |
+
(!options?.useAdditionalDayOfYearTokens &&
|
423 |
+
(0, _index5.isProtectedDayOfYearToken)(token))
|
424 |
+
) {
|
425 |
+
(0, _index5.warnOrThrowProtectedError)(token, formatStr, String(date));
|
426 |
+
}
|
427 |
+
|
428 |
+
const formatter = _index3.formatters[token[0]];
|
429 |
+
return formatter(originalDate, token, locale.localize, formatterOptions);
|
430 |
+
})
|
431 |
+
.join("");
|
432 |
+
}
|
433 |
+
|
434 |
+
function cleanEscapedString(input) {
|
435 |
+
const matched = input.match(escapedStringRegExp);
|
436 |
+
|
437 |
+
if (!matched) {
|
438 |
+
return input;
|
439 |
+
}
|
440 |
+
|
441 |
+
return matched[1].replace(doubleQuoteRegExp, "'");
|
442 |
+
}
|
workers1/auto3d/node_modules/date-fns/format.mjs
ADDED
@@ -0,0 +1,436 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { defaultLocale } from "./_lib/defaultLocale.mjs";
|
2 |
+
import { getDefaultOptions } from "./_lib/defaultOptions.mjs";
|
3 |
+
import { formatters } from "./_lib/format/formatters.mjs";
|
4 |
+
import { longFormatters } from "./_lib/format/longFormatters.mjs";
|
5 |
+
import {
|
6 |
+
isProtectedDayOfYearToken,
|
7 |
+
isProtectedWeekYearToken,
|
8 |
+
warnOrThrowProtectedError,
|
9 |
+
} from "./_lib/protectedTokens.mjs";
|
10 |
+
import { isValid } from "./isValid.mjs";
|
11 |
+
import { toDate } from "./toDate.mjs";
|
12 |
+
|
13 |
+
// Rexports of internal for libraries to use.
|
14 |
+
// See: https://github.com/date-fns/date-fns/issues/3638#issuecomment-1877082874
|
15 |
+
export { formatters, longFormatters };
|
16 |
+
|
17 |
+
// This RegExp consists of three parts separated by `|`:
|
18 |
+
// - [yYQqMLwIdDecihHKkms]o matches any available ordinal number token
|
19 |
+
// (one of the certain letters followed by `o`)
|
20 |
+
// - (\w)\1* matches any sequences of the same letter
|
21 |
+
// - '' matches two quote characters in a row
|
22 |
+
// - '(''|[^'])+('|$) matches anything surrounded by two quote characters ('),
|
23 |
+
// except a single quote symbol, which ends the sequence.
|
24 |
+
// Two quote characters do not end the sequence.
|
25 |
+
// If there is no matching single quote
|
26 |
+
// then the sequence will continue until the end of the string.
|
27 |
+
// - . matches any single character unmatched by previous parts of the RegExps
|
28 |
+
const formattingTokensRegExp =
|
29 |
+
/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g;
|
30 |
+
|
31 |
+
// This RegExp catches symbols escaped by quotes, and also
|
32 |
+
// sequences of symbols P, p, and the combinations like `PPPPPPPppppp`
|
33 |
+
const longFormattingTokensRegExp = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g;
|
34 |
+
|
35 |
+
const escapedStringRegExp = /^'([^]*?)'?$/;
|
36 |
+
const doubleQuoteRegExp = /''/g;
|
37 |
+
const unescapedLatinCharacterRegExp = /[a-zA-Z]/;
|
38 |
+
|
39 |
+
export { format as formatDate };
|
40 |
+
|
41 |
+
/**
|
42 |
+
* The {@link format} function options.
|
43 |
+
*/
|
44 |
+
|
45 |
+
/**
|
46 |
+
* @name format
|
47 |
+
* @alias formatDate
|
48 |
+
* @category Common Helpers
|
49 |
+
* @summary Format the date.
|
50 |
+
*
|
51 |
+
* @description
|
52 |
+
* Return the formatted date string in the given format. The result may vary by locale.
|
53 |
+
*
|
54 |
+
* > ⚠️ Please note that the `format` tokens differ from Moment.js and other libraries.
|
55 |
+
* > See: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
|
56 |
+
*
|
57 |
+
* The characters wrapped between two single quotes characters (') are escaped.
|
58 |
+
* Two single quotes in a row, whether inside or outside a quoted sequence, represent a 'real' single quote.
|
59 |
+
* (see the last example)
|
60 |
+
*
|
61 |
+
* Format of the string is based on Unicode Technical Standard #35:
|
62 |
+
* https://www.unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table
|
63 |
+
* with a few additions (see note 7 below the table).
|
64 |
+
*
|
65 |
+
* Accepted patterns:
|
66 |
+
* | Unit | Pattern | Result examples | Notes |
|
67 |
+
* |---------------------------------|---------|-----------------------------------|-------|
|
68 |
+
* | Era | G..GGG | AD, BC | |
|
69 |
+
* | | GGGG | Anno Domini, Before Christ | 2 |
|
70 |
+
* | | GGGGG | A, B | |
|
71 |
+
* | Calendar year | y | 44, 1, 1900, 2017 | 5 |
|
72 |
+
* | | yo | 44th, 1st, 0th, 17th | 5,7 |
|
73 |
+
* | | yy | 44, 01, 00, 17 | 5 |
|
74 |
+
* | | yyy | 044, 001, 1900, 2017 | 5 |
|
75 |
+
* | | yyyy | 0044, 0001, 1900, 2017 | 5 |
|
76 |
+
* | | yyyyy | ... | 3,5 |
|
77 |
+
* | Local week-numbering year | Y | 44, 1, 1900, 2017 | 5 |
|
78 |
+
* | | Yo | 44th, 1st, 1900th, 2017th | 5,7 |
|
79 |
+
* | | YY | 44, 01, 00, 17 | 5,8 |
|
80 |
+
* | | YYY | 044, 001, 1900, 2017 | 5 |
|
81 |
+
* | | YYYY | 0044, 0001, 1900, 2017 | 5,8 |
|
82 |
+
* | | YYYYY | ... | 3,5 |
|
83 |
+
* | ISO week-numbering year | R | -43, 0, 1, 1900, 2017 | 5,7 |
|
84 |
+
* | | RR | -43, 00, 01, 1900, 2017 | 5,7 |
|
85 |
+
* | | RRR | -043, 000, 001, 1900, 2017 | 5,7 |
|
86 |
+
* | | RRRR | -0043, 0000, 0001, 1900, 2017 | 5,7 |
|
87 |
+
* | | RRRRR | ... | 3,5,7 |
|
88 |
+
* | Extended year | u | -43, 0, 1, 1900, 2017 | 5 |
|
89 |
+
* | | uu | -43, 01, 1900, 2017 | 5 |
|
90 |
+
* | | uuu | -043, 001, 1900, 2017 | 5 |
|
91 |
+
* | | uuuu | -0043, 0001, 1900, 2017 | 5 |
|
92 |
+
* | | uuuuu | ... | 3,5 |
|
93 |
+
* | Quarter (formatting) | Q | 1, 2, 3, 4 | |
|
94 |
+
* | | Qo | 1st, 2nd, 3rd, 4th | 7 |
|
95 |
+
* | | QQ | 01, 02, 03, 04 | |
|
96 |
+
* | | QQQ | Q1, Q2, Q3, Q4 | |
|
97 |
+
* | | QQQQ | 1st quarter, 2nd quarter, ... | 2 |
|
98 |
+
* | | QQQQQ | 1, 2, 3, 4 | 4 |
|
99 |
+
* | Quarter (stand-alone) | q | 1, 2, 3, 4 | |
|
100 |
+
* | | qo | 1st, 2nd, 3rd, 4th | 7 |
|
101 |
+
* | | qq | 01, 02, 03, 04 | |
|
102 |
+
* | | qqq | Q1, Q2, Q3, Q4 | |
|
103 |
+
* | | qqqq | 1st quarter, 2nd quarter, ... | 2 |
|
104 |
+
* | | qqqqq | 1, 2, 3, 4 | 4 |
|
105 |
+
* | Month (formatting) | M | 1, 2, ..., 12 | |
|
106 |
+
* | | Mo | 1st, 2nd, ..., 12th | 7 |
|
107 |
+
* | | MM | 01, 02, ..., 12 | |
|
108 |
+
* | | MMM | Jan, Feb, ..., Dec | |
|
109 |
+
* | | MMMM | January, February, ..., December | 2 |
|
110 |
+
* | | MMMMM | J, F, ..., D | |
|
111 |
+
* | Month (stand-alone) | L | 1, 2, ..., 12 | |
|
112 |
+
* | | Lo | 1st, 2nd, ..., 12th | 7 |
|
113 |
+
* | | LL | 01, 02, ..., 12 | |
|
114 |
+
* | | LLL | Jan, Feb, ..., Dec | |
|
115 |
+
* | | LLLL | January, February, ..., December | 2 |
|
116 |
+
* | | LLLLL | J, F, ..., D | |
|
117 |
+
* | Local week of year | w | 1, 2, ..., 53 | |
|
118 |
+
* | | wo | 1st, 2nd, ..., 53th | 7 |
|
119 |
+
* | | ww | 01, 02, ..., 53 | |
|
120 |
+
* | ISO week of year | I | 1, 2, ..., 53 | 7 |
|
121 |
+
* | | Io | 1st, 2nd, ..., 53th | 7 |
|
122 |
+
* | | II | 01, 02, ..., 53 | 7 |
|
123 |
+
* | Day of month | d | 1, 2, ..., 31 | |
|
124 |
+
* | | do | 1st, 2nd, ..., 31st | 7 |
|
125 |
+
* | | dd | 01, 02, ..., 31 | |
|
126 |
+
* | Day of year | D | 1, 2, ..., 365, 366 | 9 |
|
127 |
+
* | | Do | 1st, 2nd, ..., 365th, 366th | 7 |
|
128 |
+
* | | DD | 01, 02, ..., 365, 366 | 9 |
|
129 |
+
* | | DDD | 001, 002, ..., 365, 366 | |
|
130 |
+
* | | DDDD | ... | 3 |
|
131 |
+
* | Day of week (formatting) | E..EEE | Mon, Tue, Wed, ..., Sun | |
|
132 |
+
* | | EEEE | Monday, Tuesday, ..., Sunday | 2 |
|
133 |
+
* | | EEEEE | M, T, W, T, F, S, S | |
|
134 |
+
* | | EEEEEE | Mo, Tu, We, Th, Fr, Sa, Su | |
|
135 |
+
* | ISO day of week (formatting) | i | 1, 2, 3, ..., 7 | 7 |
|
136 |
+
* | | io | 1st, 2nd, ..., 7th | 7 |
|
137 |
+
* | | ii | 01, 02, ..., 07 | 7 |
|
138 |
+
* | | iii | Mon, Tue, Wed, ..., Sun | 7 |
|
139 |
+
* | | iiii | Monday, Tuesday, ..., Sunday | 2,7 |
|
140 |
+
* | | iiiii | M, T, W, T, F, S, S | 7 |
|
141 |
+
* | | iiiiii | Mo, Tu, We, Th, Fr, Sa, Su | 7 |
|
142 |
+
* | Local day of week (formatting) | e | 2, 3, 4, ..., 1 | |
|
143 |
+
* | | eo | 2nd, 3rd, ..., 1st | 7 |
|
144 |
+
* | | ee | 02, 03, ..., 01 | |
|
145 |
+
* | | eee | Mon, Tue, Wed, ..., Sun | |
|
146 |
+
* | | eeee | Monday, Tuesday, ..., Sunday | 2 |
|
147 |
+
* | | eeeee | M, T, W, T, F, S, S | |
|
148 |
+
* | | eeeeee | Mo, Tu, We, Th, Fr, Sa, Su | |
|
149 |
+
* | Local day of week (stand-alone) | c | 2, 3, 4, ..., 1 | |
|
150 |
+
* | | co | 2nd, 3rd, ..., 1st | 7 |
|
151 |
+
* | | cc | 02, 03, ..., 01 | |
|
152 |
+
* | | ccc | Mon, Tue, Wed, ..., Sun | |
|
153 |
+
* | | cccc | Monday, Tuesday, ..., Sunday | 2 |
|
154 |
+
* | | ccccc | M, T, W, T, F, S, S | |
|
155 |
+
* | | cccccc | Mo, Tu, We, Th, Fr, Sa, Su | |
|
156 |
+
* | AM, PM | a..aa | AM, PM | |
|
157 |
+
* | | aaa | am, pm | |
|
158 |
+
* | | aaaa | a.m., p.m. | 2 |
|
159 |
+
* | | aaaaa | a, p | |
|
160 |
+
* | AM, PM, noon, midnight | b..bb | AM, PM, noon, midnight | |
|
161 |
+
* | | bbb | am, pm, noon, midnight | |
|
162 |
+
* | | bbbb | a.m., p.m., noon, midnight | 2 |
|
163 |
+
* | | bbbbb | a, p, n, mi | |
|
164 |
+
* | Flexible day period | B..BBB | at night, in the morning, ... | |
|
165 |
+
* | | BBBB | at night, in the morning, ... | 2 |
|
166 |
+
* | | BBBBB | at night, in the morning, ... | |
|
167 |
+
* | Hour [1-12] | h | 1, 2, ..., 11, 12 | |
|
168 |
+
* | | ho | 1st, 2nd, ..., 11th, 12th | 7 |
|
169 |
+
* | | hh | 01, 02, ..., 11, 12 | |
|
170 |
+
* | Hour [0-23] | H | 0, 1, 2, ..., 23 | |
|
171 |
+
* | | Ho | 0th, 1st, 2nd, ..., 23rd | 7 |
|
172 |
+
* | | HH | 00, 01, 02, ..., 23 | |
|
173 |
+
* | Hour [0-11] | K | 1, 2, ..., 11, 0 | |
|
174 |
+
* | | Ko | 1st, 2nd, ..., 11th, 0th | 7 |
|
175 |
+
* | | KK | 01, 02, ..., 11, 00 | |
|
176 |
+
* | Hour [1-24] | k | 24, 1, 2, ..., 23 | |
|
177 |
+
* | | ko | 24th, 1st, 2nd, ..., 23rd | 7 |
|
178 |
+
* | | kk | 24, 01, 02, ..., 23 | |
|
179 |
+
* | Minute | m | 0, 1, ..., 59 | |
|
180 |
+
* | | mo | 0th, 1st, ..., 59th | 7 |
|
181 |
+
* | | mm | 00, 01, ..., 59 | |
|
182 |
+
* | Second | s | 0, 1, ..., 59 | |
|
183 |
+
* | | so | 0th, 1st, ..., 59th | 7 |
|
184 |
+
* | | ss | 00, 01, ..., 59 | |
|
185 |
+
* | Fraction of second | S | 0, 1, ..., 9 | |
|
186 |
+
* | | SS | 00, 01, ..., 99 | |
|
187 |
+
* | | SSS | 000, 001, ..., 999 | |
|
188 |
+
* | | SSSS | ... | 3 |
|
189 |
+
* | Timezone (ISO-8601 w/ Z) | X | -08, +0530, Z | |
|
190 |
+
* | | XX | -0800, +0530, Z | |
|
191 |
+
* | | XXX | -08:00, +05:30, Z | |
|
192 |
+
* | | XXXX | -0800, +0530, Z, +123456 | 2 |
|
193 |
+
* | | XXXXX | -08:00, +05:30, Z, +12:34:56 | |
|
194 |
+
* | Timezone (ISO-8601 w/o Z) | x | -08, +0530, +00 | |
|
195 |
+
* | | xx | -0800, +0530, +0000 | |
|
196 |
+
* | | xxx | -08:00, +05:30, +00:00 | 2 |
|
197 |
+
* | | xxxx | -0800, +0530, +0000, +123456 | |
|
198 |
+
* | | xxxxx | -08:00, +05:30, +00:00, +12:34:56 | |
|
199 |
+
* | Timezone (GMT) | O...OOO | GMT-8, GMT+5:30, GMT+0 | |
|
200 |
+
* | | OOOO | GMT-08:00, GMT+05:30, GMT+00:00 | 2 |
|
201 |
+
* | Timezone (specific non-locat.) | z...zzz | GMT-8, GMT+5:30, GMT+0 | 6 |
|
202 |
+
* | | zzzz | GMT-08:00, GMT+05:30, GMT+00:00 | 2,6 |
|
203 |
+
* | Seconds timestamp | t | 512969520 | 7 |
|
204 |
+
* | | tt | ... | 3,7 |
|
205 |
+
* | Milliseconds timestamp | T | 512969520900 | 7 |
|
206 |
+
* | | TT | ... | 3,7 |
|
207 |
+
* | Long localized date | P | 04/29/1453 | 7 |
|
208 |
+
* | | PP | Apr 29, 1453 | 7 |
|
209 |
+
* | | PPP | April 29th, 1453 | 7 |
|
210 |
+
* | | PPPP | Friday, April 29th, 1453 | 2,7 |
|
211 |
+
* | Long localized time | p | 12:00 AM | 7 |
|
212 |
+
* | | pp | 12:00:00 AM | 7 |
|
213 |
+
* | | ppp | 12:00:00 AM GMT+2 | 7 |
|
214 |
+
* | | pppp | 12:00:00 AM GMT+02:00 | 2,7 |
|
215 |
+
* | Combination of date and time | Pp | 04/29/1453, 12:00 AM | 7 |
|
216 |
+
* | | PPpp | Apr 29, 1453, 12:00:00 AM | 7 |
|
217 |
+
* | | PPPppp | April 29th, 1453 at ... | 7 |
|
218 |
+
* | | PPPPpppp| Friday, April 29th, 1453 at ... | 2,7 |
|
219 |
+
* Notes:
|
220 |
+
* 1. "Formatting" units (e.g. formatting quarter) in the default en-US locale
|
221 |
+
* are the same as "stand-alone" units, but are different in some languages.
|
222 |
+
* "Formatting" units are declined according to the rules of the language
|
223 |
+
* in the context of a date. "Stand-alone" units are always nominative singular:
|
224 |
+
*
|
225 |
+
* `format(new Date(2017, 10, 6), 'do LLLL', {locale: cs}) //=> '6. listopad'`
|
226 |
+
*
|
227 |
+
* `format(new Date(2017, 10, 6), 'do MMMM', {locale: cs}) //=> '6. listopadu'`
|
228 |
+
*
|
229 |
+
* 2. Any sequence of the identical letters is a pattern, unless it is escaped by
|
230 |
+
* the single quote characters (see below).
|
231 |
+
* If the sequence is longer than listed in table (e.g. `EEEEEEEEEEE`)
|
232 |
+
* the output will be the same as default pattern for this unit, usually
|
233 |
+
* the longest one (in case of ISO weekdays, `EEEE`). Default patterns for units
|
234 |
+
* are marked with "2" in the last column of the table.
|
235 |
+
*
|
236 |
+
* `format(new Date(2017, 10, 6), 'MMM') //=> 'Nov'`
|
237 |
+
*
|
238 |
+
* `format(new Date(2017, 10, 6), 'MMMM') //=> 'November'`
|
239 |
+
*
|
240 |
+
* `format(new Date(2017, 10, 6), 'MMMMM') //=> 'N'`
|
241 |
+
*
|
242 |
+
* `format(new Date(2017, 10, 6), 'MMMMMM') //=> 'November'`
|
243 |
+
*
|
244 |
+
* `format(new Date(2017, 10, 6), 'MMMMMMM') //=> 'November'`
|
245 |
+
*
|
246 |
+
* 3. Some patterns could be unlimited length (such as `yyyyyyyy`).
|
247 |
+
* The output will be padded with zeros to match the length of the pattern.
|
248 |
+
*
|
249 |
+
* `format(new Date(2017, 10, 6), 'yyyyyyyy') //=> '00002017'`
|
250 |
+
*
|
251 |
+
* 4. `QQQQQ` and `qqqqq` could be not strictly numerical in some locales.
|
252 |
+
* These tokens represent the shortest form of the quarter.
|
253 |
+
*
|
254 |
+
* 5. The main difference between `y` and `u` patterns are B.C. years:
|
255 |
+
*
|
256 |
+
* | Year | `y` | `u` |
|
257 |
+
* |------|-----|-----|
|
258 |
+
* | AC 1 | 1 | 1 |
|
259 |
+
* | BC 1 | 1 | 0 |
|
260 |
+
* | BC 2 | 2 | -1 |
|
261 |
+
*
|
262 |
+
* Also `yy` always returns the last two digits of a year,
|
263 |
+
* while `uu` pads single digit years to 2 characters and returns other years unchanged:
|
264 |
+
*
|
265 |
+
* | Year | `yy` | `uu` |
|
266 |
+
* |------|------|------|
|
267 |
+
* | 1 | 01 | 01 |
|
268 |
+
* | 14 | 14 | 14 |
|
269 |
+
* | 376 | 76 | 376 |
|
270 |
+
* | 1453 | 53 | 1453 |
|
271 |
+
*
|
272 |
+
* The same difference is true for local and ISO week-numbering years (`Y` and `R`),
|
273 |
+
* except local week-numbering years are dependent on `options.weekStartsOn`
|
274 |
+
* and `options.firstWeekContainsDate` (compare [getISOWeekYear](https://date-fns.org/docs/getISOWeekYear)
|
275 |
+
* and [getWeekYear](https://date-fns.org/docs/getWeekYear)).
|
276 |
+
*
|
277 |
+
* 6. Specific non-location timezones are currently unavailable in `date-fns`,
|
278 |
+
* so right now these tokens fall back to GMT timezones.
|
279 |
+
*
|
280 |
+
* 7. These patterns are not in the Unicode Technical Standard #35:
|
281 |
+
* - `i`: ISO day of week
|
282 |
+
* - `I`: ISO week of year
|
283 |
+
* - `R`: ISO week-numbering year
|
284 |
+
* - `t`: seconds timestamp
|
285 |
+
* - `T`: milliseconds timestamp
|
286 |
+
* - `o`: ordinal number modifier
|
287 |
+
* - `P`: long localized date
|
288 |
+
* - `p`: long localized time
|
289 |
+
*
|
290 |
+
* 8. `YY` and `YYYY` tokens represent week-numbering years but they are often confused with years.
|
291 |
+
* You should enable `options.useAdditionalWeekYearTokens` to use them. See: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
|
292 |
+
*
|
293 |
+
* 9. `D` and `DD` tokens represent days of the year but they are often confused with days of the month.
|
294 |
+
* You should enable `options.useAdditionalDayOfYearTokens` to use them. See: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
|
295 |
+
*
|
296 |
+
* @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
|
297 |
+
*
|
298 |
+
* @param date - The original date
|
299 |
+
* @param format - The string of tokens
|
300 |
+
* @param options - An object with options
|
301 |
+
*
|
302 |
+
* @returns The formatted date string
|
303 |
+
*
|
304 |
+
* @throws `date` must not be Invalid Date
|
305 |
+
* @throws `options.locale` must contain `localize` property
|
306 |
+
* @throws `options.locale` must contain `formatLong` property
|
307 |
+
* @throws use `yyyy` instead of `YYYY` for formatting years using [format provided] to the input [input provided]; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
|
308 |
+
* @throws use `yy` instead of `YY` for formatting years using [format provided] to the input [input provided]; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
|
309 |
+
* @throws use `d` instead of `D` for formatting days of the month using [format provided] to the input [input provided]; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
|
310 |
+
* @throws use `dd` instead of `DD` for formatting days of the month using [format provided] to the input [input provided]; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
|
311 |
+
* @throws format string contains an unescaped latin alphabet character
|
312 |
+
*
|
313 |
+
* @example
|
314 |
+
* // Represent 11 February 2014 in middle-endian format:
|
315 |
+
* const result = format(new Date(2014, 1, 11), 'MM/dd/yyyy')
|
316 |
+
* //=> '02/11/2014'
|
317 |
+
*
|
318 |
+
* @example
|
319 |
+
* // Represent 2 July 2014 in Esperanto:
|
320 |
+
* import { eoLocale } from 'date-fns/locale/eo'
|
321 |
+
* const result = format(new Date(2014, 6, 2), "do 'de' MMMM yyyy", {
|
322 |
+
* locale: eoLocale
|
323 |
+
* })
|
324 |
+
* //=> '2-a de julio 2014'
|
325 |
+
*
|
326 |
+
* @example
|
327 |
+
* // Escape string by single quote characters:
|
328 |
+
* const result = format(new Date(2014, 6, 2, 15), "h 'o''clock'")
|
329 |
+
* //=> "3 o'clock"
|
330 |
+
*/
|
331 |
+
export function format(date, formatStr, options) {
|
332 |
+
const defaultOptions = getDefaultOptions();
|
333 |
+
const locale = options?.locale ?? defaultOptions.locale ?? defaultLocale;
|
334 |
+
|
335 |
+
const firstWeekContainsDate =
|
336 |
+
options?.firstWeekContainsDate ??
|
337 |
+
options?.locale?.options?.firstWeekContainsDate ??
|
338 |
+
defaultOptions.firstWeekContainsDate ??
|
339 |
+
defaultOptions.locale?.options?.firstWeekContainsDate ??
|
340 |
+
1;
|
341 |
+
|
342 |
+
const weekStartsOn =
|
343 |
+
options?.weekStartsOn ??
|
344 |
+
options?.locale?.options?.weekStartsOn ??
|
345 |
+
defaultOptions.weekStartsOn ??
|
346 |
+
defaultOptions.locale?.options?.weekStartsOn ??
|
347 |
+
0;
|
348 |
+
|
349 |
+
const originalDate = toDate(date);
|
350 |
+
|
351 |
+
if (!isValid(originalDate)) {
|
352 |
+
throw new RangeError("Invalid time value");
|
353 |
+
}
|
354 |
+
|
355 |
+
let parts = formatStr
|
356 |
+
.match(longFormattingTokensRegExp)
|
357 |
+
.map((substring) => {
|
358 |
+
const firstCharacter = substring[0];
|
359 |
+
if (firstCharacter === "p" || firstCharacter === "P") {
|
360 |
+
const longFormatter = longFormatters[firstCharacter];
|
361 |
+
return longFormatter(substring, locale.formatLong);
|
362 |
+
}
|
363 |
+
return substring;
|
364 |
+
})
|
365 |
+
.join("")
|
366 |
+
.match(formattingTokensRegExp)
|
367 |
+
.map((substring) => {
|
368 |
+
// Replace two single quote characters with one single quote character
|
369 |
+
if (substring === "''") {
|
370 |
+
return { isToken: false, value: "'" };
|
371 |
+
}
|
372 |
+
|
373 |
+
const firstCharacter = substring[0];
|
374 |
+
if (firstCharacter === "'") {
|
375 |
+
return { isToken: false, value: cleanEscapedString(substring) };
|
376 |
+
}
|
377 |
+
|
378 |
+
if (formatters[firstCharacter]) {
|
379 |
+
return { isToken: true, value: substring };
|
380 |
+
}
|
381 |
+
|
382 |
+
if (firstCharacter.match(unescapedLatinCharacterRegExp)) {
|
383 |
+
throw new RangeError(
|
384 |
+
"Format string contains an unescaped latin alphabet character `" +
|
385 |
+
firstCharacter +
|
386 |
+
"`",
|
387 |
+
);
|
388 |
+
}
|
389 |
+
|
390 |
+
return { isToken: false, value: substring };
|
391 |
+
});
|
392 |
+
|
393 |
+
// invoke localize preprocessor (only for french locales at the moment)
|
394 |
+
if (locale.localize.preprocessor) {
|
395 |
+
parts = locale.localize.preprocessor(originalDate, parts);
|
396 |
+
}
|
397 |
+
|
398 |
+
const formatterOptions = {
|
399 |
+
firstWeekContainsDate,
|
400 |
+
weekStartsOn,
|
401 |
+
locale,
|
402 |
+
};
|
403 |
+
|
404 |
+
return parts
|
405 |
+
.map((part) => {
|
406 |
+
if (!part.isToken) return part.value;
|
407 |
+
|
408 |
+
const token = part.value;
|
409 |
+
|
410 |
+
if (
|
411 |
+
(!options?.useAdditionalWeekYearTokens &&
|
412 |
+
isProtectedWeekYearToken(token)) ||
|
413 |
+
(!options?.useAdditionalDayOfYearTokens &&
|
414 |
+
isProtectedDayOfYearToken(token))
|
415 |
+
) {
|
416 |
+
warnOrThrowProtectedError(token, formatStr, String(date));
|
417 |
+
}
|
418 |
+
|
419 |
+
const formatter = formatters[token[0]];
|
420 |
+
return formatter(originalDate, token, locale.localize, formatterOptions);
|
421 |
+
})
|
422 |
+
.join("");
|
423 |
+
}
|
424 |
+
|
425 |
+
function cleanEscapedString(input) {
|
426 |
+
const matched = input.match(escapedStringRegExp);
|
427 |
+
|
428 |
+
if (!matched) {
|
429 |
+
return input;
|
430 |
+
}
|
431 |
+
|
432 |
+
return matched[1].replace(doubleQuoteRegExp, "'");
|
433 |
+
}
|
434 |
+
|
435 |
+
// Fallback for modularized imports:
|
436 |
+
export default format;
|
workers1/auto3d/node_modules/date-fns/formatDistance.d.mts
ADDED
@@ -0,0 +1,96 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import type { LocalizedOptions } from "./types.js";
|
2 |
+
/**
|
3 |
+
* The {@link formatDistance} function options.
|
4 |
+
*/
|
5 |
+
export interface FormatDistanceOptions
|
6 |
+
extends LocalizedOptions<"formatDistance"> {
|
7 |
+
/** Distances less than a minute are more detailed */
|
8 |
+
includeSeconds?: boolean;
|
9 |
+
/** Add "X ago"/"in X" in the locale language */
|
10 |
+
addSuffix?: boolean;
|
11 |
+
}
|
12 |
+
/**
|
13 |
+
* @name formatDistance
|
14 |
+
* @category Common Helpers
|
15 |
+
* @summary Return the distance between the given dates in words.
|
16 |
+
*
|
17 |
+
* @description
|
18 |
+
* Return the distance between the given dates in words.
|
19 |
+
*
|
20 |
+
* | Distance between dates | Result |
|
21 |
+
* |-------------------------------------------------------------------|---------------------|
|
22 |
+
* | 0 ... 30 secs | less than a minute |
|
23 |
+
* | 30 secs ... 1 min 30 secs | 1 minute |
|
24 |
+
* | 1 min 30 secs ... 44 mins 30 secs | [2..44] minutes |
|
25 |
+
* | 44 mins ... 30 secs ... 89 mins 30 secs | about 1 hour |
|
26 |
+
* | 89 mins 30 secs ... 23 hrs 59 mins 30 secs | about [2..24] hours |
|
27 |
+
* | 23 hrs 59 mins 30 secs ... 41 hrs 59 mins 30 secs | 1 day |
|
28 |
+
* | 41 hrs 59 mins 30 secs ... 29 days 23 hrs 59 mins 30 secs | [2..30] days |
|
29 |
+
* | 29 days 23 hrs 59 mins 30 secs ... 44 days 23 hrs 59 mins 30 secs | about 1 month |
|
30 |
+
* | 44 days 23 hrs 59 mins 30 secs ... 59 days 23 hrs 59 mins 30 secs | about 2 months |
|
31 |
+
* | 59 days 23 hrs 59 mins 30 secs ... 1 yr | [2..12] months |
|
32 |
+
* | 1 yr ... 1 yr 3 months | about 1 year |
|
33 |
+
* | 1 yr 3 months ... 1 yr 9 month s | over 1 year |
|
34 |
+
* | 1 yr 9 months ... 2 yrs | almost 2 years |
|
35 |
+
* | N yrs ... N yrs 3 months | about N years |
|
36 |
+
* | N yrs 3 months ... N yrs 9 months | over N years |
|
37 |
+
* | N yrs 9 months ... N+1 yrs | almost N+1 years |
|
38 |
+
*
|
39 |
+
* With `options.includeSeconds == true`:
|
40 |
+
* | Distance between dates | Result |
|
41 |
+
* |------------------------|----------------------|
|
42 |
+
* | 0 secs ... 5 secs | less than 5 seconds |
|
43 |
+
* | 5 secs ... 10 secs | less than 10 seconds |
|
44 |
+
* | 10 secs ... 20 secs | less than 20 seconds |
|
45 |
+
* | 20 secs ... 40 secs | half a minute |
|
46 |
+
* | 40 secs ... 60 secs | less than a minute |
|
47 |
+
* | 60 secs ... 90 secs | 1 minute |
|
48 |
+
*
|
49 |
+
* @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
|
50 |
+
*
|
51 |
+
* @param date - The date
|
52 |
+
* @param baseDate - The date to compare with
|
53 |
+
* @param options - An object with options
|
54 |
+
*
|
55 |
+
* @returns The distance in words
|
56 |
+
*
|
57 |
+
* @throws `date` must not be Invalid Date
|
58 |
+
* @throws `baseDate` must not be Invalid Date
|
59 |
+
* @throws `options.locale` must contain `formatDistance` property
|
60 |
+
*
|
61 |
+
* @example
|
62 |
+
* // What is the distance between 2 July 2014 and 1 January 2015?
|
63 |
+
* const result = formatDistance(new Date(2014, 6, 2), new Date(2015, 0, 1))
|
64 |
+
* //=> '6 months'
|
65 |
+
*
|
66 |
+
* @example
|
67 |
+
* // What is the distance between 1 January 2015 00:00:15
|
68 |
+
* // and 1 January 2015 00:00:00, including seconds?
|
69 |
+
* const result = formatDistance(
|
70 |
+
* new Date(2015, 0, 1, 0, 0, 15),
|
71 |
+
* new Date(2015, 0, 1, 0, 0, 0),
|
72 |
+
* { includeSeconds: true }
|
73 |
+
* )
|
74 |
+
* //=> 'less than 20 seconds'
|
75 |
+
*
|
76 |
+
* @example
|
77 |
+
* // What is the distance from 1 January 2016
|
78 |
+
* // to 1 January 2015, with a suffix?
|
79 |
+
* const result = formatDistance(new Date(2015, 0, 1), new Date(2016, 0, 1), {
|
80 |
+
* addSuffix: true
|
81 |
+
* })
|
82 |
+
* //=> 'about 1 year ago'
|
83 |
+
*
|
84 |
+
* @example
|
85 |
+
* // What is the distance between 1 August 2016 and 1 January 2015 in Esperanto?
|
86 |
+
* import { eoLocale } from 'date-fns/locale/eo'
|
87 |
+
* const result = formatDistance(new Date(2016, 7, 1), new Date(2015, 0, 1), {
|
88 |
+
* locale: eoLocale
|
89 |
+
* })
|
90 |
+
* //=> 'pli ol 1 jaro'
|
91 |
+
*/
|
92 |
+
export declare function formatDistance<DateType extends Date>(
|
93 |
+
date: DateType | number | string,
|
94 |
+
baseDate: DateType | number | string,
|
95 |
+
options?: FormatDistanceOptions,
|
96 |
+
): string;
|
workers1/auto3d/node_modules/date-fns/formatDistance.d.ts
ADDED
@@ -0,0 +1,96 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import type { LocalizedOptions } from "./types.js";
|
2 |
+
/**
|
3 |
+
* The {@link formatDistance} function options.
|
4 |
+
*/
|
5 |
+
export interface FormatDistanceOptions
|
6 |
+
extends LocalizedOptions<"formatDistance"> {
|
7 |
+
/** Distances less than a minute are more detailed */
|
8 |
+
includeSeconds?: boolean;
|
9 |
+
/** Add "X ago"/"in X" in the locale language */
|
10 |
+
addSuffix?: boolean;
|
11 |
+
}
|
12 |
+
/**
|
13 |
+
* @name formatDistance
|
14 |
+
* @category Common Helpers
|
15 |
+
* @summary Return the distance between the given dates in words.
|
16 |
+
*
|
17 |
+
* @description
|
18 |
+
* Return the distance between the given dates in words.
|
19 |
+
*
|
20 |
+
* | Distance between dates | Result |
|
21 |
+
* |-------------------------------------------------------------------|---------------------|
|
22 |
+
* | 0 ... 30 secs | less than a minute |
|
23 |
+
* | 30 secs ... 1 min 30 secs | 1 minute |
|
24 |
+
* | 1 min 30 secs ... 44 mins 30 secs | [2..44] minutes |
|
25 |
+
* | 44 mins ... 30 secs ... 89 mins 30 secs | about 1 hour |
|
26 |
+
* | 89 mins 30 secs ... 23 hrs 59 mins 30 secs | about [2..24] hours |
|
27 |
+
* | 23 hrs 59 mins 30 secs ... 41 hrs 59 mins 30 secs | 1 day |
|
28 |
+
* | 41 hrs 59 mins 30 secs ... 29 days 23 hrs 59 mins 30 secs | [2..30] days |
|
29 |
+
* | 29 days 23 hrs 59 mins 30 secs ... 44 days 23 hrs 59 mins 30 secs | about 1 month |
|
30 |
+
* | 44 days 23 hrs 59 mins 30 secs ... 59 days 23 hrs 59 mins 30 secs | about 2 months |
|
31 |
+
* | 59 days 23 hrs 59 mins 30 secs ... 1 yr | [2..12] months |
|
32 |
+
* | 1 yr ... 1 yr 3 months | about 1 year |
|
33 |
+
* | 1 yr 3 months ... 1 yr 9 month s | over 1 year |
|
34 |
+
* | 1 yr 9 months ... 2 yrs | almost 2 years |
|
35 |
+
* | N yrs ... N yrs 3 months | about N years |
|
36 |
+
* | N yrs 3 months ... N yrs 9 months | over N years |
|
37 |
+
* | N yrs 9 months ... N+1 yrs | almost N+1 years |
|
38 |
+
*
|
39 |
+
* With `options.includeSeconds == true`:
|
40 |
+
* | Distance between dates | Result |
|
41 |
+
* |------------------------|----------------------|
|
42 |
+
* | 0 secs ... 5 secs | less than 5 seconds |
|
43 |
+
* | 5 secs ... 10 secs | less than 10 seconds |
|
44 |
+
* | 10 secs ... 20 secs | less than 20 seconds |
|
45 |
+
* | 20 secs ... 40 secs | half a minute |
|
46 |
+
* | 40 secs ... 60 secs | less than a minute |
|
47 |
+
* | 60 secs ... 90 secs | 1 minute |
|
48 |
+
*
|
49 |
+
* @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
|
50 |
+
*
|
51 |
+
* @param date - The date
|
52 |
+
* @param baseDate - The date to compare with
|
53 |
+
* @param options - An object with options
|
54 |
+
*
|
55 |
+
* @returns The distance in words
|
56 |
+
*
|
57 |
+
* @throws `date` must not be Invalid Date
|
58 |
+
* @throws `baseDate` must not be Invalid Date
|
59 |
+
* @throws `options.locale` must contain `formatDistance` property
|
60 |
+
*
|
61 |
+
* @example
|
62 |
+
* // What is the distance between 2 July 2014 and 1 January 2015?
|
63 |
+
* const result = formatDistance(new Date(2014, 6, 2), new Date(2015, 0, 1))
|
64 |
+
* //=> '6 months'
|
65 |
+
*
|
66 |
+
* @example
|
67 |
+
* // What is the distance between 1 January 2015 00:00:15
|
68 |
+
* // and 1 January 2015 00:00:00, including seconds?
|
69 |
+
* const result = formatDistance(
|
70 |
+
* new Date(2015, 0, 1, 0, 0, 15),
|
71 |
+
* new Date(2015, 0, 1, 0, 0, 0),
|
72 |
+
* { includeSeconds: true }
|
73 |
+
* )
|
74 |
+
* //=> 'less than 20 seconds'
|
75 |
+
*
|
76 |
+
* @example
|
77 |
+
* // What is the distance from 1 January 2016
|
78 |
+
* // to 1 January 2015, with a suffix?
|
79 |
+
* const result = formatDistance(new Date(2015, 0, 1), new Date(2016, 0, 1), {
|
80 |
+
* addSuffix: true
|
81 |
+
* })
|
82 |
+
* //=> 'about 1 year ago'
|
83 |
+
*
|
84 |
+
* @example
|
85 |
+
* // What is the distance between 1 August 2016 and 1 January 2015 in Esperanto?
|
86 |
+
* import { eoLocale } from 'date-fns/locale/eo'
|
87 |
+
* const result = formatDistance(new Date(2016, 7, 1), new Date(2015, 0, 1), {
|
88 |
+
* locale: eoLocale
|
89 |
+
* })
|
90 |
+
* //=> 'pli ol 1 jaro'
|
91 |
+
*/
|
92 |
+
export declare function formatDistance<DateType extends Date>(
|
93 |
+
date: DateType | number | string,
|
94 |
+
baseDate: DateType | number | string,
|
95 |
+
options?: FormatDistanceOptions,
|
96 |
+
): string;
|
workers1/auto3d/node_modules/date-fns/formatDistance.js
ADDED
@@ -0,0 +1,210 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"use strict";
|
2 |
+
exports.formatDistance = formatDistance;
|
3 |
+
var _index = require("./compareAsc.js");
|
4 |
+
var _index2 = require("./constants.js");
|
5 |
+
var _index3 = require("./differenceInMonths.js");
|
6 |
+
var _index4 = require("./differenceInSeconds.js");
|
7 |
+
var _index5 = require("./toDate.js");
|
8 |
+
|
9 |
+
var _index6 = require("./_lib/defaultLocale.js");
|
10 |
+
var _index7 = require("./_lib/defaultOptions.js");
|
11 |
+
var _index8 = require("./_lib/getTimezoneOffsetInMilliseconds.js");
|
12 |
+
|
13 |
+
/**
|
14 |
+
* The {@link formatDistance} function options.
|
15 |
+
*/
|
16 |
+
|
17 |
+
/**
|
18 |
+
* @name formatDistance
|
19 |
+
* @category Common Helpers
|
20 |
+
* @summary Return the distance between the given dates in words.
|
21 |
+
*
|
22 |
+
* @description
|
23 |
+
* Return the distance between the given dates in words.
|
24 |
+
*
|
25 |
+
* | Distance between dates | Result |
|
26 |
+
* |-------------------------------------------------------------------|---------------------|
|
27 |
+
* | 0 ... 30 secs | less than a minute |
|
28 |
+
* | 30 secs ... 1 min 30 secs | 1 minute |
|
29 |
+
* | 1 min 30 secs ... 44 mins 30 secs | [2..44] minutes |
|
30 |
+
* | 44 mins ... 30 secs ... 89 mins 30 secs | about 1 hour |
|
31 |
+
* | 89 mins 30 secs ... 23 hrs 59 mins 30 secs | about [2..24] hours |
|
32 |
+
* | 23 hrs 59 mins 30 secs ... 41 hrs 59 mins 30 secs | 1 day |
|
33 |
+
* | 41 hrs 59 mins 30 secs ... 29 days 23 hrs 59 mins 30 secs | [2..30] days |
|
34 |
+
* | 29 days 23 hrs 59 mins 30 secs ... 44 days 23 hrs 59 mins 30 secs | about 1 month |
|
35 |
+
* | 44 days 23 hrs 59 mins 30 secs ... 59 days 23 hrs 59 mins 30 secs | about 2 months |
|
36 |
+
* | 59 days 23 hrs 59 mins 30 secs ... 1 yr | [2..12] months |
|
37 |
+
* | 1 yr ... 1 yr 3 months | about 1 year |
|
38 |
+
* | 1 yr 3 months ... 1 yr 9 month s | over 1 year |
|
39 |
+
* | 1 yr 9 months ... 2 yrs | almost 2 years |
|
40 |
+
* | N yrs ... N yrs 3 months | about N years |
|
41 |
+
* | N yrs 3 months ... N yrs 9 months | over N years |
|
42 |
+
* | N yrs 9 months ... N+1 yrs | almost N+1 years |
|
43 |
+
*
|
44 |
+
* With `options.includeSeconds == true`:
|
45 |
+
* | Distance between dates | Result |
|
46 |
+
* |------------------------|----------------------|
|
47 |
+
* | 0 secs ... 5 secs | less than 5 seconds |
|
48 |
+
* | 5 secs ... 10 secs | less than 10 seconds |
|
49 |
+
* | 10 secs ... 20 secs | less than 20 seconds |
|
50 |
+
* | 20 secs ... 40 secs | half a minute |
|
51 |
+
* | 40 secs ... 60 secs | less than a minute |
|
52 |
+
* | 60 secs ... 90 secs | 1 minute |
|
53 |
+
*
|
54 |
+
* @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
|
55 |
+
*
|
56 |
+
* @param date - The date
|
57 |
+
* @param baseDate - The date to compare with
|
58 |
+
* @param options - An object with options
|
59 |
+
*
|
60 |
+
* @returns The distance in words
|
61 |
+
*
|
62 |
+
* @throws `date` must not be Invalid Date
|
63 |
+
* @throws `baseDate` must not be Invalid Date
|
64 |
+
* @throws `options.locale` must contain `formatDistance` property
|
65 |
+
*
|
66 |
+
* @example
|
67 |
+
* // What is the distance between 2 July 2014 and 1 January 2015?
|
68 |
+
* const result = formatDistance(new Date(2014, 6, 2), new Date(2015, 0, 1))
|
69 |
+
* //=> '6 months'
|
70 |
+
*
|
71 |
+
* @example
|
72 |
+
* // What is the distance between 1 January 2015 00:00:15
|
73 |
+
* // and 1 January 2015 00:00:00, including seconds?
|
74 |
+
* const result = formatDistance(
|
75 |
+
* new Date(2015, 0, 1, 0, 0, 15),
|
76 |
+
* new Date(2015, 0, 1, 0, 0, 0),
|
77 |
+
* { includeSeconds: true }
|
78 |
+
* )
|
79 |
+
* //=> 'less than 20 seconds'
|
80 |
+
*
|
81 |
+
* @example
|
82 |
+
* // What is the distance from 1 January 2016
|
83 |
+
* // to 1 January 2015, with a suffix?
|
84 |
+
* const result = formatDistance(new Date(2015, 0, 1), new Date(2016, 0, 1), {
|
85 |
+
* addSuffix: true
|
86 |
+
* })
|
87 |
+
* //=> 'about 1 year ago'
|
88 |
+
*
|
89 |
+
* @example
|
90 |
+
* // What is the distance between 1 August 2016 and 1 January 2015 in Esperanto?
|
91 |
+
* import { eoLocale } from 'date-fns/locale/eo'
|
92 |
+
* const result = formatDistance(new Date(2016, 7, 1), new Date(2015, 0, 1), {
|
93 |
+
* locale: eoLocale
|
94 |
+
* })
|
95 |
+
* //=> 'pli ol 1 jaro'
|
96 |
+
*/
|
97 |
+
|
98 |
+
function formatDistance(date, baseDate, options) {
|
99 |
+
const defaultOptions = (0, _index7.getDefaultOptions)();
|
100 |
+
const locale =
|
101 |
+
options?.locale ?? defaultOptions.locale ?? _index6.defaultLocale;
|
102 |
+
const minutesInAlmostTwoDays = 2520;
|
103 |
+
|
104 |
+
const comparison = (0, _index.compareAsc)(date, baseDate);
|
105 |
+
|
106 |
+
if (isNaN(comparison)) {
|
107 |
+
throw new RangeError("Invalid time value");
|
108 |
+
}
|
109 |
+
|
110 |
+
const localizeOptions = Object.assign({}, options, {
|
111 |
+
addSuffix: options?.addSuffix,
|
112 |
+
comparison: comparison,
|
113 |
+
});
|
114 |
+
|
115 |
+
let dateLeft;
|
116 |
+
let dateRight;
|
117 |
+
if (comparison > 0) {
|
118 |
+
dateLeft = (0, _index5.toDate)(baseDate);
|
119 |
+
dateRight = (0, _index5.toDate)(date);
|
120 |
+
} else {
|
121 |
+
dateLeft = (0, _index5.toDate)(date);
|
122 |
+
dateRight = (0, _index5.toDate)(baseDate);
|
123 |
+
}
|
124 |
+
|
125 |
+
const seconds = (0, _index4.differenceInSeconds)(dateRight, dateLeft);
|
126 |
+
const offsetInSeconds =
|
127 |
+
((0, _index8.getTimezoneOffsetInMilliseconds)(dateRight) -
|
128 |
+
(0, _index8.getTimezoneOffsetInMilliseconds)(dateLeft)) /
|
129 |
+
1000;
|
130 |
+
const minutes = Math.round((seconds - offsetInSeconds) / 60);
|
131 |
+
let months;
|
132 |
+
|
133 |
+
// 0 up to 2 mins
|
134 |
+
if (minutes < 2) {
|
135 |
+
if (options?.includeSeconds) {
|
136 |
+
if (seconds < 5) {
|
137 |
+
return locale.formatDistance("lessThanXSeconds", 5, localizeOptions);
|
138 |
+
} else if (seconds < 10) {
|
139 |
+
return locale.formatDistance("lessThanXSeconds", 10, localizeOptions);
|
140 |
+
} else if (seconds < 20) {
|
141 |
+
return locale.formatDistance("lessThanXSeconds", 20, localizeOptions);
|
142 |
+
} else if (seconds < 40) {
|
143 |
+
return locale.formatDistance("halfAMinute", 0, localizeOptions);
|
144 |
+
} else if (seconds < 60) {
|
145 |
+
return locale.formatDistance("lessThanXMinutes", 1, localizeOptions);
|
146 |
+
} else {
|
147 |
+
return locale.formatDistance("xMinutes", 1, localizeOptions);
|
148 |
+
}
|
149 |
+
} else {
|
150 |
+
if (minutes === 0) {
|
151 |
+
return locale.formatDistance("lessThanXMinutes", 1, localizeOptions);
|
152 |
+
} else {
|
153 |
+
return locale.formatDistance("xMinutes", minutes, localizeOptions);
|
154 |
+
}
|
155 |
+
}
|
156 |
+
|
157 |
+
// 2 mins up to 0.75 hrs
|
158 |
+
} else if (minutes < 45) {
|
159 |
+
return locale.formatDistance("xMinutes", minutes, localizeOptions);
|
160 |
+
|
161 |
+
// 0.75 hrs up to 1.5 hrs
|
162 |
+
} else if (minutes < 90) {
|
163 |
+
return locale.formatDistance("aboutXHours", 1, localizeOptions);
|
164 |
+
|
165 |
+
// 1.5 hrs up to 24 hrs
|
166 |
+
} else if (minutes < _index2.minutesInDay) {
|
167 |
+
const hours = Math.round(minutes / 60);
|
168 |
+
return locale.formatDistance("aboutXHours", hours, localizeOptions);
|
169 |
+
|
170 |
+
// 1 day up to 1.75 days
|
171 |
+
} else if (minutes < minutesInAlmostTwoDays) {
|
172 |
+
return locale.formatDistance("xDays", 1, localizeOptions);
|
173 |
+
|
174 |
+
// 1.75 days up to 30 days
|
175 |
+
} else if (minutes < _index2.minutesInMonth) {
|
176 |
+
const days = Math.round(minutes / _index2.minutesInDay);
|
177 |
+
return locale.formatDistance("xDays", days, localizeOptions);
|
178 |
+
|
179 |
+
// 1 month up to 2 months
|
180 |
+
} else if (minutes < _index2.minutesInMonth * 2) {
|
181 |
+
months = Math.round(minutes / _index2.minutesInMonth);
|
182 |
+
return locale.formatDistance("aboutXMonths", months, localizeOptions);
|
183 |
+
}
|
184 |
+
|
185 |
+
months = (0, _index3.differenceInMonths)(dateRight, dateLeft);
|
186 |
+
|
187 |
+
// 2 months up to 12 months
|
188 |
+
if (months < 12) {
|
189 |
+
const nearestMonth = Math.round(minutes / _index2.minutesInMonth);
|
190 |
+
return locale.formatDistance("xMonths", nearestMonth, localizeOptions);
|
191 |
+
|
192 |
+
// 1 year up to max Date
|
193 |
+
} else {
|
194 |
+
const monthsSinceStartOfYear = months % 12;
|
195 |
+
const years = Math.trunc(months / 12);
|
196 |
+
|
197 |
+
// N years up to 1 years 3 months
|
198 |
+
if (monthsSinceStartOfYear < 3) {
|
199 |
+
return locale.formatDistance("aboutXYears", years, localizeOptions);
|
200 |
+
|
201 |
+
// N years 3 months up to N years 9 months
|
202 |
+
} else if (monthsSinceStartOfYear < 9) {
|
203 |
+
return locale.formatDistance("overXYears", years, localizeOptions);
|
204 |
+
|
205 |
+
// N years 9 months up to N year 12 months
|
206 |
+
} else {
|
207 |
+
return locale.formatDistance("almostXYears", years + 1, localizeOptions);
|
208 |
+
}
|
209 |
+
}
|
210 |
+
}
|
workers1/auto3d/node_modules/date-fns/formatDistance.mjs
ADDED
@@ -0,0 +1,209 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { compareAsc } from "./compareAsc.mjs";
|
2 |
+
import { minutesInDay, minutesInMonth } from "./constants.mjs";
|
3 |
+
import { differenceInMonths } from "./differenceInMonths.mjs";
|
4 |
+
import { differenceInSeconds } from "./differenceInSeconds.mjs";
|
5 |
+
import { toDate } from "./toDate.mjs";
|
6 |
+
import { defaultLocale } from "./_lib/defaultLocale.mjs";
|
7 |
+
import { getDefaultOptions } from "./_lib/defaultOptions.mjs";
|
8 |
+
import { getTimezoneOffsetInMilliseconds } from "./_lib/getTimezoneOffsetInMilliseconds.mjs";
|
9 |
+
|
10 |
+
/**
|
11 |
+
* The {@link formatDistance} function options.
|
12 |
+
*/
|
13 |
+
|
14 |
+
/**
|
15 |
+
* @name formatDistance
|
16 |
+
* @category Common Helpers
|
17 |
+
* @summary Return the distance between the given dates in words.
|
18 |
+
*
|
19 |
+
* @description
|
20 |
+
* Return the distance between the given dates in words.
|
21 |
+
*
|
22 |
+
* | Distance between dates | Result |
|
23 |
+
* |-------------------------------------------------------------------|---------------------|
|
24 |
+
* | 0 ... 30 secs | less than a minute |
|
25 |
+
* | 30 secs ... 1 min 30 secs | 1 minute |
|
26 |
+
* | 1 min 30 secs ... 44 mins 30 secs | [2..44] minutes |
|
27 |
+
* | 44 mins ... 30 secs ... 89 mins 30 secs | about 1 hour |
|
28 |
+
* | 89 mins 30 secs ... 23 hrs 59 mins 30 secs | about [2..24] hours |
|
29 |
+
* | 23 hrs 59 mins 30 secs ... 41 hrs 59 mins 30 secs | 1 day |
|
30 |
+
* | 41 hrs 59 mins 30 secs ... 29 days 23 hrs 59 mins 30 secs | [2..30] days |
|
31 |
+
* | 29 days 23 hrs 59 mins 30 secs ... 44 days 23 hrs 59 mins 30 secs | about 1 month |
|
32 |
+
* | 44 days 23 hrs 59 mins 30 secs ... 59 days 23 hrs 59 mins 30 secs | about 2 months |
|
33 |
+
* | 59 days 23 hrs 59 mins 30 secs ... 1 yr | [2..12] months |
|
34 |
+
* | 1 yr ... 1 yr 3 months | about 1 year |
|
35 |
+
* | 1 yr 3 months ... 1 yr 9 month s | over 1 year |
|
36 |
+
* | 1 yr 9 months ... 2 yrs | almost 2 years |
|
37 |
+
* | N yrs ... N yrs 3 months | about N years |
|
38 |
+
* | N yrs 3 months ... N yrs 9 months | over N years |
|
39 |
+
* | N yrs 9 months ... N+1 yrs | almost N+1 years |
|
40 |
+
*
|
41 |
+
* With `options.includeSeconds == true`:
|
42 |
+
* | Distance between dates | Result |
|
43 |
+
* |------------------------|----------------------|
|
44 |
+
* | 0 secs ... 5 secs | less than 5 seconds |
|
45 |
+
* | 5 secs ... 10 secs | less than 10 seconds |
|
46 |
+
* | 10 secs ... 20 secs | less than 20 seconds |
|
47 |
+
* | 20 secs ... 40 secs | half a minute |
|
48 |
+
* | 40 secs ... 60 secs | less than a minute |
|
49 |
+
* | 60 secs ... 90 secs | 1 minute |
|
50 |
+
*
|
51 |
+
* @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
|
52 |
+
*
|
53 |
+
* @param date - The date
|
54 |
+
* @param baseDate - The date to compare with
|
55 |
+
* @param options - An object with options
|
56 |
+
*
|
57 |
+
* @returns The distance in words
|
58 |
+
*
|
59 |
+
* @throws `date` must not be Invalid Date
|
60 |
+
* @throws `baseDate` must not be Invalid Date
|
61 |
+
* @throws `options.locale` must contain `formatDistance` property
|
62 |
+
*
|
63 |
+
* @example
|
64 |
+
* // What is the distance between 2 July 2014 and 1 January 2015?
|
65 |
+
* const result = formatDistance(new Date(2014, 6, 2), new Date(2015, 0, 1))
|
66 |
+
* //=> '6 months'
|
67 |
+
*
|
68 |
+
* @example
|
69 |
+
* // What is the distance between 1 January 2015 00:00:15
|
70 |
+
* // and 1 January 2015 00:00:00, including seconds?
|
71 |
+
* const result = formatDistance(
|
72 |
+
* new Date(2015, 0, 1, 0, 0, 15),
|
73 |
+
* new Date(2015, 0, 1, 0, 0, 0),
|
74 |
+
* { includeSeconds: true }
|
75 |
+
* )
|
76 |
+
* //=> 'less than 20 seconds'
|
77 |
+
*
|
78 |
+
* @example
|
79 |
+
* // What is the distance from 1 January 2016
|
80 |
+
* // to 1 January 2015, with a suffix?
|
81 |
+
* const result = formatDistance(new Date(2015, 0, 1), new Date(2016, 0, 1), {
|
82 |
+
* addSuffix: true
|
83 |
+
* })
|
84 |
+
* //=> 'about 1 year ago'
|
85 |
+
*
|
86 |
+
* @example
|
87 |
+
* // What is the distance between 1 August 2016 and 1 January 2015 in Esperanto?
|
88 |
+
* import { eoLocale } from 'date-fns/locale/eo'
|
89 |
+
* const result = formatDistance(new Date(2016, 7, 1), new Date(2015, 0, 1), {
|
90 |
+
* locale: eoLocale
|
91 |
+
* })
|
92 |
+
* //=> 'pli ol 1 jaro'
|
93 |
+
*/
|
94 |
+
|
95 |
+
export function formatDistance(date, baseDate, options) {
|
96 |
+
const defaultOptions = getDefaultOptions();
|
97 |
+
const locale = options?.locale ?? defaultOptions.locale ?? defaultLocale;
|
98 |
+
const minutesInAlmostTwoDays = 2520;
|
99 |
+
|
100 |
+
const comparison = compareAsc(date, baseDate);
|
101 |
+
|
102 |
+
if (isNaN(comparison)) {
|
103 |
+
throw new RangeError("Invalid time value");
|
104 |
+
}
|
105 |
+
|
106 |
+
const localizeOptions = Object.assign({}, options, {
|
107 |
+
addSuffix: options?.addSuffix,
|
108 |
+
comparison: comparison,
|
109 |
+
});
|
110 |
+
|
111 |
+
let dateLeft;
|
112 |
+
let dateRight;
|
113 |
+
if (comparison > 0) {
|
114 |
+
dateLeft = toDate(baseDate);
|
115 |
+
dateRight = toDate(date);
|
116 |
+
} else {
|
117 |
+
dateLeft = toDate(date);
|
118 |
+
dateRight = toDate(baseDate);
|
119 |
+
}
|
120 |
+
|
121 |
+
const seconds = differenceInSeconds(dateRight, dateLeft);
|
122 |
+
const offsetInSeconds =
|
123 |
+
(getTimezoneOffsetInMilliseconds(dateRight) -
|
124 |
+
getTimezoneOffsetInMilliseconds(dateLeft)) /
|
125 |
+
1000;
|
126 |
+
const minutes = Math.round((seconds - offsetInSeconds) / 60);
|
127 |
+
let months;
|
128 |
+
|
129 |
+
// 0 up to 2 mins
|
130 |
+
if (minutes < 2) {
|
131 |
+
if (options?.includeSeconds) {
|
132 |
+
if (seconds < 5) {
|
133 |
+
return locale.formatDistance("lessThanXSeconds", 5, localizeOptions);
|
134 |
+
} else if (seconds < 10) {
|
135 |
+
return locale.formatDistance("lessThanXSeconds", 10, localizeOptions);
|
136 |
+
} else if (seconds < 20) {
|
137 |
+
return locale.formatDistance("lessThanXSeconds", 20, localizeOptions);
|
138 |
+
} else if (seconds < 40) {
|
139 |
+
return locale.formatDistance("halfAMinute", 0, localizeOptions);
|
140 |
+
} else if (seconds < 60) {
|
141 |
+
return locale.formatDistance("lessThanXMinutes", 1, localizeOptions);
|
142 |
+
} else {
|
143 |
+
return locale.formatDistance("xMinutes", 1, localizeOptions);
|
144 |
+
}
|
145 |
+
} else {
|
146 |
+
if (minutes === 0) {
|
147 |
+
return locale.formatDistance("lessThanXMinutes", 1, localizeOptions);
|
148 |
+
} else {
|
149 |
+
return locale.formatDistance("xMinutes", minutes, localizeOptions);
|
150 |
+
}
|
151 |
+
}
|
152 |
+
|
153 |
+
// 2 mins up to 0.75 hrs
|
154 |
+
} else if (minutes < 45) {
|
155 |
+
return locale.formatDistance("xMinutes", minutes, localizeOptions);
|
156 |
+
|
157 |
+
// 0.75 hrs up to 1.5 hrs
|
158 |
+
} else if (minutes < 90) {
|
159 |
+
return locale.formatDistance("aboutXHours", 1, localizeOptions);
|
160 |
+
|
161 |
+
// 1.5 hrs up to 24 hrs
|
162 |
+
} else if (minutes < minutesInDay) {
|
163 |
+
const hours = Math.round(minutes / 60);
|
164 |
+
return locale.formatDistance("aboutXHours", hours, localizeOptions);
|
165 |
+
|
166 |
+
// 1 day up to 1.75 days
|
167 |
+
} else if (minutes < minutesInAlmostTwoDays) {
|
168 |
+
return locale.formatDistance("xDays", 1, localizeOptions);
|
169 |
+
|
170 |
+
// 1.75 days up to 30 days
|
171 |
+
} else if (minutes < minutesInMonth) {
|
172 |
+
const days = Math.round(minutes / minutesInDay);
|
173 |
+
return locale.formatDistance("xDays", days, localizeOptions);
|
174 |
+
|
175 |
+
// 1 month up to 2 months
|
176 |
+
} else if (minutes < minutesInMonth * 2) {
|
177 |
+
months = Math.round(minutes / minutesInMonth);
|
178 |
+
return locale.formatDistance("aboutXMonths", months, localizeOptions);
|
179 |
+
}
|
180 |
+
|
181 |
+
months = differenceInMonths(dateRight, dateLeft);
|
182 |
+
|
183 |
+
// 2 months up to 12 months
|
184 |
+
if (months < 12) {
|
185 |
+
const nearestMonth = Math.round(minutes / minutesInMonth);
|
186 |
+
return locale.formatDistance("xMonths", nearestMonth, localizeOptions);
|
187 |
+
|
188 |
+
// 1 year up to max Date
|
189 |
+
} else {
|
190 |
+
const monthsSinceStartOfYear = months % 12;
|
191 |
+
const years = Math.trunc(months / 12);
|
192 |
+
|
193 |
+
// N years up to 1 years 3 months
|
194 |
+
if (monthsSinceStartOfYear < 3) {
|
195 |
+
return locale.formatDistance("aboutXYears", years, localizeOptions);
|
196 |
+
|
197 |
+
// N years 3 months up to N years 9 months
|
198 |
+
} else if (monthsSinceStartOfYear < 9) {
|
199 |
+
return locale.formatDistance("overXYears", years, localizeOptions);
|
200 |
+
|
201 |
+
// N years 9 months up to N year 12 months
|
202 |
+
} else {
|
203 |
+
return locale.formatDistance("almostXYears", years + 1, localizeOptions);
|
204 |
+
}
|
205 |
+
}
|
206 |
+
}
|
207 |
+
|
208 |
+
// Fallback for modularized imports:
|
209 |
+
export default formatDistance;
|
workers1/auto3d/node_modules/date-fns/formatDistanceStrict.d.mts
ADDED
@@ -0,0 +1,106 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import type { LocalizedOptions, RoundingOptions } from "./types.js";
|
2 |
+
/**
|
3 |
+
* The {@link formatDistanceStrict} function options.
|
4 |
+
*/
|
5 |
+
export interface FormatDistanceStrictOptions
|
6 |
+
extends LocalizedOptions<"formatDistance">,
|
7 |
+
RoundingOptions {
|
8 |
+
/** Add "X ago"/"in X" in the locale language */
|
9 |
+
addSuffix?: boolean;
|
10 |
+
/** If specified, will force the unit */
|
11 |
+
unit?: FormatDistanceStrictUnit;
|
12 |
+
}
|
13 |
+
/**
|
14 |
+
* The unit used to format the distance in {@link formatDistanceStrict}.
|
15 |
+
*/
|
16 |
+
export type FormatDistanceStrictUnit =
|
17 |
+
| "second"
|
18 |
+
| "minute"
|
19 |
+
| "hour"
|
20 |
+
| "day"
|
21 |
+
| "month"
|
22 |
+
| "year";
|
23 |
+
/**
|
24 |
+
* @name formatDistanceStrict
|
25 |
+
* @category Common Helpers
|
26 |
+
* @summary Return the distance between the given dates in words.
|
27 |
+
*
|
28 |
+
* @description
|
29 |
+
* Return the distance between the given dates in words, using strict units.
|
30 |
+
* This is like `formatDistance`, but does not use helpers like 'almost', 'over',
|
31 |
+
* 'less than' and the like.
|
32 |
+
*
|
33 |
+
* | Distance between dates | Result |
|
34 |
+
* |------------------------|---------------------|
|
35 |
+
* | 0 ... 59 secs | [0..59] seconds |
|
36 |
+
* | 1 ... 59 mins | [1..59] minutes |
|
37 |
+
* | 1 ... 23 hrs | [1..23] hours |
|
38 |
+
* | 1 ... 29 days | [1..29] days |
|
39 |
+
* | 1 ... 11 months | [1..11] months |
|
40 |
+
* | 1 ... N years | [1..N] years |
|
41 |
+
*
|
42 |
+
* @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
|
43 |
+
*
|
44 |
+
* @param date - The date
|
45 |
+
* @param baseDate - The date to compare with
|
46 |
+
* @param options - An object with options
|
47 |
+
*
|
48 |
+
* @returns The distance in words
|
49 |
+
*
|
50 |
+
* @throws `date` must not be Invalid Date
|
51 |
+
* @throws `baseDate` must not be Invalid Date
|
52 |
+
* @throws `options.unit` must be 'second', 'minute', 'hour', 'day', 'month' or 'year'
|
53 |
+
* @throws `options.locale` must contain `formatDistance` property
|
54 |
+
*
|
55 |
+
* @example
|
56 |
+
* // What is the distance between 2 July 2014 and 1 January 2015?
|
57 |
+
* const result = formatDistanceStrict(new Date(2014, 6, 2), new Date(2015, 0, 2))
|
58 |
+
* //=> '6 months'
|
59 |
+
*
|
60 |
+
* @example
|
61 |
+
* // What is the distance between 1 January 2015 00:00:15
|
62 |
+
* // and 1 January 2015 00:00:00?
|
63 |
+
* const result = formatDistanceStrict(
|
64 |
+
* new Date(2015, 0, 1, 0, 0, 15),
|
65 |
+
* new Date(2015, 0, 1, 0, 0, 0)
|
66 |
+
* )
|
67 |
+
* //=> '15 seconds'
|
68 |
+
*
|
69 |
+
* @example
|
70 |
+
* // What is the distance from 1 January 2016
|
71 |
+
* // to 1 January 2015, with a suffix?
|
72 |
+
* const result = formatDistanceStrict(new Date(2015, 0, 1), new Date(2016, 0, 1), {
|
73 |
+
* addSuffix: true
|
74 |
+
* })
|
75 |
+
* //=> '1 year ago'
|
76 |
+
*
|
77 |
+
* @example
|
78 |
+
* // What is the distance from 1 January 2016
|
79 |
+
* // to 1 January 2015, in minutes?
|
80 |
+
* const result = formatDistanceStrict(new Date(2016, 0, 1), new Date(2015, 0, 1), {
|
81 |
+
* unit: 'minute'
|
82 |
+
* })
|
83 |
+
* //=> '525600 minutes'
|
84 |
+
*
|
85 |
+
* @example
|
86 |
+
* // What is the distance from 1 January 2015
|
87 |
+
* // to 28 January 2015, in months, rounded up?
|
88 |
+
* const result = formatDistanceStrict(new Date(2015, 0, 28), new Date(2015, 0, 1), {
|
89 |
+
* unit: 'month',
|
90 |
+
* roundingMethod: 'ceil'
|
91 |
+
* })
|
92 |
+
* //=> '1 month'
|
93 |
+
*
|
94 |
+
* @example
|
95 |
+
* // What is the distance between 1 August 2016 and 1 January 2015 in Esperanto?
|
96 |
+
* import { eoLocale } from 'date-fns/locale/eo'
|
97 |
+
* const result = formatDistanceStrict(new Date(2016, 7, 1), new Date(2015, 0, 1), {
|
98 |
+
* locale: eoLocale
|
99 |
+
* })
|
100 |
+
* //=> '1 jaro'
|
101 |
+
*/
|
102 |
+
export declare function formatDistanceStrict<DateType extends Date>(
|
103 |
+
date: DateType | number | string,
|
104 |
+
baseDate: DateType | number | string,
|
105 |
+
options?: FormatDistanceStrictOptions,
|
106 |
+
): string;
|
workers1/auto3d/node_modules/date-fns/formatDistanceStrict.d.ts
ADDED
@@ -0,0 +1,106 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import type { LocalizedOptions, RoundingOptions } from "./types.js";
|
2 |
+
/**
|
3 |
+
* The {@link formatDistanceStrict} function options.
|
4 |
+
*/
|
5 |
+
export interface FormatDistanceStrictOptions
|
6 |
+
extends LocalizedOptions<"formatDistance">,
|
7 |
+
RoundingOptions {
|
8 |
+
/** Add "X ago"/"in X" in the locale language */
|
9 |
+
addSuffix?: boolean;
|
10 |
+
/** If specified, will force the unit */
|
11 |
+
unit?: FormatDistanceStrictUnit;
|
12 |
+
}
|
13 |
+
/**
|
14 |
+
* The unit used to format the distance in {@link formatDistanceStrict}.
|
15 |
+
*/
|
16 |
+
export type FormatDistanceStrictUnit =
|
17 |
+
| "second"
|
18 |
+
| "minute"
|
19 |
+
| "hour"
|
20 |
+
| "day"
|
21 |
+
| "month"
|
22 |
+
| "year";
|
23 |
+
/**
|
24 |
+
* @name formatDistanceStrict
|
25 |
+
* @category Common Helpers
|
26 |
+
* @summary Return the distance between the given dates in words.
|
27 |
+
*
|
28 |
+
* @description
|
29 |
+
* Return the distance between the given dates in words, using strict units.
|
30 |
+
* This is like `formatDistance`, but does not use helpers like 'almost', 'over',
|
31 |
+
* 'less than' and the like.
|
32 |
+
*
|
33 |
+
* | Distance between dates | Result |
|
34 |
+
* |------------------------|---------------------|
|
35 |
+
* | 0 ... 59 secs | [0..59] seconds |
|
36 |
+
* | 1 ... 59 mins | [1..59] minutes |
|
37 |
+
* | 1 ... 23 hrs | [1..23] hours |
|
38 |
+
* | 1 ... 29 days | [1..29] days |
|
39 |
+
* | 1 ... 11 months | [1..11] months |
|
40 |
+
* | 1 ... N years | [1..N] years |
|
41 |
+
*
|
42 |
+
* @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
|
43 |
+
*
|
44 |
+
* @param date - The date
|
45 |
+
* @param baseDate - The date to compare with
|
46 |
+
* @param options - An object with options
|
47 |
+
*
|
48 |
+
* @returns The distance in words
|
49 |
+
*
|
50 |
+
* @throws `date` must not be Invalid Date
|
51 |
+
* @throws `baseDate` must not be Invalid Date
|
52 |
+
* @throws `options.unit` must be 'second', 'minute', 'hour', 'day', 'month' or 'year'
|
53 |
+
* @throws `options.locale` must contain `formatDistance` property
|
54 |
+
*
|
55 |
+
* @example
|
56 |
+
* // What is the distance between 2 July 2014 and 1 January 2015?
|
57 |
+
* const result = formatDistanceStrict(new Date(2014, 6, 2), new Date(2015, 0, 2))
|
58 |
+
* //=> '6 months'
|
59 |
+
*
|
60 |
+
* @example
|
61 |
+
* // What is the distance between 1 January 2015 00:00:15
|
62 |
+
* // and 1 January 2015 00:00:00?
|
63 |
+
* const result = formatDistanceStrict(
|
64 |
+
* new Date(2015, 0, 1, 0, 0, 15),
|
65 |
+
* new Date(2015, 0, 1, 0, 0, 0)
|
66 |
+
* )
|
67 |
+
* //=> '15 seconds'
|
68 |
+
*
|
69 |
+
* @example
|
70 |
+
* // What is the distance from 1 January 2016
|
71 |
+
* // to 1 January 2015, with a suffix?
|
72 |
+
* const result = formatDistanceStrict(new Date(2015, 0, 1), new Date(2016, 0, 1), {
|
73 |
+
* addSuffix: true
|
74 |
+
* })
|
75 |
+
* //=> '1 year ago'
|
76 |
+
*
|
77 |
+
* @example
|
78 |
+
* // What is the distance from 1 January 2016
|
79 |
+
* // to 1 January 2015, in minutes?
|
80 |
+
* const result = formatDistanceStrict(new Date(2016, 0, 1), new Date(2015, 0, 1), {
|
81 |
+
* unit: 'minute'
|
82 |
+
* })
|
83 |
+
* //=> '525600 minutes'
|
84 |
+
*
|
85 |
+
* @example
|
86 |
+
* // What is the distance from 1 January 2015
|
87 |
+
* // to 28 January 2015, in months, rounded up?
|
88 |
+
* const result = formatDistanceStrict(new Date(2015, 0, 28), new Date(2015, 0, 1), {
|
89 |
+
* unit: 'month',
|
90 |
+
* roundingMethod: 'ceil'
|
91 |
+
* })
|
92 |
+
* //=> '1 month'
|
93 |
+
*
|
94 |
+
* @example
|
95 |
+
* // What is the distance between 1 August 2016 and 1 January 2015 in Esperanto?
|
96 |
+
* import { eoLocale } from 'date-fns/locale/eo'
|
97 |
+
* const result = formatDistanceStrict(new Date(2016, 7, 1), new Date(2015, 0, 1), {
|
98 |
+
* locale: eoLocale
|
99 |
+
* })
|
100 |
+
* //=> '1 jaro'
|
101 |
+
*/
|
102 |
+
export declare function formatDistanceStrict<DateType extends Date>(
|
103 |
+
date: DateType | number | string,
|
104 |
+
baseDate: DateType | number | string,
|
105 |
+
options?: FormatDistanceStrictOptions,
|
106 |
+
): string;
|
workers1/auto3d/node_modules/date-fns/formatDistanceStrict.js
ADDED
@@ -0,0 +1,196 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"use strict";
|
2 |
+
exports.formatDistanceStrict = formatDistanceStrict;
|
3 |
+
var _index = require("./_lib/defaultLocale.js");
|
4 |
+
var _index2 = require("./_lib/defaultOptions.js");
|
5 |
+
var _index3 = require("./_lib/getRoundingMethod.js");
|
6 |
+
var _index4 = require("./_lib/getTimezoneOffsetInMilliseconds.js");
|
7 |
+
var _index5 = require("./compareAsc.js");
|
8 |
+
var _index6 = require("./constants.js");
|
9 |
+
|
10 |
+
var _index7 = require("./toDate.js");
|
11 |
+
|
12 |
+
/**
|
13 |
+
* The {@link formatDistanceStrict} function options.
|
14 |
+
*/
|
15 |
+
|
16 |
+
/**
|
17 |
+
* The unit used to format the distance in {@link formatDistanceStrict}.
|
18 |
+
*/
|
19 |
+
|
20 |
+
/**
|
21 |
+
* @name formatDistanceStrict
|
22 |
+
* @category Common Helpers
|
23 |
+
* @summary Return the distance between the given dates in words.
|
24 |
+
*
|
25 |
+
* @description
|
26 |
+
* Return the distance between the given dates in words, using strict units.
|
27 |
+
* This is like `formatDistance`, but does not use helpers like 'almost', 'over',
|
28 |
+
* 'less than' and the like.
|
29 |
+
*
|
30 |
+
* | Distance between dates | Result |
|
31 |
+
* |------------------------|---------------------|
|
32 |
+
* | 0 ... 59 secs | [0..59] seconds |
|
33 |
+
* | 1 ... 59 mins | [1..59] minutes |
|
34 |
+
* | 1 ... 23 hrs | [1..23] hours |
|
35 |
+
* | 1 ... 29 days | [1..29] days |
|
36 |
+
* | 1 ... 11 months | [1..11] months |
|
37 |
+
* | 1 ... N years | [1..N] years |
|
38 |
+
*
|
39 |
+
* @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
|
40 |
+
*
|
41 |
+
* @param date - The date
|
42 |
+
* @param baseDate - The date to compare with
|
43 |
+
* @param options - An object with options
|
44 |
+
*
|
45 |
+
* @returns The distance in words
|
46 |
+
*
|
47 |
+
* @throws `date` must not be Invalid Date
|
48 |
+
* @throws `baseDate` must not be Invalid Date
|
49 |
+
* @throws `options.unit` must be 'second', 'minute', 'hour', 'day', 'month' or 'year'
|
50 |
+
* @throws `options.locale` must contain `formatDistance` property
|
51 |
+
*
|
52 |
+
* @example
|
53 |
+
* // What is the distance between 2 July 2014 and 1 January 2015?
|
54 |
+
* const result = formatDistanceStrict(new Date(2014, 6, 2), new Date(2015, 0, 2))
|
55 |
+
* //=> '6 months'
|
56 |
+
*
|
57 |
+
* @example
|
58 |
+
* // What is the distance between 1 January 2015 00:00:15
|
59 |
+
* // and 1 January 2015 00:00:00?
|
60 |
+
* const result = formatDistanceStrict(
|
61 |
+
* new Date(2015, 0, 1, 0, 0, 15),
|
62 |
+
* new Date(2015, 0, 1, 0, 0, 0)
|
63 |
+
* )
|
64 |
+
* //=> '15 seconds'
|
65 |
+
*
|
66 |
+
* @example
|
67 |
+
* // What is the distance from 1 January 2016
|
68 |
+
* // to 1 January 2015, with a suffix?
|
69 |
+
* const result = formatDistanceStrict(new Date(2015, 0, 1), new Date(2016, 0, 1), {
|
70 |
+
* addSuffix: true
|
71 |
+
* })
|
72 |
+
* //=> '1 year ago'
|
73 |
+
*
|
74 |
+
* @example
|
75 |
+
* // What is the distance from 1 January 2016
|
76 |
+
* // to 1 January 2015, in minutes?
|
77 |
+
* const result = formatDistanceStrict(new Date(2016, 0, 1), new Date(2015, 0, 1), {
|
78 |
+
* unit: 'minute'
|
79 |
+
* })
|
80 |
+
* //=> '525600 minutes'
|
81 |
+
*
|
82 |
+
* @example
|
83 |
+
* // What is the distance from 1 January 2015
|
84 |
+
* // to 28 January 2015, in months, rounded up?
|
85 |
+
* const result = formatDistanceStrict(new Date(2015, 0, 28), new Date(2015, 0, 1), {
|
86 |
+
* unit: 'month',
|
87 |
+
* roundingMethod: 'ceil'
|
88 |
+
* })
|
89 |
+
* //=> '1 month'
|
90 |
+
*
|
91 |
+
* @example
|
92 |
+
* // What is the distance between 1 August 2016 and 1 January 2015 in Esperanto?
|
93 |
+
* import { eoLocale } from 'date-fns/locale/eo'
|
94 |
+
* const result = formatDistanceStrict(new Date(2016, 7, 1), new Date(2015, 0, 1), {
|
95 |
+
* locale: eoLocale
|
96 |
+
* })
|
97 |
+
* //=> '1 jaro'
|
98 |
+
*/
|
99 |
+
|
100 |
+
function formatDistanceStrict(date, baseDate, options) {
|
101 |
+
const defaultOptions = (0, _index2.getDefaultOptions)();
|
102 |
+
const locale =
|
103 |
+
options?.locale ?? defaultOptions.locale ?? _index.defaultLocale;
|
104 |
+
|
105 |
+
const comparison = (0, _index5.compareAsc)(date, baseDate);
|
106 |
+
|
107 |
+
if (isNaN(comparison)) {
|
108 |
+
throw new RangeError("Invalid time value");
|
109 |
+
}
|
110 |
+
|
111 |
+
const localizeOptions = Object.assign({}, options, {
|
112 |
+
addSuffix: options?.addSuffix,
|
113 |
+
comparison: comparison,
|
114 |
+
});
|
115 |
+
|
116 |
+
let dateLeft;
|
117 |
+
let dateRight;
|
118 |
+
if (comparison > 0) {
|
119 |
+
dateLeft = (0, _index7.toDate)(baseDate);
|
120 |
+
dateRight = (0, _index7.toDate)(date);
|
121 |
+
} else {
|
122 |
+
dateLeft = (0, _index7.toDate)(date);
|
123 |
+
dateRight = (0, _index7.toDate)(baseDate);
|
124 |
+
}
|
125 |
+
|
126 |
+
const roundingMethod = (0, _index3.getRoundingMethod)(
|
127 |
+
options?.roundingMethod ?? "round",
|
128 |
+
);
|
129 |
+
|
130 |
+
const milliseconds = dateRight.getTime() - dateLeft.getTime();
|
131 |
+
const minutes = milliseconds / _index6.millisecondsInMinute;
|
132 |
+
|
133 |
+
const timezoneOffset =
|
134 |
+
(0, _index4.getTimezoneOffsetInMilliseconds)(dateRight) -
|
135 |
+
(0, _index4.getTimezoneOffsetInMilliseconds)(dateLeft);
|
136 |
+
|
137 |
+
// Use DST-normalized difference in minutes for years, months and days;
|
138 |
+
// use regular difference in minutes for hours, minutes and seconds.
|
139 |
+
const dstNormalizedMinutes =
|
140 |
+
(milliseconds - timezoneOffset) / _index6.millisecondsInMinute;
|
141 |
+
|
142 |
+
const defaultUnit = options?.unit;
|
143 |
+
let unit;
|
144 |
+
if (!defaultUnit) {
|
145 |
+
if (minutes < 1) {
|
146 |
+
unit = "second";
|
147 |
+
} else if (minutes < 60) {
|
148 |
+
unit = "minute";
|
149 |
+
} else if (minutes < _index6.minutesInDay) {
|
150 |
+
unit = "hour";
|
151 |
+
} else if (dstNormalizedMinutes < _index6.minutesInMonth) {
|
152 |
+
unit = "day";
|
153 |
+
} else if (dstNormalizedMinutes < _index6.minutesInYear) {
|
154 |
+
unit = "month";
|
155 |
+
} else {
|
156 |
+
unit = "year";
|
157 |
+
}
|
158 |
+
} else {
|
159 |
+
unit = defaultUnit;
|
160 |
+
}
|
161 |
+
|
162 |
+
// 0 up to 60 seconds
|
163 |
+
if (unit === "second") {
|
164 |
+
const seconds = roundingMethod(milliseconds / 1000);
|
165 |
+
return locale.formatDistance("xSeconds", seconds, localizeOptions);
|
166 |
+
|
167 |
+
// 1 up to 60 mins
|
168 |
+
} else if (unit === "minute") {
|
169 |
+
const roundedMinutes = roundingMethod(minutes);
|
170 |
+
return locale.formatDistance("xMinutes", roundedMinutes, localizeOptions);
|
171 |
+
|
172 |
+
// 1 up to 24 hours
|
173 |
+
} else if (unit === "hour") {
|
174 |
+
const hours = roundingMethod(minutes / 60);
|
175 |
+
return locale.formatDistance("xHours", hours, localizeOptions);
|
176 |
+
|
177 |
+
// 1 up to 30 days
|
178 |
+
} else if (unit === "day") {
|
179 |
+
const days = roundingMethod(dstNormalizedMinutes / _index6.minutesInDay);
|
180 |
+
return locale.formatDistance("xDays", days, localizeOptions);
|
181 |
+
|
182 |
+
// 1 up to 12 months
|
183 |
+
} else if (unit === "month") {
|
184 |
+
const months = roundingMethod(
|
185 |
+
dstNormalizedMinutes / _index6.minutesInMonth,
|
186 |
+
);
|
187 |
+
return months === 12 && defaultUnit !== "month"
|
188 |
+
? locale.formatDistance("xYears", 1, localizeOptions)
|
189 |
+
: locale.formatDistance("xMonths", months, localizeOptions);
|
190 |
+
|
191 |
+
// 1 year up to max Date
|
192 |
+
} else {
|
193 |
+
const years = roundingMethod(dstNormalizedMinutes / _index6.minutesInYear);
|
194 |
+
return locale.formatDistance("xYears", years, localizeOptions);
|
195 |
+
}
|
196 |
+
}
|
workers1/auto3d/node_modules/date-fns/formatDistanceStrict.mjs
ADDED
@@ -0,0 +1,196 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { defaultLocale } from "./_lib/defaultLocale.mjs";
|
2 |
+
import { getDefaultOptions } from "./_lib/defaultOptions.mjs";
|
3 |
+
import { getRoundingMethod } from "./_lib/getRoundingMethod.mjs";
|
4 |
+
import { getTimezoneOffsetInMilliseconds } from "./_lib/getTimezoneOffsetInMilliseconds.mjs";
|
5 |
+
import { compareAsc } from "./compareAsc.mjs";
|
6 |
+
import {
|
7 |
+
millisecondsInMinute,
|
8 |
+
minutesInDay,
|
9 |
+
minutesInMonth,
|
10 |
+
minutesInYear,
|
11 |
+
} from "./constants.mjs";
|
12 |
+
import { toDate } from "./toDate.mjs";
|
13 |
+
|
14 |
+
/**
|
15 |
+
* The {@link formatDistanceStrict} function options.
|
16 |
+
*/
|
17 |
+
|
18 |
+
/**
|
19 |
+
* The unit used to format the distance in {@link formatDistanceStrict}.
|
20 |
+
*/
|
21 |
+
|
22 |
+
/**
|
23 |
+
* @name formatDistanceStrict
|
24 |
+
* @category Common Helpers
|
25 |
+
* @summary Return the distance between the given dates in words.
|
26 |
+
*
|
27 |
+
* @description
|
28 |
+
* Return the distance between the given dates in words, using strict units.
|
29 |
+
* This is like `formatDistance`, but does not use helpers like 'almost', 'over',
|
30 |
+
* 'less than' and the like.
|
31 |
+
*
|
32 |
+
* | Distance between dates | Result |
|
33 |
+
* |------------------------|---------------------|
|
34 |
+
* | 0 ... 59 secs | [0..59] seconds |
|
35 |
+
* | 1 ... 59 mins | [1..59] minutes |
|
36 |
+
* | 1 ... 23 hrs | [1..23] hours |
|
37 |
+
* | 1 ... 29 days | [1..29] days |
|
38 |
+
* | 1 ... 11 months | [1..11] months |
|
39 |
+
* | 1 ... N years | [1..N] years |
|
40 |
+
*
|
41 |
+
* @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
|
42 |
+
*
|
43 |
+
* @param date - The date
|
44 |
+
* @param baseDate - The date to compare with
|
45 |
+
* @param options - An object with options
|
46 |
+
*
|
47 |
+
* @returns The distance in words
|
48 |
+
*
|
49 |
+
* @throws `date` must not be Invalid Date
|
50 |
+
* @throws `baseDate` must not be Invalid Date
|
51 |
+
* @throws `options.unit` must be 'second', 'minute', 'hour', 'day', 'month' or 'year'
|
52 |
+
* @throws `options.locale` must contain `formatDistance` property
|
53 |
+
*
|
54 |
+
* @example
|
55 |
+
* // What is the distance between 2 July 2014 and 1 January 2015?
|
56 |
+
* const result = formatDistanceStrict(new Date(2014, 6, 2), new Date(2015, 0, 2))
|
57 |
+
* //=> '6 months'
|
58 |
+
*
|
59 |
+
* @example
|
60 |
+
* // What is the distance between 1 January 2015 00:00:15
|
61 |
+
* // and 1 January 2015 00:00:00?
|
62 |
+
* const result = formatDistanceStrict(
|
63 |
+
* new Date(2015, 0, 1, 0, 0, 15),
|
64 |
+
* new Date(2015, 0, 1, 0, 0, 0)
|
65 |
+
* )
|
66 |
+
* //=> '15 seconds'
|
67 |
+
*
|
68 |
+
* @example
|
69 |
+
* // What is the distance from 1 January 2016
|
70 |
+
* // to 1 January 2015, with a suffix?
|
71 |
+
* const result = formatDistanceStrict(new Date(2015, 0, 1), new Date(2016, 0, 1), {
|
72 |
+
* addSuffix: true
|
73 |
+
* })
|
74 |
+
* //=> '1 year ago'
|
75 |
+
*
|
76 |
+
* @example
|
77 |
+
* // What is the distance from 1 January 2016
|
78 |
+
* // to 1 January 2015, in minutes?
|
79 |
+
* const result = formatDistanceStrict(new Date(2016, 0, 1), new Date(2015, 0, 1), {
|
80 |
+
* unit: 'minute'
|
81 |
+
* })
|
82 |
+
* //=> '525600 minutes'
|
83 |
+
*
|
84 |
+
* @example
|
85 |
+
* // What is the distance from 1 January 2015
|
86 |
+
* // to 28 January 2015, in months, rounded up?
|
87 |
+
* const result = formatDistanceStrict(new Date(2015, 0, 28), new Date(2015, 0, 1), {
|
88 |
+
* unit: 'month',
|
89 |
+
* roundingMethod: 'ceil'
|
90 |
+
* })
|
91 |
+
* //=> '1 month'
|
92 |
+
*
|
93 |
+
* @example
|
94 |
+
* // What is the distance between 1 August 2016 and 1 January 2015 in Esperanto?
|
95 |
+
* import { eoLocale } from 'date-fns/locale/eo'
|
96 |
+
* const result = formatDistanceStrict(new Date(2016, 7, 1), new Date(2015, 0, 1), {
|
97 |
+
* locale: eoLocale
|
98 |
+
* })
|
99 |
+
* //=> '1 jaro'
|
100 |
+
*/
|
101 |
+
|
102 |
+
export function formatDistanceStrict(date, baseDate, options) {
|
103 |
+
const defaultOptions = getDefaultOptions();
|
104 |
+
const locale = options?.locale ?? defaultOptions.locale ?? defaultLocale;
|
105 |
+
|
106 |
+
const comparison = compareAsc(date, baseDate);
|
107 |
+
|
108 |
+
if (isNaN(comparison)) {
|
109 |
+
throw new RangeError("Invalid time value");
|
110 |
+
}
|
111 |
+
|
112 |
+
const localizeOptions = Object.assign({}, options, {
|
113 |
+
addSuffix: options?.addSuffix,
|
114 |
+
comparison: comparison,
|
115 |
+
});
|
116 |
+
|
117 |
+
let dateLeft;
|
118 |
+
let dateRight;
|
119 |
+
if (comparison > 0) {
|
120 |
+
dateLeft = toDate(baseDate);
|
121 |
+
dateRight = toDate(date);
|
122 |
+
} else {
|
123 |
+
dateLeft = toDate(date);
|
124 |
+
dateRight = toDate(baseDate);
|
125 |
+
}
|
126 |
+
|
127 |
+
const roundingMethod = getRoundingMethod(options?.roundingMethod ?? "round");
|
128 |
+
|
129 |
+
const milliseconds = dateRight.getTime() - dateLeft.getTime();
|
130 |
+
const minutes = milliseconds / millisecondsInMinute;
|
131 |
+
|
132 |
+
const timezoneOffset =
|
133 |
+
getTimezoneOffsetInMilliseconds(dateRight) -
|
134 |
+
getTimezoneOffsetInMilliseconds(dateLeft);
|
135 |
+
|
136 |
+
// Use DST-normalized difference in minutes for years, months and days;
|
137 |
+
// use regular difference in minutes for hours, minutes and seconds.
|
138 |
+
const dstNormalizedMinutes =
|
139 |
+
(milliseconds - timezoneOffset) / millisecondsInMinute;
|
140 |
+
|
141 |
+
const defaultUnit = options?.unit;
|
142 |
+
let unit;
|
143 |
+
if (!defaultUnit) {
|
144 |
+
if (minutes < 1) {
|
145 |
+
unit = "second";
|
146 |
+
} else if (minutes < 60) {
|
147 |
+
unit = "minute";
|
148 |
+
} else if (minutes < minutesInDay) {
|
149 |
+
unit = "hour";
|
150 |
+
} else if (dstNormalizedMinutes < minutesInMonth) {
|
151 |
+
unit = "day";
|
152 |
+
} else if (dstNormalizedMinutes < minutesInYear) {
|
153 |
+
unit = "month";
|
154 |
+
} else {
|
155 |
+
unit = "year";
|
156 |
+
}
|
157 |
+
} else {
|
158 |
+
unit = defaultUnit;
|
159 |
+
}
|
160 |
+
|
161 |
+
// 0 up to 60 seconds
|
162 |
+
if (unit === "second") {
|
163 |
+
const seconds = roundingMethod(milliseconds / 1000);
|
164 |
+
return locale.formatDistance("xSeconds", seconds, localizeOptions);
|
165 |
+
|
166 |
+
// 1 up to 60 mins
|
167 |
+
} else if (unit === "minute") {
|
168 |
+
const roundedMinutes = roundingMethod(minutes);
|
169 |
+
return locale.formatDistance("xMinutes", roundedMinutes, localizeOptions);
|
170 |
+
|
171 |
+
// 1 up to 24 hours
|
172 |
+
} else if (unit === "hour") {
|
173 |
+
const hours = roundingMethod(minutes / 60);
|
174 |
+
return locale.formatDistance("xHours", hours, localizeOptions);
|
175 |
+
|
176 |
+
// 1 up to 30 days
|
177 |
+
} else if (unit === "day") {
|
178 |
+
const days = roundingMethod(dstNormalizedMinutes / minutesInDay);
|
179 |
+
return locale.formatDistance("xDays", days, localizeOptions);
|
180 |
+
|
181 |
+
// 1 up to 12 months
|
182 |
+
} else if (unit === "month") {
|
183 |
+
const months = roundingMethod(dstNormalizedMinutes / minutesInMonth);
|
184 |
+
return months === 12 && defaultUnit !== "month"
|
185 |
+
? locale.formatDistance("xYears", 1, localizeOptions)
|
186 |
+
: locale.formatDistance("xMonths", months, localizeOptions);
|
187 |
+
|
188 |
+
// 1 year up to max Date
|
189 |
+
} else {
|
190 |
+
const years = roundingMethod(dstNormalizedMinutes / minutesInYear);
|
191 |
+
return locale.formatDistance("xYears", years, localizeOptions);
|
192 |
+
}
|
193 |
+
}
|
194 |
+
|
195 |
+
// Fallback for modularized imports:
|
196 |
+
export default formatDistanceStrict;
|
workers1/auto3d/node_modules/date-fns/formatDistanceToNow.d.mts
ADDED
@@ -0,0 +1,92 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import type { FormatDistanceOptions } from "./formatDistance.js";
|
2 |
+
/**
|
3 |
+
* The {@link formatDistanceToNow} function options.
|
4 |
+
*/
|
5 |
+
export interface FormatDistanceToNowOptions extends FormatDistanceOptions {}
|
6 |
+
/**
|
7 |
+
* @name formatDistanceToNow
|
8 |
+
* @category Common Helpers
|
9 |
+
* @summary Return the distance between the given date and now in words.
|
10 |
+
* @pure false
|
11 |
+
*
|
12 |
+
* @description
|
13 |
+
* Return the distance between the given date and now in words.
|
14 |
+
*
|
15 |
+
* | Distance to now | Result |
|
16 |
+
* |-------------------------------------------------------------------|---------------------|
|
17 |
+
* | 0 ... 30 secs | less than a minute |
|
18 |
+
* | 30 secs ... 1 min 30 secs | 1 minute |
|
19 |
+
* | 1 min 30 secs ... 44 mins 30 secs | [2..44] minutes |
|
20 |
+
* | 44 mins ... 30 secs ... 89 mins 30 secs | about 1 hour |
|
21 |
+
* | 89 mins 30 secs ... 23 hrs 59 mins 30 secs | about [2..24] hours |
|
22 |
+
* | 23 hrs 59 mins 30 secs ... 41 hrs 59 mins 30 secs | 1 day |
|
23 |
+
* | 41 hrs 59 mins 30 secs ... 29 days 23 hrs 59 mins 30 secs | [2..30] days |
|
24 |
+
* | 29 days 23 hrs 59 mins 30 secs ... 44 days 23 hrs 59 mins 30 secs | about 1 month |
|
25 |
+
* | 44 days 23 hrs 59 mins 30 secs ... 59 days 23 hrs 59 mins 30 secs | about 2 months |
|
26 |
+
* | 59 days 23 hrs 59 mins 30 secs ... 1 yr | [2..12] months |
|
27 |
+
* | 1 yr ... 1 yr 3 months | about 1 year |
|
28 |
+
* | 1 yr 3 months ... 1 yr 9 month s | over 1 year |
|
29 |
+
* | 1 yr 9 months ... 2 yrs | almost 2 years |
|
30 |
+
* | N yrs ... N yrs 3 months | about N years |
|
31 |
+
* | N yrs 3 months ... N yrs 9 months | over N years |
|
32 |
+
* | N yrs 9 months ... N+1 yrs | almost N+1 years |
|
33 |
+
*
|
34 |
+
* With `options.includeSeconds == true`:
|
35 |
+
* | Distance to now | Result |
|
36 |
+
* |---------------------|----------------------|
|
37 |
+
* | 0 secs ... 5 secs | less than 5 seconds |
|
38 |
+
* | 5 secs ... 10 secs | less than 10 seconds |
|
39 |
+
* | 10 secs ... 20 secs | less than 20 seconds |
|
40 |
+
* | 20 secs ... 40 secs | half a minute |
|
41 |
+
* | 40 secs ... 60 secs | less than a minute |
|
42 |
+
* | 60 secs ... 90 secs | 1 minute |
|
43 |
+
*
|
44 |
+
* @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
|
45 |
+
*
|
46 |
+
* @param date - The given date
|
47 |
+
* @param options - The object with options
|
48 |
+
*
|
49 |
+
* @returns The distance in words
|
50 |
+
*
|
51 |
+
* @throws `date` must not be Invalid Date
|
52 |
+
* @throws `options.locale` must contain `formatDistance` property
|
53 |
+
*
|
54 |
+
* @example
|
55 |
+
* // If today is 1 January 2015, what is the distance to 2 July 2014?
|
56 |
+
* const result = formatDistanceToNow(
|
57 |
+
* new Date(2014, 6, 2)
|
58 |
+
* )
|
59 |
+
* //=> '6 months'
|
60 |
+
*
|
61 |
+
* @example
|
62 |
+
* // If now is 1 January 2015 00:00:00,
|
63 |
+
* // what is the distance to 1 January 2015 00:00:15, including seconds?
|
64 |
+
* const result = formatDistanceToNow(
|
65 |
+
* new Date(2015, 0, 1, 0, 0, 15),
|
66 |
+
* {includeSeconds: true}
|
67 |
+
* )
|
68 |
+
* //=> 'less than 20 seconds'
|
69 |
+
*
|
70 |
+
* @example
|
71 |
+
* // If today is 1 January 2015,
|
72 |
+
* // what is the distance to 1 January 2016, with a suffix?
|
73 |
+
* const result = formatDistanceToNow(
|
74 |
+
* new Date(2016, 0, 1),
|
75 |
+
* {addSuffix: true}
|
76 |
+
* )
|
77 |
+
* //=> 'in about 1 year'
|
78 |
+
*
|
79 |
+
* @example
|
80 |
+
* // If today is 1 January 2015,
|
81 |
+
* // what is the distance to 1 August 2016 in Esperanto?
|
82 |
+
* const eoLocale = require('date-fns/locale/eo')
|
83 |
+
* const result = formatDistanceToNow(
|
84 |
+
* new Date(2016, 7, 1),
|
85 |
+
* {locale: eoLocale}
|
86 |
+
* )
|
87 |
+
* //=> 'pli ol 1 jaro'
|
88 |
+
*/
|
89 |
+
export declare function formatDistanceToNow<DateType extends Date>(
|
90 |
+
date: DateType | number | string,
|
91 |
+
options?: FormatDistanceToNowOptions,
|
92 |
+
): string;
|
workers1/auto3d/node_modules/date-fns/formatDistanceToNow.d.ts
ADDED
@@ -0,0 +1,92 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import type { FormatDistanceOptions } from "./formatDistance.js";
|
2 |
+
/**
|
3 |
+
* The {@link formatDistanceToNow} function options.
|
4 |
+
*/
|
5 |
+
export interface FormatDistanceToNowOptions extends FormatDistanceOptions {}
|
6 |
+
/**
|
7 |
+
* @name formatDistanceToNow
|
8 |
+
* @category Common Helpers
|
9 |
+
* @summary Return the distance between the given date and now in words.
|
10 |
+
* @pure false
|
11 |
+
*
|
12 |
+
* @description
|
13 |
+
* Return the distance between the given date and now in words.
|
14 |
+
*
|
15 |
+
* | Distance to now | Result |
|
16 |
+
* |-------------------------------------------------------------------|---------------------|
|
17 |
+
* | 0 ... 30 secs | less than a minute |
|
18 |
+
* | 30 secs ... 1 min 30 secs | 1 minute |
|
19 |
+
* | 1 min 30 secs ... 44 mins 30 secs | [2..44] minutes |
|
20 |
+
* | 44 mins ... 30 secs ... 89 mins 30 secs | about 1 hour |
|
21 |
+
* | 89 mins 30 secs ... 23 hrs 59 mins 30 secs | about [2..24] hours |
|
22 |
+
* | 23 hrs 59 mins 30 secs ... 41 hrs 59 mins 30 secs | 1 day |
|
23 |
+
* | 41 hrs 59 mins 30 secs ... 29 days 23 hrs 59 mins 30 secs | [2..30] days |
|
24 |
+
* | 29 days 23 hrs 59 mins 30 secs ... 44 days 23 hrs 59 mins 30 secs | about 1 month |
|
25 |
+
* | 44 days 23 hrs 59 mins 30 secs ... 59 days 23 hrs 59 mins 30 secs | about 2 months |
|
26 |
+
* | 59 days 23 hrs 59 mins 30 secs ... 1 yr | [2..12] months |
|
27 |
+
* | 1 yr ... 1 yr 3 months | about 1 year |
|
28 |
+
* | 1 yr 3 months ... 1 yr 9 month s | over 1 year |
|
29 |
+
* | 1 yr 9 months ... 2 yrs | almost 2 years |
|
30 |
+
* | N yrs ... N yrs 3 months | about N years |
|
31 |
+
* | N yrs 3 months ... N yrs 9 months | over N years |
|
32 |
+
* | N yrs 9 months ... N+1 yrs | almost N+1 years |
|
33 |
+
*
|
34 |
+
* With `options.includeSeconds == true`:
|
35 |
+
* | Distance to now | Result |
|
36 |
+
* |---------------------|----------------------|
|
37 |
+
* | 0 secs ... 5 secs | less than 5 seconds |
|
38 |
+
* | 5 secs ... 10 secs | less than 10 seconds |
|
39 |
+
* | 10 secs ... 20 secs | less than 20 seconds |
|
40 |
+
* | 20 secs ... 40 secs | half a minute |
|
41 |
+
* | 40 secs ... 60 secs | less than a minute |
|
42 |
+
* | 60 secs ... 90 secs | 1 minute |
|
43 |
+
*
|
44 |
+
* @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
|
45 |
+
*
|
46 |
+
* @param date - The given date
|
47 |
+
* @param options - The object with options
|
48 |
+
*
|
49 |
+
* @returns The distance in words
|
50 |
+
*
|
51 |
+
* @throws `date` must not be Invalid Date
|
52 |
+
* @throws `options.locale` must contain `formatDistance` property
|
53 |
+
*
|
54 |
+
* @example
|
55 |
+
* // If today is 1 January 2015, what is the distance to 2 July 2014?
|
56 |
+
* const result = formatDistanceToNow(
|
57 |
+
* new Date(2014, 6, 2)
|
58 |
+
* )
|
59 |
+
* //=> '6 months'
|
60 |
+
*
|
61 |
+
* @example
|
62 |
+
* // If now is 1 January 2015 00:00:00,
|
63 |
+
* // what is the distance to 1 January 2015 00:00:15, including seconds?
|
64 |
+
* const result = formatDistanceToNow(
|
65 |
+
* new Date(2015, 0, 1, 0, 0, 15),
|
66 |
+
* {includeSeconds: true}
|
67 |
+
* )
|
68 |
+
* //=> 'less than 20 seconds'
|
69 |
+
*
|
70 |
+
* @example
|
71 |
+
* // If today is 1 January 2015,
|
72 |
+
* // what is the distance to 1 January 2016, with a suffix?
|
73 |
+
* const result = formatDistanceToNow(
|
74 |
+
* new Date(2016, 0, 1),
|
75 |
+
* {addSuffix: true}
|
76 |
+
* )
|
77 |
+
* //=> 'in about 1 year'
|
78 |
+
*
|
79 |
+
* @example
|
80 |
+
* // If today is 1 January 2015,
|
81 |
+
* // what is the distance to 1 August 2016 in Esperanto?
|
82 |
+
* const eoLocale = require('date-fns/locale/eo')
|
83 |
+
* const result = formatDistanceToNow(
|
84 |
+
* new Date(2016, 7, 1),
|
85 |
+
* {locale: eoLocale}
|
86 |
+
* )
|
87 |
+
* //=> 'pli ol 1 jaro'
|
88 |
+
*/
|
89 |
+
export declare function formatDistanceToNow<DateType extends Date>(
|
90 |
+
date: DateType | number | string,
|
91 |
+
options?: FormatDistanceToNowOptions,
|
92 |
+
): string;
|
workers1/auto3d/node_modules/date-fns/formatDistanceToNow.js
ADDED
@@ -0,0 +1,100 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"use strict";
|
2 |
+
exports.formatDistanceToNow = formatDistanceToNow;
|
3 |
+
var _index = require("./constructNow.js");
|
4 |
+
|
5 |
+
var _index2 = require("./formatDistance.js");
|
6 |
+
|
7 |
+
/**
|
8 |
+
* The {@link formatDistanceToNow} function options.
|
9 |
+
*/
|
10 |
+
|
11 |
+
/**
|
12 |
+
* @name formatDistanceToNow
|
13 |
+
* @category Common Helpers
|
14 |
+
* @summary Return the distance between the given date and now in words.
|
15 |
+
* @pure false
|
16 |
+
*
|
17 |
+
* @description
|
18 |
+
* Return the distance between the given date and now in words.
|
19 |
+
*
|
20 |
+
* | Distance to now | Result |
|
21 |
+
* |-------------------------------------------------------------------|---------------------|
|
22 |
+
* | 0 ... 30 secs | less than a minute |
|
23 |
+
* | 30 secs ... 1 min 30 secs | 1 minute |
|
24 |
+
* | 1 min 30 secs ... 44 mins 30 secs | [2..44] minutes |
|
25 |
+
* | 44 mins ... 30 secs ... 89 mins 30 secs | about 1 hour |
|
26 |
+
* | 89 mins 30 secs ... 23 hrs 59 mins 30 secs | about [2..24] hours |
|
27 |
+
* | 23 hrs 59 mins 30 secs ... 41 hrs 59 mins 30 secs | 1 day |
|
28 |
+
* | 41 hrs 59 mins 30 secs ... 29 days 23 hrs 59 mins 30 secs | [2..30] days |
|
29 |
+
* | 29 days 23 hrs 59 mins 30 secs ... 44 days 23 hrs 59 mins 30 secs | about 1 month |
|
30 |
+
* | 44 days 23 hrs 59 mins 30 secs ... 59 days 23 hrs 59 mins 30 secs | about 2 months |
|
31 |
+
* | 59 days 23 hrs 59 mins 30 secs ... 1 yr | [2..12] months |
|
32 |
+
* | 1 yr ... 1 yr 3 months | about 1 year |
|
33 |
+
* | 1 yr 3 months ... 1 yr 9 month s | over 1 year |
|
34 |
+
* | 1 yr 9 months ... 2 yrs | almost 2 years |
|
35 |
+
* | N yrs ... N yrs 3 months | about N years |
|
36 |
+
* | N yrs 3 months ... N yrs 9 months | over N years |
|
37 |
+
* | N yrs 9 months ... N+1 yrs | almost N+1 years |
|
38 |
+
*
|
39 |
+
* With `options.includeSeconds == true`:
|
40 |
+
* | Distance to now | Result |
|
41 |
+
* |---------------------|----------------------|
|
42 |
+
* | 0 secs ... 5 secs | less than 5 seconds |
|
43 |
+
* | 5 secs ... 10 secs | less than 10 seconds |
|
44 |
+
* | 10 secs ... 20 secs | less than 20 seconds |
|
45 |
+
* | 20 secs ... 40 secs | half a minute |
|
46 |
+
* | 40 secs ... 60 secs | less than a minute |
|
47 |
+
* | 60 secs ... 90 secs | 1 minute |
|
48 |
+
*
|
49 |
+
* @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
|
50 |
+
*
|
51 |
+
* @param date - The given date
|
52 |
+
* @param options - The object with options
|
53 |
+
*
|
54 |
+
* @returns The distance in words
|
55 |
+
*
|
56 |
+
* @throws `date` must not be Invalid Date
|
57 |
+
* @throws `options.locale` must contain `formatDistance` property
|
58 |
+
*
|
59 |
+
* @example
|
60 |
+
* // If today is 1 January 2015, what is the distance to 2 July 2014?
|
61 |
+
* const result = formatDistanceToNow(
|
62 |
+
* new Date(2014, 6, 2)
|
63 |
+
* )
|
64 |
+
* //=> '6 months'
|
65 |
+
*
|
66 |
+
* @example
|
67 |
+
* // If now is 1 January 2015 00:00:00,
|
68 |
+
* // what is the distance to 1 January 2015 00:00:15, including seconds?
|
69 |
+
* const result = formatDistanceToNow(
|
70 |
+
* new Date(2015, 0, 1, 0, 0, 15),
|
71 |
+
* {includeSeconds: true}
|
72 |
+
* )
|
73 |
+
* //=> 'less than 20 seconds'
|
74 |
+
*
|
75 |
+
* @example
|
76 |
+
* // If today is 1 January 2015,
|
77 |
+
* // what is the distance to 1 January 2016, with a suffix?
|
78 |
+
* const result = formatDistanceToNow(
|
79 |
+
* new Date(2016, 0, 1),
|
80 |
+
* {addSuffix: true}
|
81 |
+
* )
|
82 |
+
* //=> 'in about 1 year'
|
83 |
+
*
|
84 |
+
* @example
|
85 |
+
* // If today is 1 January 2015,
|
86 |
+
* // what is the distance to 1 August 2016 in Esperanto?
|
87 |
+
* const eoLocale = require('date-fns/locale/eo')
|
88 |
+
* const result = formatDistanceToNow(
|
89 |
+
* new Date(2016, 7, 1),
|
90 |
+
* {locale: eoLocale}
|
91 |
+
* )
|
92 |
+
* //=> 'pli ol 1 jaro'
|
93 |
+
*/
|
94 |
+
function formatDistanceToNow(date, options) {
|
95 |
+
return (0, _index2.formatDistance)(
|
96 |
+
date,
|
97 |
+
(0, _index.constructNow)(date),
|
98 |
+
options,
|
99 |
+
);
|
100 |
+
}
|
workers1/auto3d/node_modules/date-fns/formatDistanceToNow.mjs
ADDED
@@ -0,0 +1,96 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { constructNow } from "./constructNow.mjs";
|
2 |
+
import { formatDistance } from "./formatDistance.mjs";
|
3 |
+
|
4 |
+
/**
|
5 |
+
* The {@link formatDistanceToNow} function options.
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* @name formatDistanceToNow
|
10 |
+
* @category Common Helpers
|
11 |
+
* @summary Return the distance between the given date and now in words.
|
12 |
+
* @pure false
|
13 |
+
*
|
14 |
+
* @description
|
15 |
+
* Return the distance between the given date and now in words.
|
16 |
+
*
|
17 |
+
* | Distance to now | Result |
|
18 |
+
* |-------------------------------------------------------------------|---------------------|
|
19 |
+
* | 0 ... 30 secs | less than a minute |
|
20 |
+
* | 30 secs ... 1 min 30 secs | 1 minute |
|
21 |
+
* | 1 min 30 secs ... 44 mins 30 secs | [2..44] minutes |
|
22 |
+
* | 44 mins ... 30 secs ... 89 mins 30 secs | about 1 hour |
|
23 |
+
* | 89 mins 30 secs ... 23 hrs 59 mins 30 secs | about [2..24] hours |
|
24 |
+
* | 23 hrs 59 mins 30 secs ... 41 hrs 59 mins 30 secs | 1 day |
|
25 |
+
* | 41 hrs 59 mins 30 secs ... 29 days 23 hrs 59 mins 30 secs | [2..30] days |
|
26 |
+
* | 29 days 23 hrs 59 mins 30 secs ... 44 days 23 hrs 59 mins 30 secs | about 1 month |
|
27 |
+
* | 44 days 23 hrs 59 mins 30 secs ... 59 days 23 hrs 59 mins 30 secs | about 2 months |
|
28 |
+
* | 59 days 23 hrs 59 mins 30 secs ... 1 yr | [2..12] months |
|
29 |
+
* | 1 yr ... 1 yr 3 months | about 1 year |
|
30 |
+
* | 1 yr 3 months ... 1 yr 9 month s | over 1 year |
|
31 |
+
* | 1 yr 9 months ... 2 yrs | almost 2 years |
|
32 |
+
* | N yrs ... N yrs 3 months | about N years |
|
33 |
+
* | N yrs 3 months ... N yrs 9 months | over N years |
|
34 |
+
* | N yrs 9 months ... N+1 yrs | almost N+1 years |
|
35 |
+
*
|
36 |
+
* With `options.includeSeconds == true`:
|
37 |
+
* | Distance to now | Result |
|
38 |
+
* |---------------------|----------------------|
|
39 |
+
* | 0 secs ... 5 secs | less than 5 seconds |
|
40 |
+
* | 5 secs ... 10 secs | less than 10 seconds |
|
41 |
+
* | 10 secs ... 20 secs | less than 20 seconds |
|
42 |
+
* | 20 secs ... 40 secs | half a minute |
|
43 |
+
* | 40 secs ... 60 secs | less than a minute |
|
44 |
+
* | 60 secs ... 90 secs | 1 minute |
|
45 |
+
*
|
46 |
+
* @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
|
47 |
+
*
|
48 |
+
* @param date - The given date
|
49 |
+
* @param options - The object with options
|
50 |
+
*
|
51 |
+
* @returns The distance in words
|
52 |
+
*
|
53 |
+
* @throws `date` must not be Invalid Date
|
54 |
+
* @throws `options.locale` must contain `formatDistance` property
|
55 |
+
*
|
56 |
+
* @example
|
57 |
+
* // If today is 1 January 2015, what is the distance to 2 July 2014?
|
58 |
+
* const result = formatDistanceToNow(
|
59 |
+
* new Date(2014, 6, 2)
|
60 |
+
* )
|
61 |
+
* //=> '6 months'
|
62 |
+
*
|
63 |
+
* @example
|
64 |
+
* // If now is 1 January 2015 00:00:00,
|
65 |
+
* // what is the distance to 1 January 2015 00:00:15, including seconds?
|
66 |
+
* const result = formatDistanceToNow(
|
67 |
+
* new Date(2015, 0, 1, 0, 0, 15),
|
68 |
+
* {includeSeconds: true}
|
69 |
+
* )
|
70 |
+
* //=> 'less than 20 seconds'
|
71 |
+
*
|
72 |
+
* @example
|
73 |
+
* // If today is 1 January 2015,
|
74 |
+
* // what is the distance to 1 January 2016, with a suffix?
|
75 |
+
* const result = formatDistanceToNow(
|
76 |
+
* new Date(2016, 0, 1),
|
77 |
+
* {addSuffix: true}
|
78 |
+
* )
|
79 |
+
* //=> 'in about 1 year'
|
80 |
+
*
|
81 |
+
* @example
|
82 |
+
* // If today is 1 January 2015,
|
83 |
+
* // what is the distance to 1 August 2016 in Esperanto?
|
84 |
+
* const eoLocale = require('date-fns/locale/eo')
|
85 |
+
* const result = formatDistanceToNow(
|
86 |
+
* new Date(2016, 7, 1),
|
87 |
+
* {locale: eoLocale}
|
88 |
+
* )
|
89 |
+
* //=> 'pli ol 1 jaro'
|
90 |
+
*/
|
91 |
+
export function formatDistanceToNow(date, options) {
|
92 |
+
return formatDistance(date, constructNow(date), options);
|
93 |
+
}
|
94 |
+
|
95 |
+
// Fallback for modularized imports:
|
96 |
+
export default formatDistanceToNow;
|
workers1/auto3d/node_modules/date-fns/formatDistanceToNowStrict.d.mts
ADDED
@@ -0,0 +1,83 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import type { FormatDistanceStrictOptions } from "./formatDistanceStrict.js";
|
2 |
+
/**
|
3 |
+
* The {@link formatDistanceToNowStrict} function options.
|
4 |
+
*/
|
5 |
+
export interface FormatDistanceToNowStrictOptions
|
6 |
+
extends FormatDistanceStrictOptions {}
|
7 |
+
/**
|
8 |
+
* @name formatDistanceToNowStrict
|
9 |
+
* @category Common Helpers
|
10 |
+
* @summary Return the distance between the given date and now in words.
|
11 |
+
* @pure false
|
12 |
+
*
|
13 |
+
* @description
|
14 |
+
* Return the distance between the given dates in words, using strict units.
|
15 |
+
* This is like `formatDistance`, but does not use helpers like 'almost', 'over',
|
16 |
+
* 'less than' and the like.
|
17 |
+
*
|
18 |
+
* | Distance between dates | Result |
|
19 |
+
* |------------------------|---------------------|
|
20 |
+
* | 0 ... 59 secs | [0..59] seconds |
|
21 |
+
* | 1 ... 59 mins | [1..59] minutes |
|
22 |
+
* | 1 ... 23 hrs | [1..23] hours |
|
23 |
+
* | 1 ... 29 days | [1..29] days |
|
24 |
+
* | 1 ... 11 months | [1..11] months |
|
25 |
+
* | 1 ... N years | [1..N] years |
|
26 |
+
*
|
27 |
+
* @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
|
28 |
+
*
|
29 |
+
* @param date - The given date
|
30 |
+
* @param options - An object with options.
|
31 |
+
*
|
32 |
+
* @returns The distance in words
|
33 |
+
*
|
34 |
+
* @throws `date` must not be Invalid Date
|
35 |
+
* @throws `options.locale` must contain `formatDistance` property
|
36 |
+
*
|
37 |
+
* @example
|
38 |
+
* // If today is 1 January 2015, what is the distance to 2 July 2014?
|
39 |
+
* const result = formatDistanceToNowStrict(
|
40 |
+
* new Date(2014, 6, 2)
|
41 |
+
* )
|
42 |
+
* //=> '6 months'
|
43 |
+
*
|
44 |
+
* @example
|
45 |
+
* // If now is 1 January 2015 00:00:00,
|
46 |
+
* // what is the distance to 1 January 2015 00:00:15, including seconds?
|
47 |
+
* const result = formatDistanceToNowStrict(
|
48 |
+
* new Date(2015, 0, 1, 0, 0, 15)
|
49 |
+
* )
|
50 |
+
* //=> '15 seconds'
|
51 |
+
*
|
52 |
+
* @example
|
53 |
+
* // If today is 1 January 2015,
|
54 |
+
* // what is the distance to 1 January 2016, with a suffix?
|
55 |
+
* const result = formatDistanceToNowStrict(
|
56 |
+
* new Date(2016, 0, 1),
|
57 |
+
* {addSuffix: true}
|
58 |
+
* )
|
59 |
+
* //=> 'in 1 year'
|
60 |
+
*
|
61 |
+
* @example
|
62 |
+
* // If today is 28 January 2015,
|
63 |
+
* // what is the distance to 1 January 2015, in months, rounded up??
|
64 |
+
* const result = formatDistanceToNowStrict(new Date(2015, 0, 1), {
|
65 |
+
* unit: 'month',
|
66 |
+
* roundingMethod: 'ceil'
|
67 |
+
* })
|
68 |
+
* //=> '1 month'
|
69 |
+
*
|
70 |
+
* @example
|
71 |
+
* // If today is 1 January 2015,
|
72 |
+
* // what is the distance to 1 January 2016 in Esperanto?
|
73 |
+
* const eoLocale = require('date-fns/locale/eo')
|
74 |
+
* const result = formatDistanceToNowStrict(
|
75 |
+
* new Date(2016, 0, 1),
|
76 |
+
* {locale: eoLocale}
|
77 |
+
* )
|
78 |
+
* //=> '1 jaro'
|
79 |
+
*/
|
80 |
+
export declare function formatDistanceToNowStrict<DateType extends Date>(
|
81 |
+
date: DateType | number | string,
|
82 |
+
options?: FormatDistanceToNowStrictOptions,
|
83 |
+
): string;
|
workers1/auto3d/node_modules/date-fns/formatDistanceToNowStrict.d.ts
ADDED
@@ -0,0 +1,83 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import type { FormatDistanceStrictOptions } from "./formatDistanceStrict.js";
|
2 |
+
/**
|
3 |
+
* The {@link formatDistanceToNowStrict} function options.
|
4 |
+
*/
|
5 |
+
export interface FormatDistanceToNowStrictOptions
|
6 |
+
extends FormatDistanceStrictOptions {}
|
7 |
+
/**
|
8 |
+
* @name formatDistanceToNowStrict
|
9 |
+
* @category Common Helpers
|
10 |
+
* @summary Return the distance between the given date and now in words.
|
11 |
+
* @pure false
|
12 |
+
*
|
13 |
+
* @description
|
14 |
+
* Return the distance between the given dates in words, using strict units.
|
15 |
+
* This is like `formatDistance`, but does not use helpers like 'almost', 'over',
|
16 |
+
* 'less than' and the like.
|
17 |
+
*
|
18 |
+
* | Distance between dates | Result |
|
19 |
+
* |------------------------|---------------------|
|
20 |
+
* | 0 ... 59 secs | [0..59] seconds |
|
21 |
+
* | 1 ... 59 mins | [1..59] minutes |
|
22 |
+
* | 1 ... 23 hrs | [1..23] hours |
|
23 |
+
* | 1 ... 29 days | [1..29] days |
|
24 |
+
* | 1 ... 11 months | [1..11] months |
|
25 |
+
* | 1 ... N years | [1..N] years |
|
26 |
+
*
|
27 |
+
* @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
|
28 |
+
*
|
29 |
+
* @param date - The given date
|
30 |
+
* @param options - An object with options.
|
31 |
+
*
|
32 |
+
* @returns The distance in words
|
33 |
+
*
|
34 |
+
* @throws `date` must not be Invalid Date
|
35 |
+
* @throws `options.locale` must contain `formatDistance` property
|
36 |
+
*
|
37 |
+
* @example
|
38 |
+
* // If today is 1 January 2015, what is the distance to 2 July 2014?
|
39 |
+
* const result = formatDistanceToNowStrict(
|
40 |
+
* new Date(2014, 6, 2)
|
41 |
+
* )
|
42 |
+
* //=> '6 months'
|
43 |
+
*
|
44 |
+
* @example
|
45 |
+
* // If now is 1 January 2015 00:00:00,
|
46 |
+
* // what is the distance to 1 January 2015 00:00:15, including seconds?
|
47 |
+
* const result = formatDistanceToNowStrict(
|
48 |
+
* new Date(2015, 0, 1, 0, 0, 15)
|
49 |
+
* )
|
50 |
+
* //=> '15 seconds'
|
51 |
+
*
|
52 |
+
* @example
|
53 |
+
* // If today is 1 January 2015,
|
54 |
+
* // what is the distance to 1 January 2016, with a suffix?
|
55 |
+
* const result = formatDistanceToNowStrict(
|
56 |
+
* new Date(2016, 0, 1),
|
57 |
+
* {addSuffix: true}
|
58 |
+
* )
|
59 |
+
* //=> 'in 1 year'
|
60 |
+
*
|
61 |
+
* @example
|
62 |
+
* // If today is 28 January 2015,
|
63 |
+
* // what is the distance to 1 January 2015, in months, rounded up??
|
64 |
+
* const result = formatDistanceToNowStrict(new Date(2015, 0, 1), {
|
65 |
+
* unit: 'month',
|
66 |
+
* roundingMethod: 'ceil'
|
67 |
+
* })
|
68 |
+
* //=> '1 month'
|
69 |
+
*
|
70 |
+
* @example
|
71 |
+
* // If today is 1 January 2015,
|
72 |
+
* // what is the distance to 1 January 2016 in Esperanto?
|
73 |
+
* const eoLocale = require('date-fns/locale/eo')
|
74 |
+
* const result = formatDistanceToNowStrict(
|
75 |
+
* new Date(2016, 0, 1),
|
76 |
+
* {locale: eoLocale}
|
77 |
+
* )
|
78 |
+
* //=> '1 jaro'
|
79 |
+
*/
|
80 |
+
export declare function formatDistanceToNowStrict<DateType extends Date>(
|
81 |
+
date: DateType | number | string,
|
82 |
+
options?: FormatDistanceToNowStrictOptions,
|
83 |
+
): string;
|
workers1/auto3d/node_modules/date-fns/formatDistanceToNowStrict.js
ADDED
@@ -0,0 +1,89 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"use strict";
|
2 |
+
exports.formatDistanceToNowStrict = formatDistanceToNowStrict;
|
3 |
+
var _index = require("./formatDistanceStrict.js");
|
4 |
+
var _index2 = require("./constructNow.js");
|
5 |
+
|
6 |
+
/**
|
7 |
+
* The {@link formatDistanceToNowStrict} function options.
|
8 |
+
*/
|
9 |
+
|
10 |
+
/**
|
11 |
+
* @name formatDistanceToNowStrict
|
12 |
+
* @category Common Helpers
|
13 |
+
* @summary Return the distance between the given date and now in words.
|
14 |
+
* @pure false
|
15 |
+
*
|
16 |
+
* @description
|
17 |
+
* Return the distance between the given dates in words, using strict units.
|
18 |
+
* This is like `formatDistance`, but does not use helpers like 'almost', 'over',
|
19 |
+
* 'less than' and the like.
|
20 |
+
*
|
21 |
+
* | Distance between dates | Result |
|
22 |
+
* |------------------------|---------------------|
|
23 |
+
* | 0 ... 59 secs | [0..59] seconds |
|
24 |
+
* | 1 ... 59 mins | [1..59] minutes |
|
25 |
+
* | 1 ... 23 hrs | [1..23] hours |
|
26 |
+
* | 1 ... 29 days | [1..29] days |
|
27 |
+
* | 1 ... 11 months | [1..11] months |
|
28 |
+
* | 1 ... N years | [1..N] years |
|
29 |
+
*
|
30 |
+
* @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
|
31 |
+
*
|
32 |
+
* @param date - The given date
|
33 |
+
* @param options - An object with options.
|
34 |
+
*
|
35 |
+
* @returns The distance in words
|
36 |
+
*
|
37 |
+
* @throws `date` must not be Invalid Date
|
38 |
+
* @throws `options.locale` must contain `formatDistance` property
|
39 |
+
*
|
40 |
+
* @example
|
41 |
+
* // If today is 1 January 2015, what is the distance to 2 July 2014?
|
42 |
+
* const result = formatDistanceToNowStrict(
|
43 |
+
* new Date(2014, 6, 2)
|
44 |
+
* )
|
45 |
+
* //=> '6 months'
|
46 |
+
*
|
47 |
+
* @example
|
48 |
+
* // If now is 1 January 2015 00:00:00,
|
49 |
+
* // what is the distance to 1 January 2015 00:00:15, including seconds?
|
50 |
+
* const result = formatDistanceToNowStrict(
|
51 |
+
* new Date(2015, 0, 1, 0, 0, 15)
|
52 |
+
* )
|
53 |
+
* //=> '15 seconds'
|
54 |
+
*
|
55 |
+
* @example
|
56 |
+
* // If today is 1 January 2015,
|
57 |
+
* // what is the distance to 1 January 2016, with a suffix?
|
58 |
+
* const result = formatDistanceToNowStrict(
|
59 |
+
* new Date(2016, 0, 1),
|
60 |
+
* {addSuffix: true}
|
61 |
+
* )
|
62 |
+
* //=> 'in 1 year'
|
63 |
+
*
|
64 |
+
* @example
|
65 |
+
* // If today is 28 January 2015,
|
66 |
+
* // what is the distance to 1 January 2015, in months, rounded up??
|
67 |
+
* const result = formatDistanceToNowStrict(new Date(2015, 0, 1), {
|
68 |
+
* unit: 'month',
|
69 |
+
* roundingMethod: 'ceil'
|
70 |
+
* })
|
71 |
+
* //=> '1 month'
|
72 |
+
*
|
73 |
+
* @example
|
74 |
+
* // If today is 1 January 2015,
|
75 |
+
* // what is the distance to 1 January 2016 in Esperanto?
|
76 |
+
* const eoLocale = require('date-fns/locale/eo')
|
77 |
+
* const result = formatDistanceToNowStrict(
|
78 |
+
* new Date(2016, 0, 1),
|
79 |
+
* {locale: eoLocale}
|
80 |
+
* )
|
81 |
+
* //=> '1 jaro'
|
82 |
+
*/
|
83 |
+
function formatDistanceToNowStrict(date, options) {
|
84 |
+
return (0, _index.formatDistanceStrict)(
|
85 |
+
date,
|
86 |
+
(0, _index2.constructNow)(date),
|
87 |
+
options,
|
88 |
+
);
|
89 |
+
}
|
workers1/auto3d/node_modules/date-fns/formatDistanceToNowStrict.mjs
ADDED
@@ -0,0 +1,86 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { formatDistanceStrict } from "./formatDistanceStrict.mjs";
|
2 |
+
import { constructNow } from "./constructNow.mjs";
|
3 |
+
|
4 |
+
/**
|
5 |
+
* The {@link formatDistanceToNowStrict} function options.
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* @name formatDistanceToNowStrict
|
10 |
+
* @category Common Helpers
|
11 |
+
* @summary Return the distance between the given date and now in words.
|
12 |
+
* @pure false
|
13 |
+
*
|
14 |
+
* @description
|
15 |
+
* Return the distance between the given dates in words, using strict units.
|
16 |
+
* This is like `formatDistance`, but does not use helpers like 'almost', 'over',
|
17 |
+
* 'less than' and the like.
|
18 |
+
*
|
19 |
+
* | Distance between dates | Result |
|
20 |
+
* |------------------------|---------------------|
|
21 |
+
* | 0 ... 59 secs | [0..59] seconds |
|
22 |
+
* | 1 ... 59 mins | [1..59] minutes |
|
23 |
+
* | 1 ... 23 hrs | [1..23] hours |
|
24 |
+
* | 1 ... 29 days | [1..29] days |
|
25 |
+
* | 1 ... 11 months | [1..11] months |
|
26 |
+
* | 1 ... N years | [1..N] years |
|
27 |
+
*
|
28 |
+
* @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
|
29 |
+
*
|
30 |
+
* @param date - The given date
|
31 |
+
* @param options - An object with options.
|
32 |
+
*
|
33 |
+
* @returns The distance in words
|
34 |
+
*
|
35 |
+
* @throws `date` must not be Invalid Date
|
36 |
+
* @throws `options.locale` must contain `formatDistance` property
|
37 |
+
*
|
38 |
+
* @example
|
39 |
+
* // If today is 1 January 2015, what is the distance to 2 July 2014?
|
40 |
+
* const result = formatDistanceToNowStrict(
|
41 |
+
* new Date(2014, 6, 2)
|
42 |
+
* )
|
43 |
+
* //=> '6 months'
|
44 |
+
*
|
45 |
+
* @example
|
46 |
+
* // If now is 1 January 2015 00:00:00,
|
47 |
+
* // what is the distance to 1 January 2015 00:00:15, including seconds?
|
48 |
+
* const result = formatDistanceToNowStrict(
|
49 |
+
* new Date(2015, 0, 1, 0, 0, 15)
|
50 |
+
* )
|
51 |
+
* //=> '15 seconds'
|
52 |
+
*
|
53 |
+
* @example
|
54 |
+
* // If today is 1 January 2015,
|
55 |
+
* // what is the distance to 1 January 2016, with a suffix?
|
56 |
+
* const result = formatDistanceToNowStrict(
|
57 |
+
* new Date(2016, 0, 1),
|
58 |
+
* {addSuffix: true}
|
59 |
+
* )
|
60 |
+
* //=> 'in 1 year'
|
61 |
+
*
|
62 |
+
* @example
|
63 |
+
* // If today is 28 January 2015,
|
64 |
+
* // what is the distance to 1 January 2015, in months, rounded up??
|
65 |
+
* const result = formatDistanceToNowStrict(new Date(2015, 0, 1), {
|
66 |
+
* unit: 'month',
|
67 |
+
* roundingMethod: 'ceil'
|
68 |
+
* })
|
69 |
+
* //=> '1 month'
|
70 |
+
*
|
71 |
+
* @example
|
72 |
+
* // If today is 1 January 2015,
|
73 |
+
* // what is the distance to 1 January 2016 in Esperanto?
|
74 |
+
* const eoLocale = require('date-fns/locale/eo')
|
75 |
+
* const result = formatDistanceToNowStrict(
|
76 |
+
* new Date(2016, 0, 1),
|
77 |
+
* {locale: eoLocale}
|
78 |
+
* )
|
79 |
+
* //=> '1 jaro'
|
80 |
+
*/
|
81 |
+
export function formatDistanceToNowStrict(date, options) {
|
82 |
+
return formatDistanceStrict(date, constructNow(date), options);
|
83 |
+
}
|
84 |
+
|
85 |
+
// Fallback for modularized imports:
|
86 |
+
export default formatDistanceToNowStrict;
|
workers1/auto3d/node_modules/date-fns/formatDuration.d.mts
ADDED
@@ -0,0 +1,77 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import type { Duration, DurationUnit, LocalizedOptions } from "./types.js";
|
2 |
+
/**
|
3 |
+
* The {@link formatDuration} function options.
|
4 |
+
*/
|
5 |
+
export interface FormatDurationOptions
|
6 |
+
extends LocalizedOptions<"formatDistance"> {
|
7 |
+
/** The array of units to format */
|
8 |
+
format?: DurationUnit[];
|
9 |
+
/** Should be zeros be included in the output? */
|
10 |
+
zero?: boolean;
|
11 |
+
/** The delimiter string to use */
|
12 |
+
delimiter?: string;
|
13 |
+
}
|
14 |
+
/**
|
15 |
+
* @name formatDuration
|
16 |
+
* @category Common Helpers
|
17 |
+
* @summary Formats a duration in human-readable format
|
18 |
+
*
|
19 |
+
* @description
|
20 |
+
* Return human-readable duration string i.e. "9 months 2 days"
|
21 |
+
*
|
22 |
+
* @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
|
23 |
+
*
|
24 |
+
* @param duration - The duration to format
|
25 |
+
* @param options - An object with options.
|
26 |
+
*
|
27 |
+
* @returns The formatted date string
|
28 |
+
*
|
29 |
+
* @example
|
30 |
+
* // Format full duration
|
31 |
+
* formatDuration({
|
32 |
+
* years: 2,
|
33 |
+
* months: 9,
|
34 |
+
* weeks: 1,
|
35 |
+
* days: 7,
|
36 |
+
* hours: 5,
|
37 |
+
* minutes: 9,
|
38 |
+
* seconds: 30
|
39 |
+
* })
|
40 |
+
* //=> '2 years 9 months 1 week 7 days 5 hours 9 minutes 30 seconds'
|
41 |
+
*
|
42 |
+
* @example
|
43 |
+
* // Format partial duration
|
44 |
+
* formatDuration({ months: 9, days: 2 })
|
45 |
+
* //=> '9 months 2 days'
|
46 |
+
*
|
47 |
+
* @example
|
48 |
+
* // Customize the format
|
49 |
+
* formatDuration(
|
50 |
+
* {
|
51 |
+
* years: 2,
|
52 |
+
* months: 9,
|
53 |
+
* weeks: 1,
|
54 |
+
* days: 7,
|
55 |
+
* hours: 5,
|
56 |
+
* minutes: 9,
|
57 |
+
* seconds: 30
|
58 |
+
* },
|
59 |
+
* { format: ['months', 'weeks'] }
|
60 |
+
* ) === '9 months 1 week'
|
61 |
+
*
|
62 |
+
* @example
|
63 |
+
* // Customize the zeros presence
|
64 |
+
* formatDuration({ years: 0, months: 9 })
|
65 |
+
* //=> '9 months'
|
66 |
+
* formatDuration({ years: 0, months: 9 }, { zero: true })
|
67 |
+
* //=> '0 years 9 months'
|
68 |
+
*
|
69 |
+
* @example
|
70 |
+
* // Customize the delimiter
|
71 |
+
* formatDuration({ years: 2, months: 9, weeks: 3 }, { delimiter: ', ' })
|
72 |
+
* //=> '2 years, 9 months, 3 weeks'
|
73 |
+
*/
|
74 |
+
export declare function formatDuration(
|
75 |
+
duration: Duration,
|
76 |
+
options?: FormatDurationOptions,
|
77 |
+
): string;
|
workers1/auto3d/node_modules/date-fns/formatDuration.d.ts
ADDED
@@ -0,0 +1,77 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import type { Duration, DurationUnit, LocalizedOptions } from "./types.js";
|
2 |
+
/**
|
3 |
+
* The {@link formatDuration} function options.
|
4 |
+
*/
|
5 |
+
export interface FormatDurationOptions
|
6 |
+
extends LocalizedOptions<"formatDistance"> {
|
7 |
+
/** The array of units to format */
|
8 |
+
format?: DurationUnit[];
|
9 |
+
/** Should be zeros be included in the output? */
|
10 |
+
zero?: boolean;
|
11 |
+
/** The delimiter string to use */
|
12 |
+
delimiter?: string;
|
13 |
+
}
|
14 |
+
/**
|
15 |
+
* @name formatDuration
|
16 |
+
* @category Common Helpers
|
17 |
+
* @summary Formats a duration in human-readable format
|
18 |
+
*
|
19 |
+
* @description
|
20 |
+
* Return human-readable duration string i.e. "9 months 2 days"
|
21 |
+
*
|
22 |
+
* @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
|
23 |
+
*
|
24 |
+
* @param duration - The duration to format
|
25 |
+
* @param options - An object with options.
|
26 |
+
*
|
27 |
+
* @returns The formatted date string
|
28 |
+
*
|
29 |
+
* @example
|
30 |
+
* // Format full duration
|
31 |
+
* formatDuration({
|
32 |
+
* years: 2,
|
33 |
+
* months: 9,
|
34 |
+
* weeks: 1,
|
35 |
+
* days: 7,
|
36 |
+
* hours: 5,
|
37 |
+
* minutes: 9,
|
38 |
+
* seconds: 30
|
39 |
+
* })
|
40 |
+
* //=> '2 years 9 months 1 week 7 days 5 hours 9 minutes 30 seconds'
|
41 |
+
*
|
42 |
+
* @example
|
43 |
+
* // Format partial duration
|
44 |
+
* formatDuration({ months: 9, days: 2 })
|
45 |
+
* //=> '9 months 2 days'
|
46 |
+
*
|
47 |
+
* @example
|
48 |
+
* // Customize the format
|
49 |
+
* formatDuration(
|
50 |
+
* {
|
51 |
+
* years: 2,
|
52 |
+
* months: 9,
|
53 |
+
* weeks: 1,
|
54 |
+
* days: 7,
|
55 |
+
* hours: 5,
|
56 |
+
* minutes: 9,
|
57 |
+
* seconds: 30
|
58 |
+
* },
|
59 |
+
* { format: ['months', 'weeks'] }
|
60 |
+
* ) === '9 months 1 week'
|
61 |
+
*
|
62 |
+
* @example
|
63 |
+
* // Customize the zeros presence
|
64 |
+
* formatDuration({ years: 0, months: 9 })
|
65 |
+
* //=> '9 months'
|
66 |
+
* formatDuration({ years: 0, months: 9 }, { zero: true })
|
67 |
+
* //=> '0 years 9 months'
|
68 |
+
*
|
69 |
+
* @example
|
70 |
+
* // Customize the delimiter
|
71 |
+
* formatDuration({ years: 2, months: 9, weeks: 3 }, { delimiter: ', ' })
|
72 |
+
* //=> '2 years, 9 months, 3 weeks'
|
73 |
+
*/
|
74 |
+
export declare function formatDuration(
|
75 |
+
duration: Duration,
|
76 |
+
options?: FormatDurationOptions,
|
77 |
+
): string;
|
workers1/auto3d/node_modules/date-fns/formatDuration.js
ADDED
@@ -0,0 +1,105 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"use strict";
|
2 |
+
exports.formatDuration = formatDuration;
|
3 |
+
|
4 |
+
var _index = require("./_lib/defaultLocale.js");
|
5 |
+
var _index2 = require("./_lib/defaultOptions.js");
|
6 |
+
|
7 |
+
/**
|
8 |
+
* The {@link formatDuration} function options.
|
9 |
+
*/
|
10 |
+
|
11 |
+
const defaultFormat = [
|
12 |
+
"years",
|
13 |
+
"months",
|
14 |
+
"weeks",
|
15 |
+
"days",
|
16 |
+
"hours",
|
17 |
+
"minutes",
|
18 |
+
"seconds",
|
19 |
+
];
|
20 |
+
|
21 |
+
/**
|
22 |
+
* @name formatDuration
|
23 |
+
* @category Common Helpers
|
24 |
+
* @summary Formats a duration in human-readable format
|
25 |
+
*
|
26 |
+
* @description
|
27 |
+
* Return human-readable duration string i.e. "9 months 2 days"
|
28 |
+
*
|
29 |
+
* @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
|
30 |
+
*
|
31 |
+
* @param duration - The duration to format
|
32 |
+
* @param options - An object with options.
|
33 |
+
*
|
34 |
+
* @returns The formatted date string
|
35 |
+
*
|
36 |
+
* @example
|
37 |
+
* // Format full duration
|
38 |
+
* formatDuration({
|
39 |
+
* years: 2,
|
40 |
+
* months: 9,
|
41 |
+
* weeks: 1,
|
42 |
+
* days: 7,
|
43 |
+
* hours: 5,
|
44 |
+
* minutes: 9,
|
45 |
+
* seconds: 30
|
46 |
+
* })
|
47 |
+
* //=> '2 years 9 months 1 week 7 days 5 hours 9 minutes 30 seconds'
|
48 |
+
*
|
49 |
+
* @example
|
50 |
+
* // Format partial duration
|
51 |
+
* formatDuration({ months: 9, days: 2 })
|
52 |
+
* //=> '9 months 2 days'
|
53 |
+
*
|
54 |
+
* @example
|
55 |
+
* // Customize the format
|
56 |
+
* formatDuration(
|
57 |
+
* {
|
58 |
+
* years: 2,
|
59 |
+
* months: 9,
|
60 |
+
* weeks: 1,
|
61 |
+
* days: 7,
|
62 |
+
* hours: 5,
|
63 |
+
* minutes: 9,
|
64 |
+
* seconds: 30
|
65 |
+
* },
|
66 |
+
* { format: ['months', 'weeks'] }
|
67 |
+
* ) === '9 months 1 week'
|
68 |
+
*
|
69 |
+
* @example
|
70 |
+
* // Customize the zeros presence
|
71 |
+
* formatDuration({ years: 0, months: 9 })
|
72 |
+
* //=> '9 months'
|
73 |
+
* formatDuration({ years: 0, months: 9 }, { zero: true })
|
74 |
+
* //=> '0 years 9 months'
|
75 |
+
*
|
76 |
+
* @example
|
77 |
+
* // Customize the delimiter
|
78 |
+
* formatDuration({ years: 2, months: 9, weeks: 3 }, { delimiter: ', ' })
|
79 |
+
* //=> '2 years, 9 months, 3 weeks'
|
80 |
+
*/
|
81 |
+
function formatDuration(duration, options) {
|
82 |
+
const defaultOptions = (0, _index2.getDefaultOptions)();
|
83 |
+
const locale =
|
84 |
+
options?.locale ?? defaultOptions.locale ?? _index.defaultLocale;
|
85 |
+
const format = options?.format ?? defaultFormat;
|
86 |
+
const zero = options?.zero ?? false;
|
87 |
+
const delimiter = options?.delimiter ?? " ";
|
88 |
+
|
89 |
+
if (!locale.formatDistance) {
|
90 |
+
return "";
|
91 |
+
}
|
92 |
+
|
93 |
+
const result = format
|
94 |
+
.reduce((acc, unit) => {
|
95 |
+
const token = `x${unit.replace(/(^.)/, (m) => m.toUpperCase())}`;
|
96 |
+
const value = duration[unit];
|
97 |
+
if (value !== undefined && (zero || duration[unit])) {
|
98 |
+
return acc.concat(locale.formatDistance(token, value));
|
99 |
+
}
|
100 |
+
return acc;
|
101 |
+
}, [])
|
102 |
+
.join(delimiter);
|
103 |
+
|
104 |
+
return result;
|
105 |
+
}
|
workers1/auto3d/node_modules/date-fns/formatDuration.mjs
ADDED
@@ -0,0 +1,104 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { defaultLocale } from "./_lib/defaultLocale.mjs";
|
2 |
+
import { getDefaultOptions } from "./_lib/defaultOptions.mjs";
|
3 |
+
|
4 |
+
/**
|
5 |
+
* The {@link formatDuration} function options.
|
6 |
+
*/
|
7 |
+
|
8 |
+
const defaultFormat = [
|
9 |
+
"years",
|
10 |
+
"months",
|
11 |
+
"weeks",
|
12 |
+
"days",
|
13 |
+
"hours",
|
14 |
+
"minutes",
|
15 |
+
"seconds",
|
16 |
+
];
|
17 |
+
|
18 |
+
/**
|
19 |
+
* @name formatDuration
|
20 |
+
* @category Common Helpers
|
21 |
+
* @summary Formats a duration in human-readable format
|
22 |
+
*
|
23 |
+
* @description
|
24 |
+
* Return human-readable duration string i.e. "9 months 2 days"
|
25 |
+
*
|
26 |
+
* @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
|
27 |
+
*
|
28 |
+
* @param duration - The duration to format
|
29 |
+
* @param options - An object with options.
|
30 |
+
*
|
31 |
+
* @returns The formatted date string
|
32 |
+
*
|
33 |
+
* @example
|
34 |
+
* // Format full duration
|
35 |
+
* formatDuration({
|
36 |
+
* years: 2,
|
37 |
+
* months: 9,
|
38 |
+
* weeks: 1,
|
39 |
+
* days: 7,
|
40 |
+
* hours: 5,
|
41 |
+
* minutes: 9,
|
42 |
+
* seconds: 30
|
43 |
+
* })
|
44 |
+
* //=> '2 years 9 months 1 week 7 days 5 hours 9 minutes 30 seconds'
|
45 |
+
*
|
46 |
+
* @example
|
47 |
+
* // Format partial duration
|
48 |
+
* formatDuration({ months: 9, days: 2 })
|
49 |
+
* //=> '9 months 2 days'
|
50 |
+
*
|
51 |
+
* @example
|
52 |
+
* // Customize the format
|
53 |
+
* formatDuration(
|
54 |
+
* {
|
55 |
+
* years: 2,
|
56 |
+
* months: 9,
|
57 |
+
* weeks: 1,
|
58 |
+
* days: 7,
|
59 |
+
* hours: 5,
|
60 |
+
* minutes: 9,
|
61 |
+
* seconds: 30
|
62 |
+
* },
|
63 |
+
* { format: ['months', 'weeks'] }
|
64 |
+
* ) === '9 months 1 week'
|
65 |
+
*
|
66 |
+
* @example
|
67 |
+
* // Customize the zeros presence
|
68 |
+
* formatDuration({ years: 0, months: 9 })
|
69 |
+
* //=> '9 months'
|
70 |
+
* formatDuration({ years: 0, months: 9 }, { zero: true })
|
71 |
+
* //=> '0 years 9 months'
|
72 |
+
*
|
73 |
+
* @example
|
74 |
+
* // Customize the delimiter
|
75 |
+
* formatDuration({ years: 2, months: 9, weeks: 3 }, { delimiter: ', ' })
|
76 |
+
* //=> '2 years, 9 months, 3 weeks'
|
77 |
+
*/
|
78 |
+
export function formatDuration(duration, options) {
|
79 |
+
const defaultOptions = getDefaultOptions();
|
80 |
+
const locale = options?.locale ?? defaultOptions.locale ?? defaultLocale;
|
81 |
+
const format = options?.format ?? defaultFormat;
|
82 |
+
const zero = options?.zero ?? false;
|
83 |
+
const delimiter = options?.delimiter ?? " ";
|
84 |
+
|
85 |
+
if (!locale.formatDistance) {
|
86 |
+
return "";
|
87 |
+
}
|
88 |
+
|
89 |
+
const result = format
|
90 |
+
.reduce((acc, unit) => {
|
91 |
+
const token = `x${unit.replace(/(^.)/, (m) => m.toUpperCase())}`;
|
92 |
+
const value = duration[unit];
|
93 |
+
if (value !== undefined && (zero || duration[unit])) {
|
94 |
+
return acc.concat(locale.formatDistance(token, value));
|
95 |
+
}
|
96 |
+
return acc;
|
97 |
+
}, [])
|
98 |
+
.join(delimiter);
|
99 |
+
|
100 |
+
return result;
|
101 |
+
}
|
102 |
+
|
103 |
+
// Fallback for modularized imports:
|
104 |
+
export default formatDuration;
|
workers1/auto3d/node_modules/date-fns/formatISO.d.mts
ADDED
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import type { ISOFormatOptions } from "./types.js";
|
2 |
+
/**
|
3 |
+
* The {@link formatISO} function options.
|
4 |
+
*/
|
5 |
+
export interface FormatISOOptions extends ISOFormatOptions {}
|
6 |
+
/**
|
7 |
+
* @name formatISO
|
8 |
+
* @category Common Helpers
|
9 |
+
* @summary Format the date according to the ISO 8601 standard (https://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a003169814.htm).
|
10 |
+
*
|
11 |
+
* @description
|
12 |
+
* Return the formatted date string in ISO 8601 format. Options may be passed to control the parts and notations of the date.
|
13 |
+
*
|
14 |
+
* @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
|
15 |
+
*
|
16 |
+
* @param date - The original date
|
17 |
+
* @param options - An object with options.
|
18 |
+
*
|
19 |
+
* @returns The formatted date string (in loca.l time zone)
|
20 |
+
*
|
21 |
+
* @throws `date` must not be Invalid Date
|
22 |
+
*
|
23 |
+
* @example
|
24 |
+
* // Represent 18 September 2019 in ISO 8601 format (local time zone is UTC):
|
25 |
+
* const result = formatISO(new Date(2019, 8, 18, 19, 0, 52))
|
26 |
+
* //=> '2019-09-18T19:00:52Z'
|
27 |
+
*
|
28 |
+
* @example
|
29 |
+
* // Represent 18 September 2019 in ISO 8601, short format (local time zone is UTC):
|
30 |
+
* const result = formatISO(new Date(2019, 8, 18, 19, 0, 52), { format: 'basic' })
|
31 |
+
* //=> '20190918T190052'
|
32 |
+
*
|
33 |
+
* @example
|
34 |
+
* // Represent 18 September 2019 in ISO 8601 format, date only:
|
35 |
+
* const result = formatISO(new Date(2019, 8, 18, 19, 0, 52), { representation: 'date' })
|
36 |
+
* //=> '2019-09-18'
|
37 |
+
*
|
38 |
+
* @example
|
39 |
+
* // Represent 18 September 2019 in ISO 8601 format, time only (local time zone is UTC):
|
40 |
+
* const result = formatISO(new Date(2019, 8, 18, 19, 0, 52), { representation: 'time' })
|
41 |
+
* //=> '19:00:52Z'
|
42 |
+
*/
|
43 |
+
export declare function formatISO<DateType extends Date>(
|
44 |
+
date: DateType | number | string,
|
45 |
+
options?: FormatISOOptions,
|
46 |
+
): string;
|
workers1/auto3d/node_modules/date-fns/formatISO.d.ts
ADDED
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import type { ISOFormatOptions } from "./types.js";
|
2 |
+
/**
|
3 |
+
* The {@link formatISO} function options.
|
4 |
+
*/
|
5 |
+
export interface FormatISOOptions extends ISOFormatOptions {}
|
6 |
+
/**
|
7 |
+
* @name formatISO
|
8 |
+
* @category Common Helpers
|
9 |
+
* @summary Format the date according to the ISO 8601 standard (https://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a003169814.htm).
|
10 |
+
*
|
11 |
+
* @description
|
12 |
+
* Return the formatted date string in ISO 8601 format. Options may be passed to control the parts and notations of the date.
|
13 |
+
*
|
14 |
+
* @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
|
15 |
+
*
|
16 |
+
* @param date - The original date
|
17 |
+
* @param options - An object with options.
|
18 |
+
*
|
19 |
+
* @returns The formatted date string (in loca.l time zone)
|
20 |
+
*
|
21 |
+
* @throws `date` must not be Invalid Date
|
22 |
+
*
|
23 |
+
* @example
|
24 |
+
* // Represent 18 September 2019 in ISO 8601 format (local time zone is UTC):
|
25 |
+
* const result = formatISO(new Date(2019, 8, 18, 19, 0, 52))
|
26 |
+
* //=> '2019-09-18T19:00:52Z'
|
27 |
+
*
|
28 |
+
* @example
|
29 |
+
* // Represent 18 September 2019 in ISO 8601, short format (local time zone is UTC):
|
30 |
+
* const result = formatISO(new Date(2019, 8, 18, 19, 0, 52), { format: 'basic' })
|
31 |
+
* //=> '20190918T190052'
|
32 |
+
*
|
33 |
+
* @example
|
34 |
+
* // Represent 18 September 2019 in ISO 8601 format, date only:
|
35 |
+
* const result = formatISO(new Date(2019, 8, 18, 19, 0, 52), { representation: 'date' })
|
36 |
+
* //=> '2019-09-18'
|
37 |
+
*
|
38 |
+
* @example
|
39 |
+
* // Represent 18 September 2019 in ISO 8601 format, time only (local time zone is UTC):
|
40 |
+
* const result = formatISO(new Date(2019, 8, 18, 19, 0, 52), { representation: 'time' })
|
41 |
+
* //=> '19:00:52Z'
|
42 |
+
*/
|
43 |
+
export declare function formatISO<DateType extends Date>(
|
44 |
+
date: DateType | number | string,
|
45 |
+
options?: FormatISOOptions,
|
46 |
+
): string;
|
workers1/auto3d/node_modules/date-fns/formatISO.js
ADDED
@@ -0,0 +1,109 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"use strict";
|
2 |
+
exports.formatISO = formatISO;
|
3 |
+
var _index = require("./toDate.js");
|
4 |
+
|
5 |
+
var _index2 = require("./_lib/addLeadingZeros.js");
|
6 |
+
|
7 |
+
/**
|
8 |
+
* The {@link formatISO} function options.
|
9 |
+
*/
|
10 |
+
|
11 |
+
/**
|
12 |
+
* @name formatISO
|
13 |
+
* @category Common Helpers
|
14 |
+
* @summary Format the date according to the ISO 8601 standard (https://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a003169814.htm).
|
15 |
+
*
|
16 |
+
* @description
|
17 |
+
* Return the formatted date string in ISO 8601 format. Options may be passed to control the parts and notations of the date.
|
18 |
+
*
|
19 |
+
* @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
|
20 |
+
*
|
21 |
+
* @param date - The original date
|
22 |
+
* @param options - An object with options.
|
23 |
+
*
|
24 |
+
* @returns The formatted date string (in loca.l time zone)
|
25 |
+
*
|
26 |
+
* @throws `date` must not be Invalid Date
|
27 |
+
*
|
28 |
+
* @example
|
29 |
+
* // Represent 18 September 2019 in ISO 8601 format (local time zone is UTC):
|
30 |
+
* const result = formatISO(new Date(2019, 8, 18, 19, 0, 52))
|
31 |
+
* //=> '2019-09-18T19:00:52Z'
|
32 |
+
*
|
33 |
+
* @example
|
34 |
+
* // Represent 18 September 2019 in ISO 8601, short format (local time zone is UTC):
|
35 |
+
* const result = formatISO(new Date(2019, 8, 18, 19, 0, 52), { format: 'basic' })
|
36 |
+
* //=> '20190918T190052'
|
37 |
+
*
|
38 |
+
* @example
|
39 |
+
* // Represent 18 September 2019 in ISO 8601 format, date only:
|
40 |
+
* const result = formatISO(new Date(2019, 8, 18, 19, 0, 52), { representation: 'date' })
|
41 |
+
* //=> '2019-09-18'
|
42 |
+
*
|
43 |
+
* @example
|
44 |
+
* // Represent 18 September 2019 in ISO 8601 format, time only (local time zone is UTC):
|
45 |
+
* const result = formatISO(new Date(2019, 8, 18, 19, 0, 52), { representation: 'time' })
|
46 |
+
* //=> '19:00:52Z'
|
47 |
+
*/
|
48 |
+
function formatISO(date, options) {
|
49 |
+
const _date = (0, _index.toDate)(date);
|
50 |
+
|
51 |
+
if (isNaN(_date.getTime())) {
|
52 |
+
throw new RangeError("Invalid time value");
|
53 |
+
}
|
54 |
+
|
55 |
+
const format = options?.format ?? "extended";
|
56 |
+
const representation = options?.representation ?? "complete";
|
57 |
+
|
58 |
+
let result = "";
|
59 |
+
let tzOffset = "";
|
60 |
+
|
61 |
+
const dateDelimiter = format === "extended" ? "-" : "";
|
62 |
+
const timeDelimiter = format === "extended" ? ":" : "";
|
63 |
+
|
64 |
+
// Representation is either 'date' or 'complete'
|
65 |
+
if (representation !== "time") {
|
66 |
+
const day = (0, _index2.addLeadingZeros)(_date.getDate(), 2);
|
67 |
+
const month = (0, _index2.addLeadingZeros)(_date.getMonth() + 1, 2);
|
68 |
+
const year = (0, _index2.addLeadingZeros)(_date.getFullYear(), 4);
|
69 |
+
|
70 |
+
// yyyyMMdd or yyyy-MM-dd.
|
71 |
+
result = `${year}${dateDelimiter}${month}${dateDelimiter}${day}`;
|
72 |
+
}
|
73 |
+
|
74 |
+
// Representation is either 'time' or 'complete'
|
75 |
+
if (representation !== "date") {
|
76 |
+
// Add the timezone.
|
77 |
+
const offset = _date.getTimezoneOffset();
|
78 |
+
|
79 |
+
if (offset !== 0) {
|
80 |
+
const absoluteOffset = Math.abs(offset);
|
81 |
+
const hourOffset = (0, _index2.addLeadingZeros)(
|
82 |
+
Math.trunc(absoluteOffset / 60),
|
83 |
+
2,
|
84 |
+
);
|
85 |
+
const minuteOffset = (0, _index2.addLeadingZeros)(absoluteOffset % 60, 2);
|
86 |
+
// If less than 0, the sign is +, because it is ahead of time.
|
87 |
+
const sign = offset < 0 ? "+" : "-";
|
88 |
+
|
89 |
+
tzOffset = `${sign}${hourOffset}:${minuteOffset}`;
|
90 |
+
} else {
|
91 |
+
tzOffset = "Z";
|
92 |
+
}
|
93 |
+
|
94 |
+
const hour = (0, _index2.addLeadingZeros)(_date.getHours(), 2);
|
95 |
+
const minute = (0, _index2.addLeadingZeros)(_date.getMinutes(), 2);
|
96 |
+
const second = (0, _index2.addLeadingZeros)(_date.getSeconds(), 2);
|
97 |
+
|
98 |
+
// If there's also date, separate it with time with 'T'
|
99 |
+
const separator = result === "" ? "" : "T";
|
100 |
+
|
101 |
+
// Creates a time string consisting of hour, minute, and second, separated by delimiters, if defined.
|
102 |
+
const time = [hour, minute, second].join(timeDelimiter);
|
103 |
+
|
104 |
+
// HHmmss or HH:mm:ss.
|
105 |
+
result = `${result}${separator}${time}${tzOffset}`;
|
106 |
+
}
|
107 |
+
|
108 |
+
return result;
|
109 |
+
}
|
workers1/auto3d/node_modules/date-fns/formatISO.mjs
ADDED
@@ -0,0 +1,106 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { toDate } from "./toDate.mjs";
|
2 |
+
import { addLeadingZeros } from "./_lib/addLeadingZeros.mjs";
|
3 |
+
|
4 |
+
/**
|
5 |
+
* The {@link formatISO} function options.
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* @name formatISO
|
10 |
+
* @category Common Helpers
|
11 |
+
* @summary Format the date according to the ISO 8601 standard (https://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a003169814.htm).
|
12 |
+
*
|
13 |
+
* @description
|
14 |
+
* Return the formatted date string in ISO 8601 format. Options may be passed to control the parts and notations of the date.
|
15 |
+
*
|
16 |
+
* @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
|
17 |
+
*
|
18 |
+
* @param date - The original date
|
19 |
+
* @param options - An object with options.
|
20 |
+
*
|
21 |
+
* @returns The formatted date string (in loca.l time zone)
|
22 |
+
*
|
23 |
+
* @throws `date` must not be Invalid Date
|
24 |
+
*
|
25 |
+
* @example
|
26 |
+
* // Represent 18 September 2019 in ISO 8601 format (local time zone is UTC):
|
27 |
+
* const result = formatISO(new Date(2019, 8, 18, 19, 0, 52))
|
28 |
+
* //=> '2019-09-18T19:00:52Z'
|
29 |
+
*
|
30 |
+
* @example
|
31 |
+
* // Represent 18 September 2019 in ISO 8601, short format (local time zone is UTC):
|
32 |
+
* const result = formatISO(new Date(2019, 8, 18, 19, 0, 52), { format: 'basic' })
|
33 |
+
* //=> '20190918T190052'
|
34 |
+
*
|
35 |
+
* @example
|
36 |
+
* // Represent 18 September 2019 in ISO 8601 format, date only:
|
37 |
+
* const result = formatISO(new Date(2019, 8, 18, 19, 0, 52), { representation: 'date' })
|
38 |
+
* //=> '2019-09-18'
|
39 |
+
*
|
40 |
+
* @example
|
41 |
+
* // Represent 18 September 2019 in ISO 8601 format, time only (local time zone is UTC):
|
42 |
+
* const result = formatISO(new Date(2019, 8, 18, 19, 0, 52), { representation: 'time' })
|
43 |
+
* //=> '19:00:52Z'
|
44 |
+
*/
|
45 |
+
export function formatISO(date, options) {
|
46 |
+
const _date = toDate(date);
|
47 |
+
|
48 |
+
if (isNaN(_date.getTime())) {
|
49 |
+
throw new RangeError("Invalid time value");
|
50 |
+
}
|
51 |
+
|
52 |
+
const format = options?.format ?? "extended";
|
53 |
+
const representation = options?.representation ?? "complete";
|
54 |
+
|
55 |
+
let result = "";
|
56 |
+
let tzOffset = "";
|
57 |
+
|
58 |
+
const dateDelimiter = format === "extended" ? "-" : "";
|
59 |
+
const timeDelimiter = format === "extended" ? ":" : "";
|
60 |
+
|
61 |
+
// Representation is either 'date' or 'complete'
|
62 |
+
if (representation !== "time") {
|
63 |
+
const day = addLeadingZeros(_date.getDate(), 2);
|
64 |
+
const month = addLeadingZeros(_date.getMonth() + 1, 2);
|
65 |
+
const year = addLeadingZeros(_date.getFullYear(), 4);
|
66 |
+
|
67 |
+
// yyyyMMdd or yyyy-MM-dd.
|
68 |
+
result = `${year}${dateDelimiter}${month}${dateDelimiter}${day}`;
|
69 |
+
}
|
70 |
+
|
71 |
+
// Representation is either 'time' or 'complete'
|
72 |
+
if (representation !== "date") {
|
73 |
+
// Add the timezone.
|
74 |
+
const offset = _date.getTimezoneOffset();
|
75 |
+
|
76 |
+
if (offset !== 0) {
|
77 |
+
const absoluteOffset = Math.abs(offset);
|
78 |
+
const hourOffset = addLeadingZeros(Math.trunc(absoluteOffset / 60), 2);
|
79 |
+
const minuteOffset = addLeadingZeros(absoluteOffset % 60, 2);
|
80 |
+
// If less than 0, the sign is +, because it is ahead of time.
|
81 |
+
const sign = offset < 0 ? "+" : "-";
|
82 |
+
|
83 |
+
tzOffset = `${sign}${hourOffset}:${minuteOffset}`;
|
84 |
+
} else {
|
85 |
+
tzOffset = "Z";
|
86 |
+
}
|
87 |
+
|
88 |
+
const hour = addLeadingZeros(_date.getHours(), 2);
|
89 |
+
const minute = addLeadingZeros(_date.getMinutes(), 2);
|
90 |
+
const second = addLeadingZeros(_date.getSeconds(), 2);
|
91 |
+
|
92 |
+
// If there's also date, separate it with time with 'T'
|
93 |
+
const separator = result === "" ? "" : "T";
|
94 |
+
|
95 |
+
// Creates a time string consisting of hour, minute, and second, separated by delimiters, if defined.
|
96 |
+
const time = [hour, minute, second].join(timeDelimiter);
|
97 |
+
|
98 |
+
// HHmmss or HH:mm:ss.
|
99 |
+
result = `${result}${separator}${time}${tzOffset}`;
|
100 |
+
}
|
101 |
+
|
102 |
+
return result;
|
103 |
+
}
|
104 |
+
|
105 |
+
// Fallback for modularized imports:
|
106 |
+
export default formatISO;
|
workers1/auto3d/node_modules/date-fns/formatISO9075.d.mts
ADDED
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import type { ISOFormatOptions } from "./types.js";
|
2 |
+
/**
|
3 |
+
* The {@link formatISO9075} function options.
|
4 |
+
*/
|
5 |
+
export interface FormatISO9075Options extends ISOFormatOptions {}
|
6 |
+
/**
|
7 |
+
* @name formatISO9075
|
8 |
+
* @category Common Helpers
|
9 |
+
* @summary Format the date according to the ISO 9075 standard (https://dev.mysql.com/doc/refman/5.7/en/date-and-time-functions.html#function_get-format).
|
10 |
+
*
|
11 |
+
* @description
|
12 |
+
* Return the formatted date string in ISO 9075 format. Options may be passed to control the parts and notations of the date.
|
13 |
+
*
|
14 |
+
* @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
|
15 |
+
*
|
16 |
+
* @param date - The original date
|
17 |
+
* @param options - An object with options.
|
18 |
+
*
|
19 |
+
* @returns The formatted date string
|
20 |
+
*
|
21 |
+
* @throws `date` must not be Invalid Date
|
22 |
+
*
|
23 |
+
* @example
|
24 |
+
* // Represent 18 September 2019 in ISO 9075 format:
|
25 |
+
* const result = formatISO9075(new Date(2019, 8, 18, 19, 0, 52))
|
26 |
+
* //=> '2019-09-18 19:00:52'
|
27 |
+
*
|
28 |
+
* @example
|
29 |
+
* // Represent 18 September 2019 in ISO 9075, short format:
|
30 |
+
* const result = formatISO9075(new Date(2019, 8, 18, 19, 0, 52), { format: 'basic' })
|
31 |
+
* //=> '20190918 190052'
|
32 |
+
*
|
33 |
+
* @example
|
34 |
+
* // Represent 18 September 2019 in ISO 9075 format, date only:
|
35 |
+
* const result = formatISO9075(new Date(2019, 8, 18, 19, 0, 52), { representation: 'date' })
|
36 |
+
* //=> '2019-09-18'
|
37 |
+
*
|
38 |
+
* @example
|
39 |
+
* // Represent 18 September 2019 in ISO 9075 format, time only:
|
40 |
+
* const result = formatISO9075(new Date(2019, 8, 18, 19, 0, 52), { representation: 'time' })
|
41 |
+
* //=> '19:00:52'
|
42 |
+
*/
|
43 |
+
export declare function formatISO9075<DateType extends Date>(
|
44 |
+
date: DateType | number | string,
|
45 |
+
options?: FormatISO9075Options,
|
46 |
+
): string;
|