@gobrand/tiempo 2.2.1 → 2.2.3
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/README.md +234 -10
- package/dist/chunk-2H4KLXGL.js +16 -0
- package/dist/chunk-2H4KLXGL.js.map +1 -0
- package/dist/chunk-6IP245MS.js +17 -0
- package/dist/chunk-6IP245MS.js.map +1 -0
- package/dist/chunk-BIAPE4MR.js +17 -0
- package/dist/chunk-BIAPE4MR.js.map +1 -0
- package/dist/chunk-CHW2EN2O.js +17 -0
- package/dist/chunk-CHW2EN2O.js.map +1 -0
- package/dist/chunk-D7DPB2JR.js +16 -0
- package/dist/chunk-D7DPB2JR.js.map +1 -0
- package/dist/chunk-NL5LWPJI.js +94 -0
- package/dist/chunk-NL5LWPJI.js.map +1 -0
- package/dist/chunk-OABS374T.js +16 -0
- package/dist/chunk-OABS374T.js.map +1 -0
- package/dist/chunk-PIDXROVB.js +16 -0
- package/dist/chunk-PIDXROVB.js.map +1 -0
- package/dist/chunk-PVAOUYXF.js +17 -0
- package/dist/chunk-PVAOUYXF.js.map +1 -0
- package/dist/chunk-R5XN76EV.js +16 -0
- package/dist/chunk-R5XN76EV.js.map +1 -0
- package/dist/chunk-RJY62CDU.js +16 -0
- package/dist/chunk-RJY62CDU.js.map +1 -0
- package/dist/chunk-ZGR4NZTS.js +17 -0
- package/dist/chunk-ZGR4NZTS.js.map +1 -0
- package/dist/chunk-ZHRMURYP.js +16 -0
- package/dist/chunk-ZHRMURYP.js.map +1 -0
- package/dist/differenceInDays.d.ts +43 -0
- package/dist/differenceInDays.d.ts.map +1 -0
- package/dist/differenceInDays.js +8 -0
- package/dist/differenceInDays.js.map +1 -0
- package/dist/differenceInDays.test.d.ts +2 -0
- package/dist/differenceInDays.test.d.ts.map +1 -0
- package/dist/differenceInHours.d.ts +37 -0
- package/dist/differenceInHours.d.ts.map +1 -0
- package/dist/differenceInHours.js +8 -0
- package/dist/differenceInHours.js.map +1 -0
- package/dist/differenceInHours.test.d.ts +2 -0
- package/dist/differenceInHours.test.d.ts.map +1 -0
- package/dist/differenceInMicroseconds.d.ts +37 -0
- package/dist/differenceInMicroseconds.d.ts.map +1 -0
- package/dist/differenceInMicroseconds.js +8 -0
- package/dist/differenceInMicroseconds.js.map +1 -0
- package/dist/differenceInMicroseconds.test.d.ts +2 -0
- package/dist/differenceInMicroseconds.test.d.ts.map +1 -0
- package/dist/differenceInMilliseconds.d.ts +37 -0
- package/dist/differenceInMilliseconds.d.ts.map +1 -0
- package/dist/differenceInMilliseconds.js +8 -0
- package/dist/differenceInMilliseconds.js.map +1 -0
- package/dist/differenceInMilliseconds.test.d.ts +2 -0
- package/dist/differenceInMilliseconds.test.d.ts.map +1 -0
- package/dist/differenceInMinutes.d.ts +37 -0
- package/dist/differenceInMinutes.d.ts.map +1 -0
- package/dist/differenceInMinutes.js +8 -0
- package/dist/differenceInMinutes.js.map +1 -0
- package/dist/differenceInMinutes.test.d.ts +2 -0
- package/dist/differenceInMinutes.test.d.ts.map +1 -0
- package/dist/differenceInMonths.d.ts +43 -0
- package/dist/differenceInMonths.d.ts.map +1 -0
- package/dist/differenceInMonths.js +8 -0
- package/dist/differenceInMonths.js.map +1 -0
- package/dist/differenceInMonths.test.d.ts +2 -0
- package/dist/differenceInMonths.test.d.ts.map +1 -0
- package/dist/differenceInNanoseconds.d.ts +37 -0
- package/dist/differenceInNanoseconds.d.ts.map +1 -0
- package/dist/differenceInNanoseconds.js +8 -0
- package/dist/differenceInNanoseconds.js.map +1 -0
- package/dist/differenceInNanoseconds.test.d.ts +2 -0
- package/dist/differenceInNanoseconds.test.d.ts.map +1 -0
- package/dist/differenceInSeconds.d.ts +37 -0
- package/dist/differenceInSeconds.d.ts.map +1 -0
- package/dist/differenceInSeconds.js +8 -0
- package/dist/differenceInSeconds.js.map +1 -0
- package/dist/differenceInSeconds.test.d.ts +2 -0
- package/dist/differenceInSeconds.test.d.ts.map +1 -0
- package/dist/differenceInWeeks.d.ts +43 -0
- package/dist/differenceInWeeks.d.ts.map +1 -0
- package/dist/differenceInWeeks.js +8 -0
- package/dist/differenceInWeeks.js.map +1 -0
- package/dist/differenceInWeeks.test.d.ts +2 -0
- package/dist/differenceInWeeks.test.d.ts.map +1 -0
- package/dist/differenceInYears.d.ts +43 -0
- package/dist/differenceInYears.d.ts.map +1 -0
- package/dist/differenceInYears.js +8 -0
- package/dist/differenceInYears.js.map +1 -0
- package/dist/differenceInYears.test.d.ts +2 -0
- package/dist/differenceInYears.test.d.ts.map +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +66 -14
- package/dist/intlFormatDistance.d.ts +85 -0
- package/dist/intlFormatDistance.d.ts.map +1 -0
- package/dist/intlFormatDistance.js +15 -0
- package/dist/intlFormatDistance.js.map +1 -0
- package/dist/intlFormatDistance.test.d.ts +2 -0
- package/dist/intlFormatDistance.test.d.ts.map +1 -0
- package/dist/isFuture.d.ts +35 -0
- package/dist/isFuture.d.ts.map +1 -0
- package/dist/isFuture.js +8 -0
- package/dist/isFuture.js.map +1 -0
- package/dist/isFuture.test.d.ts +2 -0
- package/dist/isFuture.test.d.ts.map +1 -0
- package/dist/isPast.d.ts +35 -0
- package/dist/isPast.d.ts.map +1 -0
- package/dist/isPast.js +8 -0
- package/dist/isPast.js.map +1 -0
- package/dist/isPast.test.d.ts +2 -0
- package/dist/isPast.test.d.ts.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { Temporal } from '@js-temporal/polyfill';
|
|
2
|
+
/**
|
|
3
|
+
* Returns the number of years between two datetimes.
|
|
4
|
+
* The result is positive if laterDate is after earlierDate, negative if before.
|
|
5
|
+
*
|
|
6
|
+
* This function uses calendar-aware calculation, which means it properly handles
|
|
7
|
+
* leap years (366 days) and regular years (365 days).
|
|
8
|
+
*
|
|
9
|
+
* Instant inputs are converted to UTC for calendar calculations.
|
|
10
|
+
* For ZonedDateTime inputs, their timezone is preserved.
|
|
11
|
+
*
|
|
12
|
+
* @param laterDate - The later datetime (Instant or ZonedDateTime)
|
|
13
|
+
* @param earlierDate - The earlier datetime (Instant or ZonedDateTime)
|
|
14
|
+
* @returns The number of years between the dates
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```ts
|
|
18
|
+
* const later = Temporal.Instant.from('2028-01-20T12:00:00Z');
|
|
19
|
+
* const earlier = Temporal.Instant.from('2025-01-20T12:00:00Z');
|
|
20
|
+
*
|
|
21
|
+
* differenceInYears(later, earlier); // 3
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```ts
|
|
26
|
+
* // Works with ZonedDateTime
|
|
27
|
+
* const later = Temporal.ZonedDateTime.from('2030-06-15T15:00:00-05:00[America/New_York]');
|
|
28
|
+
* const earlier = Temporal.ZonedDateTime.from('2025-06-15T15:00:00-05:00[America/New_York]');
|
|
29
|
+
*
|
|
30
|
+
* differenceInYears(later, earlier); // 5
|
|
31
|
+
* ```
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```ts
|
|
35
|
+
* // Returns fractional years for partial year differences
|
|
36
|
+
* const later = Temporal.Instant.from('2025-07-20T12:00:00Z');
|
|
37
|
+
* const earlier = Temporal.Instant.from('2025-01-20T12:00:00Z');
|
|
38
|
+
*
|
|
39
|
+
* differenceInYears(later, earlier); // ~0.5 (approximately half a year)
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
export declare function differenceInYears(laterDate: Temporal.Instant | Temporal.ZonedDateTime, earlierDate: Temporal.Instant | Temporal.ZonedDateTime): number;
|
|
43
|
+
//# sourceMappingURL=differenceInYears.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"differenceInYears.d.ts","sourceRoot":"","sources":["../src/differenceInYears.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAGjD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,wBAAgB,iBAAiB,CAC/B,SAAS,EAAE,QAAQ,CAAC,OAAO,GAAG,QAAQ,CAAC,aAAa,EACpD,WAAW,EAAE,QAAQ,CAAC,OAAO,GAAG,QAAQ,CAAC,aAAa,GACrD,MAAM,CAMR"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"differenceInYears.test.d.ts","sourceRoot":"","sources":["../src/differenceInYears.test.ts"],"names":[],"mappings":""}
|
package/dist/index.d.ts
CHANGED
|
@@ -14,5 +14,18 @@ export { startOfYear } from './startOfYear';
|
|
|
14
14
|
export { endOfYear } from './endOfYear';
|
|
15
15
|
export { isBefore } from './isBefore';
|
|
16
16
|
export { isAfter } from './isAfter';
|
|
17
|
+
export { isFuture } from './isFuture';
|
|
18
|
+
export { isPast } from './isPast';
|
|
17
19
|
export { isSameDay } from './isSameDay';
|
|
20
|
+
export { differenceInNanoseconds } from './differenceInNanoseconds';
|
|
21
|
+
export { differenceInMicroseconds } from './differenceInMicroseconds';
|
|
22
|
+
export { differenceInMilliseconds } from './differenceInMilliseconds';
|
|
23
|
+
export { differenceInSeconds } from './differenceInSeconds';
|
|
24
|
+
export { differenceInMinutes } from './differenceInMinutes';
|
|
25
|
+
export { differenceInHours } from './differenceInHours';
|
|
26
|
+
export { differenceInDays } from './differenceInDays';
|
|
27
|
+
export { differenceInWeeks } from './differenceInWeeks';
|
|
28
|
+
export { differenceInMonths } from './differenceInMonths';
|
|
29
|
+
export { differenceInYears } from './differenceInYears';
|
|
30
|
+
export { intlFormatDistance, type IntlFormatDistanceOptions, } from './intlFormatDistance';
|
|
18
31
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sour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AkB,EAClB,KAAK,yBAAyB,GAC/B,MAAM,sBAAsB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
import {
|
|
2
|
+
startOfMonth
|
|
3
|
+
} from "./chunk-TU2UNOOW.js";
|
|
4
|
+
import {
|
|
5
|
+
startOfWeek
|
|
6
|
+
} from "./chunk-2WMXB7QL.js";
|
|
7
|
+
import {
|
|
8
|
+
startOfYear
|
|
9
|
+
} from "./chunk-YR2UCUIT.js";
|
|
10
|
+
import {
|
|
11
|
+
toUtc
|
|
12
|
+
} from "./chunk-GPAFAHKJ.js";
|
|
1
13
|
import {
|
|
2
14
|
toUtcString
|
|
3
15
|
} from "./chunk-DMKGJY4N.js";
|
|
@@ -7,6 +19,21 @@ import {
|
|
|
7
19
|
import {
|
|
8
20
|
today
|
|
9
21
|
} from "./chunk-67QHALIG.js";
|
|
22
|
+
import {
|
|
23
|
+
intlFormatDistance
|
|
24
|
+
} from "./chunk-NL5LWPJI.js";
|
|
25
|
+
import {
|
|
26
|
+
isAfter
|
|
27
|
+
} from "./chunk-BBNNR2QH.js";
|
|
28
|
+
import {
|
|
29
|
+
isBefore
|
|
30
|
+
} from "./chunk-IPJUERCK.js";
|
|
31
|
+
import {
|
|
32
|
+
isFuture
|
|
33
|
+
} from "./chunk-R5XN76EV.js";
|
|
34
|
+
import {
|
|
35
|
+
isPast
|
|
36
|
+
} from "./chunk-2H4KLXGL.js";
|
|
10
37
|
import {
|
|
11
38
|
isSameDay
|
|
12
39
|
} from "./chunk-RW3C2677.js";
|
|
@@ -17,17 +44,11 @@ import {
|
|
|
17
44
|
startOfDay
|
|
18
45
|
} from "./chunk-TW5EV3DH.js";
|
|
19
46
|
import {
|
|
20
|
-
|
|
21
|
-
} from "./chunk-
|
|
22
|
-
import {
|
|
23
|
-
startOfWeek
|
|
24
|
-
} from "./chunk-2WMXB7QL.js";
|
|
47
|
+
differenceInWeeks
|
|
48
|
+
} from "./chunk-PVAOUYXF.js";
|
|
25
49
|
import {
|
|
26
|
-
|
|
27
|
-
} from "./chunk-
|
|
28
|
-
import {
|
|
29
|
-
toUtc
|
|
30
|
-
} from "./chunk-GPAFAHKJ.js";
|
|
50
|
+
differenceInYears
|
|
51
|
+
} from "./chunk-CHW2EN2O.js";
|
|
31
52
|
import {
|
|
32
53
|
endOfDay
|
|
33
54
|
} from "./chunk-CUMB4776.js";
|
|
@@ -45,20 +66,51 @@ import {
|
|
|
45
66
|
format
|
|
46
67
|
} from "./chunk-2G5RJGPR.js";
|
|
47
68
|
import {
|
|
48
|
-
|
|
49
|
-
} from "./chunk-
|
|
69
|
+
differenceInDays
|
|
70
|
+
} from "./chunk-6IP245MS.js";
|
|
50
71
|
import {
|
|
51
|
-
|
|
52
|
-
} from "./chunk-
|
|
72
|
+
differenceInHours
|
|
73
|
+
} from "./chunk-PIDXROVB.js";
|
|
74
|
+
import {
|
|
75
|
+
differenceInMicroseconds
|
|
76
|
+
} from "./chunk-ZGR4NZTS.js";
|
|
77
|
+
import {
|
|
78
|
+
differenceInMilliseconds
|
|
79
|
+
} from "./chunk-D7DPB2JR.js";
|
|
80
|
+
import {
|
|
81
|
+
differenceInMinutes
|
|
82
|
+
} from "./chunk-RJY62CDU.js";
|
|
83
|
+
import {
|
|
84
|
+
differenceInMonths
|
|
85
|
+
} from "./chunk-BIAPE4MR.js";
|
|
86
|
+
import {
|
|
87
|
+
differenceInNanoseconds
|
|
88
|
+
} from "./chunk-OABS374T.js";
|
|
89
|
+
import {
|
|
90
|
+
differenceInSeconds
|
|
91
|
+
} from "./chunk-ZHRMURYP.js";
|
|
53
92
|
import "./chunk-MJSZNWCV.js";
|
|
54
93
|
export {
|
|
94
|
+
differenceInDays,
|
|
95
|
+
differenceInHours,
|
|
96
|
+
differenceInMicroseconds,
|
|
97
|
+
differenceInMilliseconds,
|
|
98
|
+
differenceInMinutes,
|
|
99
|
+
differenceInMonths,
|
|
100
|
+
differenceInNanoseconds,
|
|
101
|
+
differenceInSeconds,
|
|
102
|
+
differenceInWeeks,
|
|
103
|
+
differenceInYears,
|
|
55
104
|
endOfDay,
|
|
56
105
|
endOfMonth,
|
|
57
106
|
endOfWeek,
|
|
58
107
|
endOfYear,
|
|
59
108
|
format,
|
|
109
|
+
intlFormatDistance,
|
|
60
110
|
isAfter,
|
|
61
111
|
isBefore,
|
|
112
|
+
isFuture,
|
|
113
|
+
isPast,
|
|
62
114
|
isSameDay,
|
|
63
115
|
now,
|
|
64
116
|
startOfDay,
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import type { Temporal } from '@js-temporal/polyfill';
|
|
2
|
+
export interface IntlFormatDistanceOptions {
|
|
3
|
+
/**
|
|
4
|
+
* The unit to force formatting in. If not specified, the unit will be automatically selected.
|
|
5
|
+
*/
|
|
6
|
+
unit?: Intl.RelativeTimeFormatUnit;
|
|
7
|
+
/**
|
|
8
|
+
* The locale to use for formatting. Defaults to the system locale.
|
|
9
|
+
*/
|
|
10
|
+
locale?: string | string[];
|
|
11
|
+
/**
|
|
12
|
+
* The locale matching algorithm to use.
|
|
13
|
+
*/
|
|
14
|
+
localeMatcher?: 'best fit' | 'lookup';
|
|
15
|
+
/**
|
|
16
|
+
* Whether to use numeric values always, or use special strings like "yesterday", "tomorrow", etc.
|
|
17
|
+
* Defaults to 'auto'.
|
|
18
|
+
*/
|
|
19
|
+
numeric?: 'always' | 'auto';
|
|
20
|
+
/**
|
|
21
|
+
* The formatting style to use.
|
|
22
|
+
*/
|
|
23
|
+
style?: 'long' | 'short' | 'narrow';
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Formats the distance between two dates as a human-readable, internationalized string.
|
|
27
|
+
*
|
|
28
|
+
* The function automatically picks the most appropriate unit based on the distance between dates.
|
|
29
|
+
* For example, if the distance is a few hours, it returns "in X hours". If the distance is a few
|
|
30
|
+
* months, it returns "in X months".
|
|
31
|
+
*
|
|
32
|
+
* You can force a specific unit using the `options.unit` parameter.
|
|
33
|
+
*
|
|
34
|
+
* @param laterDate - The later date to compare
|
|
35
|
+
* @param earlierDate - The earlier date to compare with
|
|
36
|
+
* @param options - Formatting options
|
|
37
|
+
* @returns The formatted distance string
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```typescript
|
|
41
|
+
* const later = Temporal.Instant.from('2024-01-01T12:00:00Z');
|
|
42
|
+
* const earlier = Temporal.Instant.from('2024-01-01T11:00:00Z');
|
|
43
|
+
*
|
|
44
|
+
* intlFormatDistance(later, earlier);
|
|
45
|
+
* // => 'in 1 hour'
|
|
46
|
+
*
|
|
47
|
+
* intlFormatDistance(earlier, later);
|
|
48
|
+
* // => '1 hour ago'
|
|
49
|
+
* ```
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* ```typescript
|
|
53
|
+
* // Force a specific unit
|
|
54
|
+
* const later = Temporal.Instant.from('2025-01-01T00:00:00Z');
|
|
55
|
+
* const earlier = Temporal.Instant.from('2024-01-01T00:00:00Z');
|
|
56
|
+
*
|
|
57
|
+
* intlFormatDistance(later, earlier, { unit: 'quarter' });
|
|
58
|
+
* // => 'in 4 quarters'
|
|
59
|
+
* ```
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* ```typescript
|
|
63
|
+
* // Use a different locale
|
|
64
|
+
* const later = Temporal.Instant.from('2024-01-01T12:00:00Z');
|
|
65
|
+
* const earlier = Temporal.Instant.from('2024-01-01T11:00:00Z');
|
|
66
|
+
*
|
|
67
|
+
* intlFormatDistance(later, earlier, { locale: 'es' });
|
|
68
|
+
* // => 'dentro de 1 hora'
|
|
69
|
+
* ```
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* ```typescript
|
|
73
|
+
* // Use numeric: 'always' to avoid special strings
|
|
74
|
+
* const later = Temporal.Instant.from('2024-01-02T00:00:00Z');
|
|
75
|
+
* const earlier = Temporal.Instant.from('2024-01-01T00:00:00Z');
|
|
76
|
+
*
|
|
77
|
+
* intlFormatDistance(later, earlier, { numeric: 'auto' });
|
|
78
|
+
* // => 'tomorrow'
|
|
79
|
+
*
|
|
80
|
+
* intlFormatDistance(later, earlier, { numeric: 'always' });
|
|
81
|
+
* // => 'in 1 day'
|
|
82
|
+
* ```
|
|
83
|
+
*/
|
|
84
|
+
export declare function intlFormatDistance(laterDate: Temporal.Instant | Temporal.ZonedDateTime, earlierDate: Temporal.Instant | Temporal.ZonedDateTime, options?: IntlFormatDistanceOptions): string;
|
|
85
|
+
//# sourceMappingURL=intlFormatDistance.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"intlFormatDistance.d.ts","sourceRoot":"","sources":["../src/intlFormatDistance.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAUtD,MAAM,WAAW,yBAAyB;IACxC;;OAEG;IACH,IAAI,CAAC,EAAE,IAAI,CAAC,sBAAsB,CAAC;IACnC;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAC3B;;OAEG;IACH,aAAa,CAAC,EAAE,UAAU,GAAG,QAAQ,CAAC;IACtC;;;OAGG;IACH,OAAO,CAAC,EAAE,QAAQ,GAAG,MAAM,CAAC;IAC5B;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,QAAQ,CAAC;CACrC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0DG;AACH,wBAAgB,kBAAkB,CAChC,SAAS,EAAE,QAAQ,CAAC,OAAO,GAAG,QAAQ,CAAC,aAAa,EACpD,WAAW,EAAE,QAAQ,CAAC,OAAO,GAAG,QAAQ,CAAC,aAAa,EACtD,OAAO,CAAC,EAAE,yBAAyB,GAClC,MAAM,CAuER"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import {
|
|
2
|
+
intlFormatDistance
|
|
3
|
+
} from "./chunk-NL5LWPJI.js";
|
|
4
|
+
import "./chunk-PVAOUYXF.js";
|
|
5
|
+
import "./chunk-CHW2EN2O.js";
|
|
6
|
+
import "./chunk-6IP245MS.js";
|
|
7
|
+
import "./chunk-PIDXROVB.js";
|
|
8
|
+
import "./chunk-RJY62CDU.js";
|
|
9
|
+
import "./chunk-BIAPE4MR.js";
|
|
10
|
+
import "./chunk-ZHRMURYP.js";
|
|
11
|
+
import "./chunk-MJSZNWCV.js";
|
|
12
|
+
export {
|
|
13
|
+
intlFormatDistance
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=intlFormatDistance.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"intlFormatDistance.test.d.ts","sourceRoot":"","sources":["../src/intlFormatDistance.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Temporal } from '@js-temporal/polyfill';
|
|
2
|
+
/**
|
|
3
|
+
* Returns true if the given datetime is in the future.
|
|
4
|
+
* Compares by the underlying instant (epoch time) against the current time.
|
|
5
|
+
*
|
|
6
|
+
* @param date - Datetime to check (Instant or ZonedDateTime)
|
|
7
|
+
* @returns true if date is after the current instant, false otherwise
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* const tomorrow = Temporal.Now.zonedDateTimeISO().add({ days: 1 });
|
|
12
|
+
* const yesterday = Temporal.Now.zonedDateTimeISO().subtract({ days: 1 });
|
|
13
|
+
*
|
|
14
|
+
* isFuture(tomorrow); // true
|
|
15
|
+
* isFuture(yesterday); // false
|
|
16
|
+
* ```
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```ts
|
|
20
|
+
* // Works with Instant too
|
|
21
|
+
* const futureInstant = Temporal.Now.instant().add({ hours: 1 });
|
|
22
|
+
*
|
|
23
|
+
* isFuture(futureInstant); // true
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```ts
|
|
28
|
+
* // Works with any timezone
|
|
29
|
+
* const futureInTokyo = Temporal.ZonedDateTime.from('2100-01-01T00:00:00+09:00[Asia/Tokyo]');
|
|
30
|
+
*
|
|
31
|
+
* isFuture(futureInTokyo); // true
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
export declare function isFuture(date: Temporal.Instant | Temporal.ZonedDateTime): boolean;
|
|
35
|
+
//# sourceMappingURL=isFuture.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isFuture.d.ts","sourceRoot":"","sources":["../src/isFuture.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAGjD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,wBAAgB,QAAQ,CACtB,IAAI,EAAE,QAAQ,CAAC,OAAO,GAAG,QAAQ,CAAC,aAAa,GAC9C,OAAO,CAKT"}
|
package/dist/isFuture.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isFuture.test.d.ts","sourceRoot":"","sources":["../src/isFuture.test.ts"],"names":[],"mappings":""}
|
package/dist/isPast.d.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Temporal } from '@js-temporal/polyfill';
|
|
2
|
+
/**
|
|
3
|
+
* Returns true if the given datetime is in the past.
|
|
4
|
+
* Compares by the underlying instant (epoch time) against the current time.
|
|
5
|
+
*
|
|
6
|
+
* @param date - Datetime to check (Instant or ZonedDateTime)
|
|
7
|
+
* @returns true if date is before the current instant, false otherwise
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* const yesterday = Temporal.Now.zonedDateTimeISO().subtract({ days: 1 });
|
|
12
|
+
* const tomorrow = Temporal.Now.zonedDateTimeISO().add({ days: 1 });
|
|
13
|
+
*
|
|
14
|
+
* isPast(yesterday); // true
|
|
15
|
+
* isPast(tomorrow); // false
|
|
16
|
+
* ```
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```ts
|
|
20
|
+
* // Works with Instant too
|
|
21
|
+
* const pastInstant = Temporal.Now.instant().subtract({ hours: 1 });
|
|
22
|
+
*
|
|
23
|
+
* isPast(pastInstant); // true
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```ts
|
|
28
|
+
* // Works with any timezone
|
|
29
|
+
* const pastInTokyo = Temporal.ZonedDateTime.from('1970-01-01T00:00:00+09:00[Asia/Tokyo]');
|
|
30
|
+
*
|
|
31
|
+
* isPast(pastInTokyo); // true
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
export declare function isPast(date: Temporal.Instant | Temporal.ZonedDateTime): boolean;
|
|
35
|
+
//# sourceMappingURL=isPast.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isPast.d.ts","sourceRoot":"","sources":["../src/isPast.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAGjD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,wBAAgB,MAAM,CACpB,IAAI,EAAE,QAAQ,CAAC,OAAO,GAAG,QAAQ,CAAC,aAAa,GAC9C,OAAO,CAKT"}
|
package/dist/isPast.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isPast.test.d.ts","sourceRoot":"","sources":["../src/isPast.test.ts"],"names":[],"mappings":""}
|
package/package.json
CHANGED