@ciwergrp/nuxid 1.4.3 → 1.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/module.json +1 -1
- package/dist/module.mjs +102 -1
- package/dist/runtime/helper/date/bounds.d.ts +17 -0
- package/dist/runtime/helper/date/bounds.js +67 -0
- package/dist/runtime/helper/date/compare.d.ts +21 -0
- package/dist/runtime/helper/date/compare.js +83 -0
- package/dist/runtime/helper/date/diff.d.ts +8 -0
- package/dist/runtime/helper/date/diff.js +31 -0
- package/dist/runtime/helper/date/format.d.ts +43 -0
- package/dist/runtime/helper/date/format.js +74 -0
- package/dist/runtime/helper/date/index.d.ts +107 -0
- package/dist/runtime/helper/date/index.js +290 -0
- package/dist/runtime/helper/date/input.d.ts +6 -0
- package/dist/runtime/helper/date/input.js +41 -0
- package/dist/runtime/helper/date/now.d.ts +4 -0
- package/dist/runtime/helper/date/now.js +13 -0
- package/dist/runtime/helper/date/parse.d.ts +5 -0
- package/dist/runtime/helper/date/parse.js +9 -0
- package/dist/runtime/helper/date/shift.d.ts +29 -0
- package/dist/runtime/helper/date/shift.js +101 -0
- package/dist/runtime/helper/index.d.ts +1 -0
- package/dist/runtime/helper/index.js +1 -0
- package/package.json +16 -18
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -205,6 +205,7 @@ function registerHelperFeature(options, { from }) {
|
|
|
205
205
|
addImports({ name: "object", as: "object", from });
|
|
206
206
|
addImports({ name: "number", as: "number", from });
|
|
207
207
|
addImports({ name: "string", as: "string", from });
|
|
208
|
+
addImports({ name: "dt", as: "dt", from });
|
|
208
209
|
return;
|
|
209
210
|
}
|
|
210
211
|
const numberExports = [
|
|
@@ -308,6 +309,102 @@ function registerHelperFeature(options, { from }) {
|
|
|
308
309
|
"useLocale",
|
|
309
310
|
"withLocale"
|
|
310
311
|
];
|
|
312
|
+
const dateExports = [
|
|
313
|
+
"toDate",
|
|
314
|
+
"toUnix",
|
|
315
|
+
"toMillis",
|
|
316
|
+
"fromUnix",
|
|
317
|
+
"fromTimestamp",
|
|
318
|
+
"now",
|
|
319
|
+
"today",
|
|
320
|
+
"tomorrow",
|
|
321
|
+
"yesterday",
|
|
322
|
+
"dateFormat",
|
|
323
|
+
"formatISO",
|
|
324
|
+
"formatRFC3339",
|
|
325
|
+
"formatRFC7231",
|
|
326
|
+
"fromNow",
|
|
327
|
+
"diffForHumans",
|
|
328
|
+
"toDateString",
|
|
329
|
+
"toTimeString",
|
|
330
|
+
"toDateTimeString",
|
|
331
|
+
"toIsoString",
|
|
332
|
+
"toRfc3339String",
|
|
333
|
+
"toRfc7231String",
|
|
334
|
+
"dateParse",
|
|
335
|
+
"parseISO",
|
|
336
|
+
"addSecond",
|
|
337
|
+
"addSeconds",
|
|
338
|
+
"addMinute",
|
|
339
|
+
"addMinutes",
|
|
340
|
+
"addHour",
|
|
341
|
+
"addHours",
|
|
342
|
+
"addDay",
|
|
343
|
+
"addDays",
|
|
344
|
+
"addWeek",
|
|
345
|
+
"addWeeks",
|
|
346
|
+
"addMonth",
|
|
347
|
+
"addMonths",
|
|
348
|
+
"addYear",
|
|
349
|
+
"addYears",
|
|
350
|
+
"subSecond",
|
|
351
|
+
"subSeconds",
|
|
352
|
+
"subMinute",
|
|
353
|
+
"subMinutes",
|
|
354
|
+
"subHour",
|
|
355
|
+
"subHours",
|
|
356
|
+
"subDay",
|
|
357
|
+
"subDays",
|
|
358
|
+
"subWeek",
|
|
359
|
+
"subWeeks",
|
|
360
|
+
"subMonth",
|
|
361
|
+
"subMonths",
|
|
362
|
+
"subYear",
|
|
363
|
+
"subYears",
|
|
364
|
+
"startOfSecond",
|
|
365
|
+
"endOfSecond",
|
|
366
|
+
"startOfMinute",
|
|
367
|
+
"endOfMinute",
|
|
368
|
+
"startOfHour",
|
|
369
|
+
"endOfHour",
|
|
370
|
+
"startOfDay",
|
|
371
|
+
"endOfDay",
|
|
372
|
+
"startOfWeek",
|
|
373
|
+
"endOfWeek",
|
|
374
|
+
"startOfMonth",
|
|
375
|
+
"endOfMonth",
|
|
376
|
+
"startOfQuarter",
|
|
377
|
+
"endOfQuarter",
|
|
378
|
+
"startOfYear",
|
|
379
|
+
"endOfYear",
|
|
380
|
+
"diffInSeconds",
|
|
381
|
+
"diffInMinutes",
|
|
382
|
+
"diffInHours",
|
|
383
|
+
"diffInDays",
|
|
384
|
+
"diffInWeeks",
|
|
385
|
+
"diffInMonths",
|
|
386
|
+
"diffInYears",
|
|
387
|
+
"isBefore",
|
|
388
|
+
"isAfter",
|
|
389
|
+
"isEqual",
|
|
390
|
+
"isSameSecond",
|
|
391
|
+
"isSameMinute",
|
|
392
|
+
"isSameHour",
|
|
393
|
+
"isSameDay",
|
|
394
|
+
"isSameWeek",
|
|
395
|
+
"isSameMonth",
|
|
396
|
+
"isSameYear",
|
|
397
|
+
"isToday",
|
|
398
|
+
"isTomorrow",
|
|
399
|
+
"isYesterday",
|
|
400
|
+
"isWeekend",
|
|
401
|
+
"isPast",
|
|
402
|
+
"isFuture",
|
|
403
|
+
"isThisWeek",
|
|
404
|
+
"isThisMonth",
|
|
405
|
+
"isThisYear",
|
|
406
|
+
"isValid"
|
|
407
|
+
];
|
|
311
408
|
for (const name of numberExports) {
|
|
312
409
|
const as = `${capitalize(name)}`;
|
|
313
410
|
addImports({ name, as, from });
|
|
@@ -324,6 +421,10 @@ function registerHelperFeature(options, { from }) {
|
|
|
324
421
|
const as = `${capitalize(name)}`;
|
|
325
422
|
addImports({ name, as, from });
|
|
326
423
|
}
|
|
424
|
+
for (const name of dateExports) {
|
|
425
|
+
const as = `${capitalize(name)}`;
|
|
426
|
+
addImports({ name, as, from });
|
|
427
|
+
}
|
|
327
428
|
}
|
|
328
429
|
function capitalize(value) {
|
|
329
430
|
return value.charAt(0).toUpperCase() + value.slice(1);
|
|
@@ -479,7 +580,7 @@ const module$1 = defineNuxtModule({
|
|
|
479
580
|
moduleDependencies() {
|
|
480
581
|
const dependencies = {
|
|
481
582
|
"@sentry/nuxt": {
|
|
482
|
-
version: "10.
|
|
583
|
+
version: "10.33.0"
|
|
483
584
|
}
|
|
484
585
|
};
|
|
485
586
|
return dependencies;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { DateInput } from './input.js';
|
|
2
|
+
export declare function startOfSecond(date: DateInput): Date;
|
|
3
|
+
export declare function endOfSecond(date: DateInput): Date;
|
|
4
|
+
export declare function startOfMinute(date: DateInput): Date;
|
|
5
|
+
export declare function endOfMinute(date: DateInput): Date;
|
|
6
|
+
export declare function startOfHour(date: DateInput): Date;
|
|
7
|
+
export declare function endOfHour(date: DateInput): Date;
|
|
8
|
+
export declare function startOfDay(date: DateInput): Date;
|
|
9
|
+
export declare function endOfDay(date: DateInput): Date;
|
|
10
|
+
export declare function startOfWeek(date: DateInput): Date;
|
|
11
|
+
export declare function endOfWeek(date: DateInput): Date;
|
|
12
|
+
export declare function startOfMonth(date: DateInput): Date;
|
|
13
|
+
export declare function endOfMonth(date: DateInput): Date;
|
|
14
|
+
export declare function startOfQuarter(date: DateInput): Date;
|
|
15
|
+
export declare function endOfQuarter(date: DateInput): Date;
|
|
16
|
+
export declare function startOfYear(date: DateInput): Date;
|
|
17
|
+
export declare function endOfYear(date: DateInput): Date;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import {
|
|
2
|
+
endOfDay as endOfDayBase,
|
|
3
|
+
endOfHour as endOfHourBase,
|
|
4
|
+
endOfMinute as endOfMinuteBase,
|
|
5
|
+
endOfMonth as endOfMonthBase,
|
|
6
|
+
endOfQuarter as endOfQuarterBase,
|
|
7
|
+
endOfSecond as endOfSecondBase,
|
|
8
|
+
endOfWeek as endOfWeekBase,
|
|
9
|
+
endOfYear as endOfYearBase,
|
|
10
|
+
startOfDay as startOfDayBase,
|
|
11
|
+
startOfHour as startOfHourBase,
|
|
12
|
+
startOfMinute as startOfMinuteBase,
|
|
13
|
+
startOfMonth as startOfMonthBase,
|
|
14
|
+
startOfQuarter as startOfQuarterBase,
|
|
15
|
+
startOfSecond as startOfSecondBase,
|
|
16
|
+
startOfWeek as startOfWeekBase,
|
|
17
|
+
startOfYear as startOfYearBase
|
|
18
|
+
} from "date-fns";
|
|
19
|
+
import { toDate } from "./input.js";
|
|
20
|
+
export function startOfSecond(date) {
|
|
21
|
+
return startOfSecondBase(toDate(date));
|
|
22
|
+
}
|
|
23
|
+
export function endOfSecond(date) {
|
|
24
|
+
return endOfSecondBase(toDate(date));
|
|
25
|
+
}
|
|
26
|
+
export function startOfMinute(date) {
|
|
27
|
+
return startOfMinuteBase(toDate(date));
|
|
28
|
+
}
|
|
29
|
+
export function endOfMinute(date) {
|
|
30
|
+
return endOfMinuteBase(toDate(date));
|
|
31
|
+
}
|
|
32
|
+
export function startOfHour(date) {
|
|
33
|
+
return startOfHourBase(toDate(date));
|
|
34
|
+
}
|
|
35
|
+
export function endOfHour(date) {
|
|
36
|
+
return endOfHourBase(toDate(date));
|
|
37
|
+
}
|
|
38
|
+
export function startOfDay(date) {
|
|
39
|
+
return startOfDayBase(toDate(date));
|
|
40
|
+
}
|
|
41
|
+
export function endOfDay(date) {
|
|
42
|
+
return endOfDayBase(toDate(date));
|
|
43
|
+
}
|
|
44
|
+
export function startOfWeek(date) {
|
|
45
|
+
return startOfWeekBase(toDate(date));
|
|
46
|
+
}
|
|
47
|
+
export function endOfWeek(date) {
|
|
48
|
+
return endOfWeekBase(toDate(date));
|
|
49
|
+
}
|
|
50
|
+
export function startOfMonth(date) {
|
|
51
|
+
return startOfMonthBase(toDate(date));
|
|
52
|
+
}
|
|
53
|
+
export function endOfMonth(date) {
|
|
54
|
+
return endOfMonthBase(toDate(date));
|
|
55
|
+
}
|
|
56
|
+
export function startOfQuarter(date) {
|
|
57
|
+
return startOfQuarterBase(toDate(date));
|
|
58
|
+
}
|
|
59
|
+
export function endOfQuarter(date) {
|
|
60
|
+
return endOfQuarterBase(toDate(date));
|
|
61
|
+
}
|
|
62
|
+
export function startOfYear(date) {
|
|
63
|
+
return startOfYearBase(toDate(date));
|
|
64
|
+
}
|
|
65
|
+
export function endOfYear(date) {
|
|
66
|
+
return endOfYearBase(toDate(date));
|
|
67
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { DateInput } from './input.js';
|
|
2
|
+
export declare function isBefore(date: DateInput, dateToCompare: DateInput): boolean;
|
|
3
|
+
export declare function isAfter(date: DateInput, dateToCompare: DateInput): boolean;
|
|
4
|
+
export declare function isEqual(date: DateInput, dateToCompare: DateInput): boolean;
|
|
5
|
+
export declare function isSameSecond(date: DateInput, dateToCompare: DateInput): boolean;
|
|
6
|
+
export declare function isSameMinute(date: DateInput, dateToCompare: DateInput): boolean;
|
|
7
|
+
export declare function isSameHour(date: DateInput, dateToCompare: DateInput): boolean;
|
|
8
|
+
export declare function isSameDay(date: DateInput, dateToCompare: DateInput): boolean;
|
|
9
|
+
export declare function isSameWeek(date: DateInput, dateToCompare: DateInput): boolean;
|
|
10
|
+
export declare function isSameMonth(date: DateInput, dateToCompare: DateInput): boolean;
|
|
11
|
+
export declare function isSameYear(date: DateInput, dateToCompare: DateInput): boolean;
|
|
12
|
+
export declare function isToday(date: DateInput): boolean;
|
|
13
|
+
export declare function isTomorrow(date: DateInput): boolean;
|
|
14
|
+
export declare function isYesterday(date: DateInput): boolean;
|
|
15
|
+
export declare function isWeekend(date: DateInput): boolean;
|
|
16
|
+
export declare function isPast(date: DateInput): boolean;
|
|
17
|
+
export declare function isFuture(date: DateInput): boolean;
|
|
18
|
+
export declare function isThisWeek(date: DateInput): boolean;
|
|
19
|
+
export declare function isThisMonth(date: DateInput): boolean;
|
|
20
|
+
export declare function isThisYear(date: DateInput): boolean;
|
|
21
|
+
export declare function isValid(date: DateInput): boolean;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import {
|
|
2
|
+
isAfter as isAfterBase,
|
|
3
|
+
isBefore as isBeforeBase,
|
|
4
|
+
isEqual as isEqualBase,
|
|
5
|
+
isFuture as isFutureBase,
|
|
6
|
+
isPast as isPastBase,
|
|
7
|
+
isSameDay as isSameDayBase,
|
|
8
|
+
isSameHour as isSameHourBase,
|
|
9
|
+
isSameMinute as isSameMinuteBase,
|
|
10
|
+
isSameMonth as isSameMonthBase,
|
|
11
|
+
isSameSecond as isSameSecondBase,
|
|
12
|
+
isSameWeek as isSameWeekBase,
|
|
13
|
+
isSameYear as isSameYearBase,
|
|
14
|
+
isThisMonth as isThisMonthBase,
|
|
15
|
+
isThisWeek as isThisWeekBase,
|
|
16
|
+
isThisYear as isThisYearBase,
|
|
17
|
+
isToday as isTodayBase,
|
|
18
|
+
isTomorrow as isTomorrowBase,
|
|
19
|
+
isValid as isValidBase,
|
|
20
|
+
isWeekend as isWeekendBase,
|
|
21
|
+
isYesterday as isYesterdayBase
|
|
22
|
+
} from "date-fns";
|
|
23
|
+
import { toDate } from "./input.js";
|
|
24
|
+
export function isBefore(date, dateToCompare) {
|
|
25
|
+
return isBeforeBase(toDate(date), toDate(dateToCompare));
|
|
26
|
+
}
|
|
27
|
+
export function isAfter(date, dateToCompare) {
|
|
28
|
+
return isAfterBase(toDate(date), toDate(dateToCompare));
|
|
29
|
+
}
|
|
30
|
+
export function isEqual(date, dateToCompare) {
|
|
31
|
+
return isEqualBase(toDate(date), toDate(dateToCompare));
|
|
32
|
+
}
|
|
33
|
+
export function isSameSecond(date, dateToCompare) {
|
|
34
|
+
return isSameSecondBase(toDate(date), toDate(dateToCompare));
|
|
35
|
+
}
|
|
36
|
+
export function isSameMinute(date, dateToCompare) {
|
|
37
|
+
return isSameMinuteBase(toDate(date), toDate(dateToCompare));
|
|
38
|
+
}
|
|
39
|
+
export function isSameHour(date, dateToCompare) {
|
|
40
|
+
return isSameHourBase(toDate(date), toDate(dateToCompare));
|
|
41
|
+
}
|
|
42
|
+
export function isSameDay(date, dateToCompare) {
|
|
43
|
+
return isSameDayBase(toDate(date), toDate(dateToCompare));
|
|
44
|
+
}
|
|
45
|
+
export function isSameWeek(date, dateToCompare) {
|
|
46
|
+
return isSameWeekBase(toDate(date), toDate(dateToCompare));
|
|
47
|
+
}
|
|
48
|
+
export function isSameMonth(date, dateToCompare) {
|
|
49
|
+
return isSameMonthBase(toDate(date), toDate(dateToCompare));
|
|
50
|
+
}
|
|
51
|
+
export function isSameYear(date, dateToCompare) {
|
|
52
|
+
return isSameYearBase(toDate(date), toDate(dateToCompare));
|
|
53
|
+
}
|
|
54
|
+
export function isToday(date) {
|
|
55
|
+
return isTodayBase(toDate(date));
|
|
56
|
+
}
|
|
57
|
+
export function isTomorrow(date) {
|
|
58
|
+
return isTomorrowBase(toDate(date));
|
|
59
|
+
}
|
|
60
|
+
export function isYesterday(date) {
|
|
61
|
+
return isYesterdayBase(toDate(date));
|
|
62
|
+
}
|
|
63
|
+
export function isWeekend(date) {
|
|
64
|
+
return isWeekendBase(toDate(date));
|
|
65
|
+
}
|
|
66
|
+
export function isPast(date) {
|
|
67
|
+
return isPastBase(toDate(date));
|
|
68
|
+
}
|
|
69
|
+
export function isFuture(date) {
|
|
70
|
+
return isFutureBase(toDate(date));
|
|
71
|
+
}
|
|
72
|
+
export function isThisWeek(date) {
|
|
73
|
+
return isThisWeekBase(toDate(date));
|
|
74
|
+
}
|
|
75
|
+
export function isThisMonth(date) {
|
|
76
|
+
return isThisMonthBase(toDate(date));
|
|
77
|
+
}
|
|
78
|
+
export function isThisYear(date) {
|
|
79
|
+
return isThisYearBase(toDate(date));
|
|
80
|
+
}
|
|
81
|
+
export function isValid(date) {
|
|
82
|
+
return isValidBase(toDate(date));
|
|
83
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { DateInput } from './input.js';
|
|
2
|
+
export declare function diffInSeconds(dateLeft: DateInput, dateRight: DateInput): number;
|
|
3
|
+
export declare function diffInMinutes(dateLeft: DateInput, dateRight: DateInput): number;
|
|
4
|
+
export declare function diffInHours(dateLeft: DateInput, dateRight: DateInput): number;
|
|
5
|
+
export declare function diffInDays(dateLeft: DateInput, dateRight: DateInput): number;
|
|
6
|
+
export declare function diffInWeeks(dateLeft: DateInput, dateRight: DateInput): number;
|
|
7
|
+
export declare function diffInMonths(dateLeft: DateInput, dateRight: DateInput): number;
|
|
8
|
+
export declare function diffInYears(dateLeft: DateInput, dateRight: DateInput): number;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import {
|
|
2
|
+
differenceInDays,
|
|
3
|
+
differenceInHours,
|
|
4
|
+
differenceInMinutes,
|
|
5
|
+
differenceInMonths,
|
|
6
|
+
differenceInSeconds,
|
|
7
|
+
differenceInWeeks,
|
|
8
|
+
differenceInYears
|
|
9
|
+
} from "date-fns";
|
|
10
|
+
import { toDate } from "./input.js";
|
|
11
|
+
export function diffInSeconds(dateLeft, dateRight) {
|
|
12
|
+
return differenceInSeconds(toDate(dateLeft), toDate(dateRight));
|
|
13
|
+
}
|
|
14
|
+
export function diffInMinutes(dateLeft, dateRight) {
|
|
15
|
+
return differenceInMinutes(toDate(dateLeft), toDate(dateRight));
|
|
16
|
+
}
|
|
17
|
+
export function diffInHours(dateLeft, dateRight) {
|
|
18
|
+
return differenceInHours(toDate(dateLeft), toDate(dateRight));
|
|
19
|
+
}
|
|
20
|
+
export function diffInDays(dateLeft, dateRight) {
|
|
21
|
+
return differenceInDays(toDate(dateLeft), toDate(dateRight));
|
|
22
|
+
}
|
|
23
|
+
export function diffInWeeks(dateLeft, dateRight) {
|
|
24
|
+
return differenceInWeeks(toDate(dateLeft), toDate(dateRight));
|
|
25
|
+
}
|
|
26
|
+
export function diffInMonths(dateLeft, dateRight) {
|
|
27
|
+
return differenceInMonths(toDate(dateLeft), toDate(dateRight));
|
|
28
|
+
}
|
|
29
|
+
export function diffInYears(dateLeft, dateRight) {
|
|
30
|
+
return differenceInYears(toDate(dateLeft), toDate(dateRight));
|
|
31
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { FormatDistanceOptions, FormatDistanceToNowOptions, FormatISOOptions, FormatOptions, FormatRFC3339Options } from 'date-fns';
|
|
2
|
+
import type { DateInput } from './input.js';
|
|
3
|
+
declare const formatAliases: {
|
|
4
|
+
readonly 'YYYY-MM-DD': "yyyy-MM-dd";
|
|
5
|
+
readonly 'YYYY-MM-DD HH:mm': "yyyy-MM-dd HH:mm";
|
|
6
|
+
readonly 'YYYY-MM-DD HH:mm:ss': "yyyy-MM-dd HH:mm:ss";
|
|
7
|
+
readonly 'YYYY-MM-DD HH:mm:ss.SSS': "yyyy-MM-dd HH:mm:ss.SSS";
|
|
8
|
+
readonly 'YYYY-MM-DD HH:mm:ssZ': "yyyy-MM-dd HH:mm:ssXXX";
|
|
9
|
+
readonly 'YYYY-MM-DD HH:mm:ss.SSSZ': "yyyy-MM-dd HH:mm:ss.SSSXXX";
|
|
10
|
+
readonly 'YYYY/MM/DD': "yyyy/MM/dd";
|
|
11
|
+
readonly 'YYYY/MM/DD HH:mm': "yyyy/MM/dd HH:mm";
|
|
12
|
+
readonly 'YYYY/MM/DD HH:mm:ss': "yyyy/MM/dd HH:mm:ss";
|
|
13
|
+
readonly 'DD/MM/YYYY': "dd/MM/yyyy";
|
|
14
|
+
readonly 'MM/DD/YYYY': "MM/dd/yyyy";
|
|
15
|
+
readonly 'DD-MM-YYYY': "dd-MM-yyyy";
|
|
16
|
+
readonly 'MM-DD-YYYY': "MM-dd-yyyy";
|
|
17
|
+
readonly 'YYYY-MM': "yyyy-MM";
|
|
18
|
+
readonly 'YYYY/MM': "yyyy/MM";
|
|
19
|
+
readonly YYYY: "yyyy";
|
|
20
|
+
readonly 'DD MMM YYYY': "dd MMM yyyy";
|
|
21
|
+
readonly 'MMM DD, YYYY': "MMM dd, yyyy";
|
|
22
|
+
readonly 'HH:mm': "HH:mm";
|
|
23
|
+
readonly 'HH:mm:ss': "HH:mm:ss";
|
|
24
|
+
readonly 'HH:mm:ss.SSS': "HH:mm:ss.SSS";
|
|
25
|
+
readonly 'hh:mm A': "hh:mm a";
|
|
26
|
+
readonly 'hh:mm:ss A': "hh:mm:ss a";
|
|
27
|
+
};
|
|
28
|
+
export type DateFormatPreset = keyof typeof formatAliases;
|
|
29
|
+
export type DateFormatInput = DateFormatPreset | (string & {});
|
|
30
|
+
export declare function resolveFormatString(formatString: DateFormatInput): "yyyy-MM-dd" | "yyyy-MM-dd HH:mm" | "yyyy-MM-dd HH:mm:ss" | "yyyy-MM-dd HH:mm:ss.SSS" | "yyyy-MM-dd HH:mm:ssXXX" | "yyyy-MM-dd HH:mm:ss.SSSXXX" | "yyyy/MM/dd" | "yyyy/MM/dd HH:mm" | "yyyy/MM/dd HH:mm:ss" | "dd/MM/yyyy" | "MM/dd/yyyy" | "dd-MM-yyyy" | "MM-dd-yyyy" | "yyyy-MM" | "yyyy/MM" | "yyyy" | "dd MMM yyyy" | "MMM dd, yyyy" | "HH:mm" | "HH:mm:ss" | "HH:mm:ss.SSS" | "hh:mm a" | "hh:mm:ss a";
|
|
31
|
+
export declare function format(date: DateInput, formatString: DateFormatInput, options?: FormatOptions): string;
|
|
32
|
+
export declare function formatISO(date: DateInput, options?: FormatISOOptions): string;
|
|
33
|
+
export declare function formatRFC3339(date: DateInput, options?: FormatRFC3339Options): string;
|
|
34
|
+
export declare function formatRFC7231(date: DateInput): string;
|
|
35
|
+
export declare function fromNow(date: DateInput, options?: FormatDistanceToNowOptions): string;
|
|
36
|
+
export declare function diffForHumans(date: DateInput, baseDate?: DateInput, options?: FormatDistanceOptions): string;
|
|
37
|
+
export declare function toDateString(date: DateInput): string;
|
|
38
|
+
export declare function toTimeString(date: DateInput): string;
|
|
39
|
+
export declare function toDateTimeString(date: DateInput): string;
|
|
40
|
+
export declare function toIsoString(date: DateInput): string;
|
|
41
|
+
export declare function toRfc3339String(date: DateInput): string;
|
|
42
|
+
export declare function toRfc7231String(date: DateInput): string;
|
|
43
|
+
export {};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import {
|
|
2
|
+
format as formatDate,
|
|
3
|
+
formatDistance,
|
|
4
|
+
formatDistanceToNow,
|
|
5
|
+
formatISO as formatISODate,
|
|
6
|
+
formatRFC3339 as formatRFC3339Date,
|
|
7
|
+
formatRFC7231 as formatRFC7231Date
|
|
8
|
+
} from "date-fns";
|
|
9
|
+
import { toDate } from "./input.js";
|
|
10
|
+
const formatAliases = {
|
|
11
|
+
"YYYY-MM-DD": "yyyy-MM-dd",
|
|
12
|
+
"YYYY-MM-DD HH:mm": "yyyy-MM-dd HH:mm",
|
|
13
|
+
"YYYY-MM-DD HH:mm:ss": "yyyy-MM-dd HH:mm:ss",
|
|
14
|
+
"YYYY-MM-DD HH:mm:ss.SSS": "yyyy-MM-dd HH:mm:ss.SSS",
|
|
15
|
+
"YYYY-MM-DD HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssXXX",
|
|
16
|
+
"YYYY-MM-DD HH:mm:ss.SSSZ": "yyyy-MM-dd HH:mm:ss.SSSXXX",
|
|
17
|
+
"YYYY/MM/DD": "yyyy/MM/dd",
|
|
18
|
+
"YYYY/MM/DD HH:mm": "yyyy/MM/dd HH:mm",
|
|
19
|
+
"YYYY/MM/DD HH:mm:ss": "yyyy/MM/dd HH:mm:ss",
|
|
20
|
+
"DD/MM/YYYY": "dd/MM/yyyy",
|
|
21
|
+
"MM/DD/YYYY": "MM/dd/yyyy",
|
|
22
|
+
"DD-MM-YYYY": "dd-MM-yyyy",
|
|
23
|
+
"MM-DD-YYYY": "MM-dd-yyyy",
|
|
24
|
+
"YYYY-MM": "yyyy-MM",
|
|
25
|
+
"YYYY/MM": "yyyy/MM",
|
|
26
|
+
"YYYY": "yyyy",
|
|
27
|
+
"DD MMM YYYY": "dd MMM yyyy",
|
|
28
|
+
"MMM DD, YYYY": "MMM dd, yyyy",
|
|
29
|
+
"HH:mm": "HH:mm",
|
|
30
|
+
"HH:mm:ss": "HH:mm:ss",
|
|
31
|
+
"HH:mm:ss.SSS": "HH:mm:ss.SSS",
|
|
32
|
+
"hh:mm A": "hh:mm a",
|
|
33
|
+
"hh:mm:ss A": "hh:mm:ss a"
|
|
34
|
+
};
|
|
35
|
+
export function resolveFormatString(formatString) {
|
|
36
|
+
return formatAliases[formatString] ?? formatString;
|
|
37
|
+
}
|
|
38
|
+
export function format(date, formatString, options) {
|
|
39
|
+
return formatDate(toDate(date), resolveFormatString(formatString), options);
|
|
40
|
+
}
|
|
41
|
+
export function formatISO(date, options) {
|
|
42
|
+
return formatISODate(toDate(date), options);
|
|
43
|
+
}
|
|
44
|
+
export function formatRFC3339(date, options) {
|
|
45
|
+
return formatRFC3339Date(toDate(date), options);
|
|
46
|
+
}
|
|
47
|
+
export function formatRFC7231(date) {
|
|
48
|
+
return formatRFC7231Date(toDate(date));
|
|
49
|
+
}
|
|
50
|
+
export function fromNow(date, options = {}) {
|
|
51
|
+
return formatDistanceToNow(toDate(date), { addSuffix: true, ...options });
|
|
52
|
+
}
|
|
53
|
+
export function diffForHumans(date, baseDate, options = {}) {
|
|
54
|
+
const resolvedBase = baseDate ? toDate(baseDate) : /* @__PURE__ */ new Date();
|
|
55
|
+
return formatDistance(toDate(date), resolvedBase, { addSuffix: true, ...options });
|
|
56
|
+
}
|
|
57
|
+
export function toDateString(date) {
|
|
58
|
+
return formatDate(toDate(date), "yyyy-MM-dd");
|
|
59
|
+
}
|
|
60
|
+
export function toTimeString(date) {
|
|
61
|
+
return formatDate(toDate(date), "HH:mm:ss");
|
|
62
|
+
}
|
|
63
|
+
export function toDateTimeString(date) {
|
|
64
|
+
return formatDate(toDate(date), "yyyy-MM-dd HH:mm:ss");
|
|
65
|
+
}
|
|
66
|
+
export function toIsoString(date) {
|
|
67
|
+
return formatISODate(toDate(date));
|
|
68
|
+
}
|
|
69
|
+
export function toRfc3339String(date) {
|
|
70
|
+
return formatRFC3339Date(toDate(date));
|
|
71
|
+
}
|
|
72
|
+
export function toRfc7231String(date) {
|
|
73
|
+
return formatRFC7231Date(toDate(date));
|
|
74
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { type DateInput, fromTimestamp, fromUnix, toDate, toMillis, toUnix } from './input.js';
|
|
2
|
+
import { now, today, tomorrow, yesterday } from './now.js';
|
|
3
|
+
import { diffForHumans, format, formatISO, formatRFC3339, formatRFC7231, fromNow, toDateString, toDateTimeString, toIsoString, toRfc3339String, toRfc7231String, toTimeString } from './format.js';
|
|
4
|
+
import { parse, parseISO } from './parse.js';
|
|
5
|
+
import { addDay, addDays, addHour, addHours, addMinute, addMinutes, addMonth, addMonths, addSecond, addSeconds, addWeek, addWeeks, addYear, addYears, subDay, subDays, subHour, subHours, subMinute, subMinutes, subMonth, subMonths, subSecond, subSeconds, subWeek, subWeeks, subYear, subYears } from './shift.js';
|
|
6
|
+
import { endOfDay, endOfHour, endOfMinute, endOfMonth, endOfQuarter, endOfSecond, endOfWeek, endOfYear, startOfDay, startOfHour, startOfMinute, startOfMonth, startOfQuarter, startOfSecond, startOfWeek, startOfYear } from './bounds.js';
|
|
7
|
+
import { diffInDays, diffInHours, diffInMinutes, diffInMonths, diffInSeconds, diffInWeeks, diffInYears } from './diff.js';
|
|
8
|
+
import { isAfter, isBefore, isEqual, isFuture, isPast, isSameDay, isSameHour, isSameMinute, isSameMonth, isSameSecond, isSameWeek, isSameYear, isThisMonth, isThisWeek, isThisYear, isToday, isTomorrow, isValid, isWeekend, isYesterday } from './compare.js';
|
|
9
|
+
export type { DateFormatPreset } from './format.js';
|
|
10
|
+
export interface DateHelper {
|
|
11
|
+
toDate: typeof toDate;
|
|
12
|
+
toUnix: typeof toUnix;
|
|
13
|
+
toMillis: typeof toMillis;
|
|
14
|
+
fromUnix: typeof fromUnix;
|
|
15
|
+
fromTimestamp: typeof fromTimestamp;
|
|
16
|
+
now: typeof now;
|
|
17
|
+
today: typeof today;
|
|
18
|
+
tomorrow: typeof tomorrow;
|
|
19
|
+
yesterday: typeof yesterday;
|
|
20
|
+
format: typeof format;
|
|
21
|
+
formatISO: typeof formatISO;
|
|
22
|
+
formatRFC3339: typeof formatRFC3339;
|
|
23
|
+
formatRFC7231: typeof formatRFC7231;
|
|
24
|
+
fromNow: typeof fromNow;
|
|
25
|
+
diffForHumans: typeof diffForHumans;
|
|
26
|
+
toDateString: typeof toDateString;
|
|
27
|
+
toTimeString: typeof toTimeString;
|
|
28
|
+
toDateTimeString: typeof toDateTimeString;
|
|
29
|
+
toIsoString: typeof toIsoString;
|
|
30
|
+
toRfc3339String: typeof toRfc3339String;
|
|
31
|
+
toRfc7231String: typeof toRfc7231String;
|
|
32
|
+
parse: typeof parse;
|
|
33
|
+
parseISO: typeof parseISO;
|
|
34
|
+
addSecond: typeof addSecond;
|
|
35
|
+
addSeconds: typeof addSeconds;
|
|
36
|
+
addMinute: typeof addMinute;
|
|
37
|
+
addMinutes: typeof addMinutes;
|
|
38
|
+
addHour: typeof addHour;
|
|
39
|
+
addHours: typeof addHours;
|
|
40
|
+
addDay: typeof addDay;
|
|
41
|
+
addDays: typeof addDays;
|
|
42
|
+
addWeek: typeof addWeek;
|
|
43
|
+
addWeeks: typeof addWeeks;
|
|
44
|
+
addMonth: typeof addMonth;
|
|
45
|
+
addMonths: typeof addMonths;
|
|
46
|
+
addYear: typeof addYear;
|
|
47
|
+
addYears: typeof addYears;
|
|
48
|
+
subSecond: typeof subSecond;
|
|
49
|
+
subSeconds: typeof subSeconds;
|
|
50
|
+
subMinute: typeof subMinute;
|
|
51
|
+
subMinutes: typeof subMinutes;
|
|
52
|
+
subHour: typeof subHour;
|
|
53
|
+
subHours: typeof subHours;
|
|
54
|
+
subDay: typeof subDay;
|
|
55
|
+
subDays: typeof subDays;
|
|
56
|
+
subWeek: typeof subWeek;
|
|
57
|
+
subWeeks: typeof subWeeks;
|
|
58
|
+
subMonth: typeof subMonth;
|
|
59
|
+
subMonths: typeof subMonths;
|
|
60
|
+
subYear: typeof subYear;
|
|
61
|
+
subYears: typeof subYears;
|
|
62
|
+
startOfSecond: typeof startOfSecond;
|
|
63
|
+
endOfSecond: typeof endOfSecond;
|
|
64
|
+
startOfMinute: typeof startOfMinute;
|
|
65
|
+
endOfMinute: typeof endOfMinute;
|
|
66
|
+
startOfHour: typeof startOfHour;
|
|
67
|
+
endOfHour: typeof endOfHour;
|
|
68
|
+
startOfDay: typeof startOfDay;
|
|
69
|
+
endOfDay: typeof endOfDay;
|
|
70
|
+
startOfWeek: typeof startOfWeek;
|
|
71
|
+
endOfWeek: typeof endOfWeek;
|
|
72
|
+
startOfMonth: typeof startOfMonth;
|
|
73
|
+
endOfMonth: typeof endOfMonth;
|
|
74
|
+
startOfQuarter: typeof startOfQuarter;
|
|
75
|
+
endOfQuarter: typeof endOfQuarter;
|
|
76
|
+
startOfYear: typeof startOfYear;
|
|
77
|
+
endOfYear: typeof endOfYear;
|
|
78
|
+
diffInSeconds: typeof diffInSeconds;
|
|
79
|
+
diffInMinutes: typeof diffInMinutes;
|
|
80
|
+
diffInHours: typeof diffInHours;
|
|
81
|
+
diffInDays: typeof diffInDays;
|
|
82
|
+
diffInWeeks: typeof diffInWeeks;
|
|
83
|
+
diffInMonths: typeof diffInMonths;
|
|
84
|
+
diffInYears: typeof diffInYears;
|
|
85
|
+
isBefore: typeof isBefore;
|
|
86
|
+
isAfter: typeof isAfter;
|
|
87
|
+
isEqual: typeof isEqual;
|
|
88
|
+
isSameSecond: typeof isSameSecond;
|
|
89
|
+
isSameMinute: typeof isSameMinute;
|
|
90
|
+
isSameHour: typeof isSameHour;
|
|
91
|
+
isSameDay: typeof isSameDay;
|
|
92
|
+
isSameWeek: typeof isSameWeek;
|
|
93
|
+
isSameMonth: typeof isSameMonth;
|
|
94
|
+
isSameYear: typeof isSameYear;
|
|
95
|
+
isToday: typeof isToday;
|
|
96
|
+
isTomorrow: typeof isTomorrow;
|
|
97
|
+
isYesterday: typeof isYesterday;
|
|
98
|
+
isWeekend: typeof isWeekend;
|
|
99
|
+
isPast: typeof isPast;
|
|
100
|
+
isFuture: typeof isFuture;
|
|
101
|
+
isThisWeek: typeof isThisWeek;
|
|
102
|
+
isThisMonth: typeof isThisMonth;
|
|
103
|
+
isThisYear: typeof isThisYear;
|
|
104
|
+
isValid: typeof isValid;
|
|
105
|
+
}
|
|
106
|
+
export declare function dt(): DateHelper;
|
|
107
|
+
export { type DateInput, toDate, toUnix, toMillis, fromUnix, fromTimestamp, now, today, tomorrow, yesterday, format as dateFormat, formatISO, formatRFC3339, formatRFC7231, fromNow, diffForHumans, toDateString, toTimeString, toDateTimeString, toIsoString, toRfc3339String, toRfc7231String, parse as dateParse, parseISO, addSecond, addSeconds, addMinute, addMinutes, addHour, addHours, addDay, addDays, addWeek, addWeeks, addMonth, addMonths, addYear, addYears, subSecond, subSeconds, subMinute, subMinutes, subHour, subHours, subDay, subDays, subWeek, subWeeks, subMonth, subMonths, subYear, subYears, startOfSecond, endOfSecond, startOfMinute, endOfMinute, startOfHour, endOfHour, startOfDay, endOfDay, startOfWeek, endOfWeek, startOfMonth, endOfMonth, startOfQuarter, endOfQuarter, startOfYear, endOfYear, diffInSeconds, diffInMinutes, diffInHours, diffInDays, diffInWeeks, diffInMonths, diffInYears, isBefore, isAfter, isEqual, isSameSecond, isSameMinute, isSameHour, isSameDay, isSameWeek, isSameMonth, isSameYear, isToday, isTomorrow, isYesterday, isWeekend, isPast, isFuture, isThisWeek, isThisMonth, isThisYear, isValid, };
|
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
import { fromTimestamp, fromUnix, toDate, toMillis, toUnix } from "./input.js";
|
|
2
|
+
import { now, today, tomorrow, yesterday } from "./now.js";
|
|
3
|
+
import {
|
|
4
|
+
diffForHumans,
|
|
5
|
+
format,
|
|
6
|
+
formatISO,
|
|
7
|
+
formatRFC3339,
|
|
8
|
+
formatRFC7231,
|
|
9
|
+
fromNow,
|
|
10
|
+
toDateString,
|
|
11
|
+
toDateTimeString,
|
|
12
|
+
toIsoString,
|
|
13
|
+
toRfc3339String,
|
|
14
|
+
toRfc7231String,
|
|
15
|
+
toTimeString
|
|
16
|
+
} from "./format.js";
|
|
17
|
+
import { parse, parseISO } from "./parse.js";
|
|
18
|
+
import {
|
|
19
|
+
addDay,
|
|
20
|
+
addDays,
|
|
21
|
+
addHour,
|
|
22
|
+
addHours,
|
|
23
|
+
addMinute,
|
|
24
|
+
addMinutes,
|
|
25
|
+
addMonth,
|
|
26
|
+
addMonths,
|
|
27
|
+
addSecond,
|
|
28
|
+
addSeconds,
|
|
29
|
+
addWeek,
|
|
30
|
+
addWeeks,
|
|
31
|
+
addYear,
|
|
32
|
+
addYears,
|
|
33
|
+
subDay,
|
|
34
|
+
subDays,
|
|
35
|
+
subHour,
|
|
36
|
+
subHours,
|
|
37
|
+
subMinute,
|
|
38
|
+
subMinutes,
|
|
39
|
+
subMonth,
|
|
40
|
+
subMonths,
|
|
41
|
+
subSecond,
|
|
42
|
+
subSeconds,
|
|
43
|
+
subWeek,
|
|
44
|
+
subWeeks,
|
|
45
|
+
subYear,
|
|
46
|
+
subYears
|
|
47
|
+
} from "./shift.js";
|
|
48
|
+
import {
|
|
49
|
+
endOfDay,
|
|
50
|
+
endOfHour,
|
|
51
|
+
endOfMinute,
|
|
52
|
+
endOfMonth,
|
|
53
|
+
endOfQuarter,
|
|
54
|
+
endOfSecond,
|
|
55
|
+
endOfWeek,
|
|
56
|
+
endOfYear,
|
|
57
|
+
startOfDay,
|
|
58
|
+
startOfHour,
|
|
59
|
+
startOfMinute,
|
|
60
|
+
startOfMonth,
|
|
61
|
+
startOfQuarter,
|
|
62
|
+
startOfSecond,
|
|
63
|
+
startOfWeek,
|
|
64
|
+
startOfYear
|
|
65
|
+
} from "./bounds.js";
|
|
66
|
+
import {
|
|
67
|
+
diffInDays,
|
|
68
|
+
diffInHours,
|
|
69
|
+
diffInMinutes,
|
|
70
|
+
diffInMonths,
|
|
71
|
+
diffInSeconds,
|
|
72
|
+
diffInWeeks,
|
|
73
|
+
diffInYears
|
|
74
|
+
} from "./diff.js";
|
|
75
|
+
import {
|
|
76
|
+
isAfter,
|
|
77
|
+
isBefore,
|
|
78
|
+
isEqual,
|
|
79
|
+
isFuture,
|
|
80
|
+
isPast,
|
|
81
|
+
isSameDay,
|
|
82
|
+
isSameHour,
|
|
83
|
+
isSameMinute,
|
|
84
|
+
isSameMonth,
|
|
85
|
+
isSameSecond,
|
|
86
|
+
isSameWeek,
|
|
87
|
+
isSameYear,
|
|
88
|
+
isThisMonth,
|
|
89
|
+
isThisWeek,
|
|
90
|
+
isThisYear,
|
|
91
|
+
isToday,
|
|
92
|
+
isTomorrow,
|
|
93
|
+
isValid,
|
|
94
|
+
isWeekend,
|
|
95
|
+
isYesterday
|
|
96
|
+
} from "./compare.js";
|
|
97
|
+
export function dt() {
|
|
98
|
+
return {
|
|
99
|
+
toDate,
|
|
100
|
+
toUnix,
|
|
101
|
+
toMillis,
|
|
102
|
+
fromUnix,
|
|
103
|
+
fromTimestamp,
|
|
104
|
+
now,
|
|
105
|
+
today,
|
|
106
|
+
tomorrow,
|
|
107
|
+
yesterday,
|
|
108
|
+
format,
|
|
109
|
+
formatISO,
|
|
110
|
+
formatRFC3339,
|
|
111
|
+
formatRFC7231,
|
|
112
|
+
fromNow,
|
|
113
|
+
diffForHumans,
|
|
114
|
+
toDateString,
|
|
115
|
+
toTimeString,
|
|
116
|
+
toDateTimeString,
|
|
117
|
+
toIsoString,
|
|
118
|
+
toRfc3339String,
|
|
119
|
+
toRfc7231String,
|
|
120
|
+
parse,
|
|
121
|
+
parseISO,
|
|
122
|
+
addSecond,
|
|
123
|
+
addSeconds,
|
|
124
|
+
addMinute,
|
|
125
|
+
addMinutes,
|
|
126
|
+
addHour,
|
|
127
|
+
addHours,
|
|
128
|
+
addDay,
|
|
129
|
+
addDays,
|
|
130
|
+
addWeek,
|
|
131
|
+
addWeeks,
|
|
132
|
+
addMonth,
|
|
133
|
+
addMonths,
|
|
134
|
+
addYear,
|
|
135
|
+
addYears,
|
|
136
|
+
subSecond,
|
|
137
|
+
subSeconds,
|
|
138
|
+
subMinute,
|
|
139
|
+
subMinutes,
|
|
140
|
+
subHour,
|
|
141
|
+
subHours,
|
|
142
|
+
subDay,
|
|
143
|
+
subDays,
|
|
144
|
+
subWeek,
|
|
145
|
+
subWeeks,
|
|
146
|
+
subMonth,
|
|
147
|
+
subMonths,
|
|
148
|
+
subYear,
|
|
149
|
+
subYears,
|
|
150
|
+
startOfSecond,
|
|
151
|
+
endOfSecond,
|
|
152
|
+
startOfMinute,
|
|
153
|
+
endOfMinute,
|
|
154
|
+
startOfHour,
|
|
155
|
+
endOfHour,
|
|
156
|
+
startOfDay,
|
|
157
|
+
endOfDay,
|
|
158
|
+
startOfWeek,
|
|
159
|
+
endOfWeek,
|
|
160
|
+
startOfMonth,
|
|
161
|
+
endOfMonth,
|
|
162
|
+
startOfQuarter,
|
|
163
|
+
endOfQuarter,
|
|
164
|
+
startOfYear,
|
|
165
|
+
endOfYear,
|
|
166
|
+
diffInSeconds,
|
|
167
|
+
diffInMinutes,
|
|
168
|
+
diffInHours,
|
|
169
|
+
diffInDays,
|
|
170
|
+
diffInWeeks,
|
|
171
|
+
diffInMonths,
|
|
172
|
+
diffInYears,
|
|
173
|
+
isBefore,
|
|
174
|
+
isAfter,
|
|
175
|
+
isEqual,
|
|
176
|
+
isSameSecond,
|
|
177
|
+
isSameMinute,
|
|
178
|
+
isSameHour,
|
|
179
|
+
isSameDay,
|
|
180
|
+
isSameWeek,
|
|
181
|
+
isSameMonth,
|
|
182
|
+
isSameYear,
|
|
183
|
+
isToday,
|
|
184
|
+
isTomorrow,
|
|
185
|
+
isYesterday,
|
|
186
|
+
isWeekend,
|
|
187
|
+
isPast,
|
|
188
|
+
isFuture,
|
|
189
|
+
isThisWeek,
|
|
190
|
+
isThisMonth,
|
|
191
|
+
isThisYear,
|
|
192
|
+
isValid
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
export {
|
|
196
|
+
toDate,
|
|
197
|
+
toUnix,
|
|
198
|
+
toMillis,
|
|
199
|
+
fromUnix,
|
|
200
|
+
fromTimestamp,
|
|
201
|
+
now,
|
|
202
|
+
today,
|
|
203
|
+
tomorrow,
|
|
204
|
+
yesterday,
|
|
205
|
+
format as dateFormat,
|
|
206
|
+
formatISO,
|
|
207
|
+
formatRFC3339,
|
|
208
|
+
formatRFC7231,
|
|
209
|
+
fromNow,
|
|
210
|
+
diffForHumans,
|
|
211
|
+
toDateString,
|
|
212
|
+
toTimeString,
|
|
213
|
+
toDateTimeString,
|
|
214
|
+
toIsoString,
|
|
215
|
+
toRfc3339String,
|
|
216
|
+
toRfc7231String,
|
|
217
|
+
parse as dateParse,
|
|
218
|
+
parseISO,
|
|
219
|
+
addSecond,
|
|
220
|
+
addSeconds,
|
|
221
|
+
addMinute,
|
|
222
|
+
addMinutes,
|
|
223
|
+
addHour,
|
|
224
|
+
addHours,
|
|
225
|
+
addDay,
|
|
226
|
+
addDays,
|
|
227
|
+
addWeek,
|
|
228
|
+
addWeeks,
|
|
229
|
+
addMonth,
|
|
230
|
+
addMonths,
|
|
231
|
+
addYear,
|
|
232
|
+
addYears,
|
|
233
|
+
subSecond,
|
|
234
|
+
subSeconds,
|
|
235
|
+
subMinute,
|
|
236
|
+
subMinutes,
|
|
237
|
+
subHour,
|
|
238
|
+
subHours,
|
|
239
|
+
subDay,
|
|
240
|
+
subDays,
|
|
241
|
+
subWeek,
|
|
242
|
+
subWeeks,
|
|
243
|
+
subMonth,
|
|
244
|
+
subMonths,
|
|
245
|
+
subYear,
|
|
246
|
+
subYears,
|
|
247
|
+
startOfSecond,
|
|
248
|
+
endOfSecond,
|
|
249
|
+
startOfMinute,
|
|
250
|
+
endOfMinute,
|
|
251
|
+
startOfHour,
|
|
252
|
+
endOfHour,
|
|
253
|
+
startOfDay,
|
|
254
|
+
endOfDay,
|
|
255
|
+
startOfWeek,
|
|
256
|
+
endOfWeek,
|
|
257
|
+
startOfMonth,
|
|
258
|
+
endOfMonth,
|
|
259
|
+
startOfQuarter,
|
|
260
|
+
endOfQuarter,
|
|
261
|
+
startOfYear,
|
|
262
|
+
endOfYear,
|
|
263
|
+
diffInSeconds,
|
|
264
|
+
diffInMinutes,
|
|
265
|
+
diffInHours,
|
|
266
|
+
diffInDays,
|
|
267
|
+
diffInWeeks,
|
|
268
|
+
diffInMonths,
|
|
269
|
+
diffInYears,
|
|
270
|
+
isBefore,
|
|
271
|
+
isAfter,
|
|
272
|
+
isEqual,
|
|
273
|
+
isSameSecond,
|
|
274
|
+
isSameMinute,
|
|
275
|
+
isSameHour,
|
|
276
|
+
isSameDay,
|
|
277
|
+
isSameWeek,
|
|
278
|
+
isSameMonth,
|
|
279
|
+
isSameYear,
|
|
280
|
+
isToday,
|
|
281
|
+
isTomorrow,
|
|
282
|
+
isYesterday,
|
|
283
|
+
isWeekend,
|
|
284
|
+
isPast,
|
|
285
|
+
isFuture,
|
|
286
|
+
isThisWeek,
|
|
287
|
+
isThisMonth,
|
|
288
|
+
isThisYear,
|
|
289
|
+
isValid
|
|
290
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export type DateInput = Date | string | number;
|
|
2
|
+
export declare function toDate(value: DateInput): Date;
|
|
3
|
+
export declare function toUnix(value: DateInput): number;
|
|
4
|
+
export declare function toMillis(value: DateInput): number;
|
|
5
|
+
export declare function fromUnix(value: number | string): Date;
|
|
6
|
+
export declare const fromTimestamp: typeof fromUnix;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { parseISO } from "date-fns";
|
|
2
|
+
const numericPattern = /^-?\d+$/;
|
|
3
|
+
export function toDate(value) {
|
|
4
|
+
if (value instanceof Date) {
|
|
5
|
+
return new Date(value.getTime());
|
|
6
|
+
}
|
|
7
|
+
if (typeof value === "number") {
|
|
8
|
+
return new Date(value * 1e3);
|
|
9
|
+
}
|
|
10
|
+
const trimmed = value.trim();
|
|
11
|
+
if (trimmed === "") {
|
|
12
|
+
return new Date(Number.NaN);
|
|
13
|
+
}
|
|
14
|
+
if (numericPattern.test(trimmed)) {
|
|
15
|
+
const numeric = Number(trimmed);
|
|
16
|
+
if (!Number.isFinite(numeric)) {
|
|
17
|
+
return new Date(Number.NaN);
|
|
18
|
+
}
|
|
19
|
+
const isMilliseconds = trimmed.length >= 13;
|
|
20
|
+
return new Date(isMilliseconds ? numeric : numeric * 1e3);
|
|
21
|
+
}
|
|
22
|
+
const isoDate = parseISO(trimmed);
|
|
23
|
+
if (!Number.isNaN(isoDate.getTime())) {
|
|
24
|
+
return isoDate;
|
|
25
|
+
}
|
|
26
|
+
return new Date(trimmed);
|
|
27
|
+
}
|
|
28
|
+
export function toUnix(value) {
|
|
29
|
+
return Math.floor(toDate(value).getTime() / 1e3);
|
|
30
|
+
}
|
|
31
|
+
export function toMillis(value) {
|
|
32
|
+
return toDate(value).getTime();
|
|
33
|
+
}
|
|
34
|
+
export function fromUnix(value) {
|
|
35
|
+
const numeric = typeof value === "string" ? Number(value) : value;
|
|
36
|
+
if (!Number.isFinite(numeric)) {
|
|
37
|
+
return new Date(Number.NaN);
|
|
38
|
+
}
|
|
39
|
+
return new Date(numeric * 1e3);
|
|
40
|
+
}
|
|
41
|
+
export const fromTimestamp = fromUnix;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { startOfToday, startOfTomorrow, startOfYesterday } from "date-fns";
|
|
2
|
+
export function now() {
|
|
3
|
+
return /* @__PURE__ */ new Date();
|
|
4
|
+
}
|
|
5
|
+
export function today() {
|
|
6
|
+
return startOfToday();
|
|
7
|
+
}
|
|
8
|
+
export function tomorrow() {
|
|
9
|
+
return startOfTomorrow();
|
|
10
|
+
}
|
|
11
|
+
export function yesterday() {
|
|
12
|
+
return startOfYesterday();
|
|
13
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { ParseOptions } from 'date-fns';
|
|
2
|
+
import type { DateFormatInput } from './format.js';
|
|
3
|
+
import type { DateInput } from './input.js';
|
|
4
|
+
export declare function parse(value: string, formatString: DateFormatInput, baseDate?: DateInput, options?: ParseOptions): Date;
|
|
5
|
+
export declare function parseISO(value: string): Date;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { parse as parseDate, parseISO as parseISODate } from "date-fns";
|
|
2
|
+
import { resolveFormatString } from "./format.js";
|
|
3
|
+
import { toDate } from "./input.js";
|
|
4
|
+
export function parse(value, formatString, baseDate = /* @__PURE__ */ new Date(), options) {
|
|
5
|
+
return parseDate(value, resolveFormatString(formatString), toDate(baseDate), options);
|
|
6
|
+
}
|
|
7
|
+
export function parseISO(value) {
|
|
8
|
+
return parseISODate(value);
|
|
9
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { DateInput } from './input.js';
|
|
2
|
+
export declare function addSeconds(date: DateInput, amount: number): Date;
|
|
3
|
+
export declare function addSecond(date: DateInput): Date;
|
|
4
|
+
export declare function addMinutes(date: DateInput, amount: number): Date;
|
|
5
|
+
export declare function addMinute(date: DateInput): Date;
|
|
6
|
+
export declare function addHours(date: DateInput, amount: number): Date;
|
|
7
|
+
export declare function addHour(date: DateInput): Date;
|
|
8
|
+
export declare function addDays(date: DateInput, amount: number): Date;
|
|
9
|
+
export declare function addDay(date: DateInput): Date;
|
|
10
|
+
export declare function addWeeks(date: DateInput, amount: number): Date;
|
|
11
|
+
export declare function addWeek(date: DateInput): Date;
|
|
12
|
+
export declare function addMonths(date: DateInput, amount: number): Date;
|
|
13
|
+
export declare function addMonth(date: DateInput): Date;
|
|
14
|
+
export declare function addYears(date: DateInput, amount: number): Date;
|
|
15
|
+
export declare function addYear(date: DateInput): Date;
|
|
16
|
+
export declare function subSeconds(date: DateInput, amount: number): Date;
|
|
17
|
+
export declare function subSecond(date: DateInput): Date;
|
|
18
|
+
export declare function subMinutes(date: DateInput, amount: number): Date;
|
|
19
|
+
export declare function subMinute(date: DateInput): Date;
|
|
20
|
+
export declare function subHours(date: DateInput, amount: number): Date;
|
|
21
|
+
export declare function subHour(date: DateInput): Date;
|
|
22
|
+
export declare function subDays(date: DateInput, amount: number): Date;
|
|
23
|
+
export declare function subDay(date: DateInput): Date;
|
|
24
|
+
export declare function subWeeks(date: DateInput, amount: number): Date;
|
|
25
|
+
export declare function subWeek(date: DateInput): Date;
|
|
26
|
+
export declare function subMonths(date: DateInput, amount: number): Date;
|
|
27
|
+
export declare function subMonth(date: DateInput): Date;
|
|
28
|
+
export declare function subYears(date: DateInput, amount: number): Date;
|
|
29
|
+
export declare function subYear(date: DateInput): Date;
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import {
|
|
2
|
+
addDays as addDaysBase,
|
|
3
|
+
addHours as addHoursBase,
|
|
4
|
+
addMinutes as addMinutesBase,
|
|
5
|
+
addMonths as addMonthsBase,
|
|
6
|
+
addSeconds as addSecondsBase,
|
|
7
|
+
addWeeks as addWeeksBase,
|
|
8
|
+
addYears as addYearsBase,
|
|
9
|
+
subDays as subDaysBase,
|
|
10
|
+
subHours as subHoursBase,
|
|
11
|
+
subMinutes as subMinutesBase,
|
|
12
|
+
subMonths as subMonthsBase,
|
|
13
|
+
subSeconds as subSecondsBase,
|
|
14
|
+
subWeeks as subWeeksBase,
|
|
15
|
+
subYears as subYearsBase
|
|
16
|
+
} from "date-fns";
|
|
17
|
+
import { toDate } from "./input.js";
|
|
18
|
+
export function addSeconds(date, amount) {
|
|
19
|
+
return addSecondsBase(toDate(date), amount);
|
|
20
|
+
}
|
|
21
|
+
export function addSecond(date) {
|
|
22
|
+
return addSeconds(date, 1);
|
|
23
|
+
}
|
|
24
|
+
export function addMinutes(date, amount) {
|
|
25
|
+
return addMinutesBase(toDate(date), amount);
|
|
26
|
+
}
|
|
27
|
+
export function addMinute(date) {
|
|
28
|
+
return addMinutes(date, 1);
|
|
29
|
+
}
|
|
30
|
+
export function addHours(date, amount) {
|
|
31
|
+
return addHoursBase(toDate(date), amount);
|
|
32
|
+
}
|
|
33
|
+
export function addHour(date) {
|
|
34
|
+
return addHours(date, 1);
|
|
35
|
+
}
|
|
36
|
+
export function addDays(date, amount) {
|
|
37
|
+
return addDaysBase(toDate(date), amount);
|
|
38
|
+
}
|
|
39
|
+
export function addDay(date) {
|
|
40
|
+
return addDays(date, 1);
|
|
41
|
+
}
|
|
42
|
+
export function addWeeks(date, amount) {
|
|
43
|
+
return addWeeksBase(toDate(date), amount);
|
|
44
|
+
}
|
|
45
|
+
export function addWeek(date) {
|
|
46
|
+
return addWeeks(date, 1);
|
|
47
|
+
}
|
|
48
|
+
export function addMonths(date, amount) {
|
|
49
|
+
return addMonthsBase(toDate(date), amount);
|
|
50
|
+
}
|
|
51
|
+
export function addMonth(date) {
|
|
52
|
+
return addMonths(date, 1);
|
|
53
|
+
}
|
|
54
|
+
export function addYears(date, amount) {
|
|
55
|
+
return addYearsBase(toDate(date), amount);
|
|
56
|
+
}
|
|
57
|
+
export function addYear(date) {
|
|
58
|
+
return addYears(date, 1);
|
|
59
|
+
}
|
|
60
|
+
export function subSeconds(date, amount) {
|
|
61
|
+
return subSecondsBase(toDate(date), amount);
|
|
62
|
+
}
|
|
63
|
+
export function subSecond(date) {
|
|
64
|
+
return subSeconds(date, 1);
|
|
65
|
+
}
|
|
66
|
+
export function subMinutes(date, amount) {
|
|
67
|
+
return subMinutesBase(toDate(date), amount);
|
|
68
|
+
}
|
|
69
|
+
export function subMinute(date) {
|
|
70
|
+
return subMinutes(date, 1);
|
|
71
|
+
}
|
|
72
|
+
export function subHours(date, amount) {
|
|
73
|
+
return subHoursBase(toDate(date), amount);
|
|
74
|
+
}
|
|
75
|
+
export function subHour(date) {
|
|
76
|
+
return subHours(date, 1);
|
|
77
|
+
}
|
|
78
|
+
export function subDays(date, amount) {
|
|
79
|
+
return subDaysBase(toDate(date), amount);
|
|
80
|
+
}
|
|
81
|
+
export function subDay(date) {
|
|
82
|
+
return subDays(date, 1);
|
|
83
|
+
}
|
|
84
|
+
export function subWeeks(date, amount) {
|
|
85
|
+
return subWeeksBase(toDate(date), amount);
|
|
86
|
+
}
|
|
87
|
+
export function subWeek(date) {
|
|
88
|
+
return subWeeks(date, 1);
|
|
89
|
+
}
|
|
90
|
+
export function subMonths(date, amount) {
|
|
91
|
+
return subMonthsBase(toDate(date), amount);
|
|
92
|
+
}
|
|
93
|
+
export function subMonth(date) {
|
|
94
|
+
return subMonths(date, 1);
|
|
95
|
+
}
|
|
96
|
+
export function subYears(date, amount) {
|
|
97
|
+
return subYearsBase(toDate(date), amount);
|
|
98
|
+
}
|
|
99
|
+
export function subYear(date) {
|
|
100
|
+
return subYears(date, 1);
|
|
101
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ciwergrp/nuxid",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.2",
|
|
4
4
|
"description": "All-in-one essential modules for Nuxt",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -46,37 +46,35 @@
|
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
48
|
"@element-plus/nuxt": "1.1.4",
|
|
49
|
-
"@formatjs/intl": "4.0.
|
|
50
|
-
"@inquirer/prompts": "8.
|
|
51
|
-
"@nuxt/icon": "2.
|
|
49
|
+
"@formatjs/intl": "4.0.9",
|
|
50
|
+
"@inquirer/prompts": "8.2.0",
|
|
51
|
+
"@nuxt/icon": "2.2.0",
|
|
52
52
|
"@nuxt/kit": "4.2.2",
|
|
53
|
-
"@sentry/nuxt": "10.
|
|
53
|
+
"@sentry/nuxt": "10.33.0",
|
|
54
54
|
"@sindresorhus/slugify": "3.0.0",
|
|
55
|
-
"@sindresorhus/transliterate": "2.3.
|
|
55
|
+
"@sindresorhus/transliterate": "2.3.1",
|
|
56
56
|
"@vueuse/nuxt": "14.1.0",
|
|
57
|
-
"
|
|
57
|
+
"date-fns": "^4.1.0",
|
|
58
|
+
"element-plus": "2.13.1",
|
|
58
59
|
"hls.js": "1.6.15",
|
|
59
60
|
"lodash-es": "4.17.22",
|
|
60
|
-
"moment": "2.30.1",
|
|
61
61
|
"pinia": "3.0.4",
|
|
62
62
|
"pluralize": "8.0.0",
|
|
63
63
|
"socket.io-client": "4.8.3"
|
|
64
64
|
},
|
|
65
65
|
"devDependencies": {
|
|
66
|
-
"@nuxt/devtools": "^3.1.
|
|
67
|
-
"@nuxt/eslint-config": "^1.
|
|
66
|
+
"@nuxt/devtools": "^3.1.1",
|
|
67
|
+
"@nuxt/eslint-config": "^1.12.1",
|
|
68
68
|
"@nuxt/module-builder": "^1.0.2",
|
|
69
69
|
"@nuxt/schema": "^4.2.1",
|
|
70
|
-
"@nuxt/test-utils": "^3.
|
|
70
|
+
"@nuxt/test-utils": "^3.23.0",
|
|
71
71
|
"@types/lodash-es": "^4.17.12",
|
|
72
|
-
"@types/node": "
|
|
73
|
-
"
|
|
74
|
-
"eslint": "^9.39.1",
|
|
72
|
+
"@types/node": "^22",
|
|
73
|
+
"eslint": "^9.39.2",
|
|
75
74
|
"nuxt": "^4.2.1",
|
|
76
|
-
"typescript": "
|
|
77
|
-
"vitest": "^4.0.
|
|
78
|
-
"vue-tsc": "^3.
|
|
79
|
-
"@vueuse/nuxt": "14.1.0"
|
|
75
|
+
"typescript": "^5.9.3",
|
|
76
|
+
"vitest": "^4.0.17",
|
|
77
|
+
"vue-tsc": "^3.2.2"
|
|
80
78
|
},
|
|
81
79
|
"scripts": {
|
|
82
80
|
"dev": "npm run dev:prepare && nuxi dev playground",
|