@gobrand/tiempo 2.3.1 → 2.3.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 +79 -0
- package/dist/chunk-3A6X6WV5.js +186 -0
- package/dist/chunk-3A6X6WV5.js.map +1 -0
- package/dist/chunk-4E7OGJ3F.js +10 -0
- package/dist/chunk-4E7OGJ3F.js.map +1 -0
- package/dist/chunk-BPZ7BRJW.js +10 -0
- package/dist/chunk-BPZ7BRJW.js.map +1 -0
- package/dist/chunk-O6RIN7K3.js +10 -0
- package/dist/chunk-O6RIN7K3.js.map +1 -0
- package/dist/formatPlainDate.d.ts +29 -0
- package/dist/formatPlainDate.d.ts.map +1 -0
- package/dist/formatPlainDate.js +7 -0
- package/dist/formatPlainDate.js.map +1 -0
- package/dist/formatPlainDate.test.d.ts +2 -0
- package/dist/formatPlainDate.test.d.ts.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +51 -35
- package/dist/isPlainDateAfter.d.ts +21 -0
- package/dist/isPlainDateAfter.d.ts.map +1 -0
- package/dist/isPlainDateAfter.js +7 -0
- package/dist/isPlainDateAfter.js.map +1 -0
- package/dist/isPlainDateAfter.test.d.ts +2 -0
- package/dist/isPlainDateAfter.test.d.ts.map +1 -0
- package/dist/isPlainDateBefore.d.ts +21 -0
- package/dist/isPlainDateBefore.d.ts.map +1 -0
- package/dist/isPlainDateBefore.js +7 -0
- package/dist/isPlainDateBefore.js.map +1 -0
- package/dist/isPlainDateBefore.test.d.ts +2 -0
- package/dist/isPlainDateBefore.test.d.ts.map +1 -0
- package/dist/isPlainDateEqual.d.ts +21 -0
- package/dist/isPlainDateEqual.d.ts.map +1 -0
- package/dist/isPlainDateEqual.js +7 -0
- package/dist/isPlainDateEqual.js.map +1 -0
- package/dist/isPlainDateEqual.test.d.ts +2 -0
- package/dist/isPlainDateEqual.test.d.ts.map +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -314,6 +314,47 @@ format(instant, "yyyy-MM-dd HH:mm", { timeZone: "America/New_York" }); // "2025-
|
|
|
314
314
|
format(instant, "yyyy-MM-dd HH:mm", { timeZone: "Asia/Tokyo" }); // "2025-01-21 05:30"
|
|
315
315
|
```
|
|
316
316
|
|
|
317
|
+
#### `formatPlainDate(date, formatStr, options?)`
|
|
318
|
+
|
|
319
|
+
Format a Temporal.PlainDate using date-fns-like format tokens. Only supports date-related tokens (no time or timezone tokens).
|
|
320
|
+
|
|
321
|
+
**Parameters:**
|
|
322
|
+
- `date` (Temporal.PlainDate): A Temporal.PlainDate to format
|
|
323
|
+
- `formatStr` (string): Format string using date-fns tokens (e.g., "yyyy-MM-dd")
|
|
324
|
+
- `options` (FormatPlainDateOptions, optional): Configuration for locale
|
|
325
|
+
- `locale` (string): BCP 47 language tag (default: "en-US")
|
|
326
|
+
|
|
327
|
+
**Returns:** `string` - Formatted date string
|
|
328
|
+
|
|
329
|
+
**Supported tokens:**
|
|
330
|
+
- **Year**: `yyyy` (2025), `yy` (25), `y` (2025)
|
|
331
|
+
- **Month**: `MMMM` (January), `MMM` (Jan), `MM` (01), `M` (1), `Mo` (1st)
|
|
332
|
+
- **Day**: `dd` (20), `d` (20), `do` (20th)
|
|
333
|
+
- **Weekday**: `EEEE` (Monday), `EEE` (Mon), `EEEEE` (M)
|
|
334
|
+
- **Quarter**: `Q` (1), `QQQ` (Q1), `QQQQ` (1st quarter)
|
|
335
|
+
- **Era**: `G` (AD), `GGGG` (Anno Domini)
|
|
336
|
+
- **Escape text**: Use single quotes `'...'`, double single quotes `''` for literal quote
|
|
337
|
+
|
|
338
|
+
**Example:**
|
|
339
|
+
```typescript
|
|
340
|
+
import { formatPlainDate, today } from '@gobrand/tiempo';
|
|
341
|
+
|
|
342
|
+
const date = Temporal.PlainDate.from("2025-01-20");
|
|
343
|
+
|
|
344
|
+
formatPlainDate(date, "yyyy-MM-dd"); // "2025-01-20"
|
|
345
|
+
formatPlainDate(date, "MMMM d, yyyy"); // "January 20, 2025"
|
|
346
|
+
formatPlainDate(date, "EEEE, MMMM do, yyyy"); // "Monday, January 20th, 2025"
|
|
347
|
+
formatPlainDate(date, "MM/dd/yyyy"); // "01/20/2025"
|
|
348
|
+
|
|
349
|
+
// With locale
|
|
350
|
+
formatPlainDate(date, "MMMM d, yyyy", { locale: "es-ES" }); // "enero 20, 2025"
|
|
351
|
+
formatPlainDate(date, "EEEE", { locale: "de-DE" }); // "Montag"
|
|
352
|
+
|
|
353
|
+
// Use with today()
|
|
354
|
+
const todayFormatted = formatPlainDate(today(), "EEEE, MMMM do");
|
|
355
|
+
// "Thursday, January 23rd"
|
|
356
|
+
```
|
|
357
|
+
|
|
317
358
|
### Start/End Utilities
|
|
318
359
|
|
|
319
360
|
#### `today(timezone?)`
|
|
@@ -853,6 +894,44 @@ const minutesUntil = differenceInMinutes(meeting, now);
|
|
|
853
894
|
console.log(`Meeting starts in ${minutesUntil} minutes`);
|
|
854
895
|
```
|
|
855
896
|
|
|
897
|
+
### PlainDate Comparisons
|
|
898
|
+
|
|
899
|
+
For comparing calendar dates without time or timezone considerations, tiempo provides dedicated PlainDate comparison functions. These are useful for calendars, date pickers, and scheduling UIs where you work with pure dates.
|
|
900
|
+
|
|
901
|
+
#### `isPlainDateBefore(date1, date2)` / `isPlainDateAfter(date1, date2)` / `isPlainDateEqual(date1, date2)`
|
|
902
|
+
|
|
903
|
+
Compare two `Temporal.PlainDate` values. Unlike `isBefore`/`isAfter` which compare instants in time, these functions compare pure calendar dates.
|
|
904
|
+
|
|
905
|
+
```typescript
|
|
906
|
+
import { isPlainDateBefore, isPlainDateAfter, isPlainDateEqual } from '@gobrand/tiempo';
|
|
907
|
+
|
|
908
|
+
const jan20 = Temporal.PlainDate.from('2025-01-20');
|
|
909
|
+
const jan25 = Temporal.PlainDate.from('2025-01-25');
|
|
910
|
+
|
|
911
|
+
isPlainDateBefore(jan20, jan25); // true
|
|
912
|
+
isPlainDateBefore(jan25, jan20); // false
|
|
913
|
+
|
|
914
|
+
isPlainDateAfter(jan25, jan20); // true
|
|
915
|
+
isPlainDateAfter(jan20, jan25); // false
|
|
916
|
+
|
|
917
|
+
isPlainDateEqual(jan20, Temporal.PlainDate.from('2025-01-20')); // true
|
|
918
|
+
isPlainDateEqual(jan20, jan25); // false
|
|
919
|
+
```
|
|
920
|
+
|
|
921
|
+
**When to use PlainDate vs Instant/ZonedDateTime:**
|
|
922
|
+
- Use `isPlainDateBefore`/`isPlainDateAfter` when comparing calendar dates (e.g., "Is January 20th before January 25th?")
|
|
923
|
+
- Use `isBefore`/`isAfter` when comparing specific moments in time (e.g., "Did event A happen before event B?")
|
|
924
|
+
|
|
925
|
+
```typescript
|
|
926
|
+
// Calendar UI: Disable dates before today
|
|
927
|
+
const isDateDisabled = (date: Temporal.PlainDate) =>
|
|
928
|
+
isPlainDateBefore(date, today());
|
|
929
|
+
|
|
930
|
+
// Booking system: Check if selected date is in the past
|
|
931
|
+
const isPastDate = (date: Temporal.PlainDate) =>
|
|
932
|
+
isPlainDateBefore(date, today());
|
|
933
|
+
```
|
|
934
|
+
|
|
856
935
|
## Browser Support
|
|
857
936
|
|
|
858
937
|
The Temporal API is a Stage 3 TC39 proposal. The polyfill `@js-temporal/polyfill` is included as a dependency, so you're ready to go!
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
// src/formatPlainDate.ts
|
|
2
|
+
import "@js-temporal/polyfill";
|
|
3
|
+
function formatPlainDate(date, formatStr, options = {}) {
|
|
4
|
+
const { locale = "en-US" } = options;
|
|
5
|
+
let result = "";
|
|
6
|
+
let i = 0;
|
|
7
|
+
const len = formatStr.length;
|
|
8
|
+
while (i < len) {
|
|
9
|
+
const char = formatStr[i];
|
|
10
|
+
if (!char) break;
|
|
11
|
+
if (char === "'") {
|
|
12
|
+
if (i + 1 < len && formatStr[i + 1] === "'") {
|
|
13
|
+
result += "'";
|
|
14
|
+
i += 2;
|
|
15
|
+
continue;
|
|
16
|
+
}
|
|
17
|
+
i++;
|
|
18
|
+
while (i < len) {
|
|
19
|
+
if (formatStr[i] === "'") {
|
|
20
|
+
if (i + 1 < len && formatStr[i + 1] === "'") {
|
|
21
|
+
result += "'";
|
|
22
|
+
i += 2;
|
|
23
|
+
} else {
|
|
24
|
+
i++;
|
|
25
|
+
break;
|
|
26
|
+
}
|
|
27
|
+
} else {
|
|
28
|
+
result += formatStr[i];
|
|
29
|
+
i++;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
continue;
|
|
33
|
+
}
|
|
34
|
+
const token = consumeToken(formatStr, i, char);
|
|
35
|
+
if (token !== null) {
|
|
36
|
+
result += formatToken(token, date, locale);
|
|
37
|
+
i += token.length;
|
|
38
|
+
} else {
|
|
39
|
+
result += char;
|
|
40
|
+
i++;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return result;
|
|
44
|
+
}
|
|
45
|
+
function consumeToken(formatStr, start, char) {
|
|
46
|
+
if (char === "M" && start + 1 < formatStr.length && formatStr[start + 1] === "o") {
|
|
47
|
+
return "Mo";
|
|
48
|
+
}
|
|
49
|
+
if (char === "d" && start + 1 < formatStr.length && formatStr[start + 1] === "o") {
|
|
50
|
+
return "do";
|
|
51
|
+
}
|
|
52
|
+
let end = start;
|
|
53
|
+
while (end < formatStr.length && formatStr[end] === char) {
|
|
54
|
+
end++;
|
|
55
|
+
}
|
|
56
|
+
const count = end - start;
|
|
57
|
+
const validTokens = [
|
|
58
|
+
// Era
|
|
59
|
+
"GGGGG",
|
|
60
|
+
"GGGG",
|
|
61
|
+
"GGG",
|
|
62
|
+
"GG",
|
|
63
|
+
"G",
|
|
64
|
+
// Year
|
|
65
|
+
"yyyy",
|
|
66
|
+
"yyy",
|
|
67
|
+
"yy",
|
|
68
|
+
"y",
|
|
69
|
+
// Quarter
|
|
70
|
+
"QQQQQ",
|
|
71
|
+
"QQQQ",
|
|
72
|
+
"QQQ",
|
|
73
|
+
"QQ",
|
|
74
|
+
"Q",
|
|
75
|
+
// Month
|
|
76
|
+
"MMMMM",
|
|
77
|
+
"MMMM",
|
|
78
|
+
"MMM",
|
|
79
|
+
"MM",
|
|
80
|
+
"M",
|
|
81
|
+
// Day
|
|
82
|
+
"dd",
|
|
83
|
+
"d",
|
|
84
|
+
// Weekday
|
|
85
|
+
"EEEEEE",
|
|
86
|
+
"EEEEE",
|
|
87
|
+
"EEEE",
|
|
88
|
+
"EEE",
|
|
89
|
+
"EE",
|
|
90
|
+
"E"
|
|
91
|
+
];
|
|
92
|
+
for (let len = Math.min(count, 6); len > 0; len--) {
|
|
93
|
+
const candidate = char.repeat(len);
|
|
94
|
+
if (validTokens.includes(candidate)) {
|
|
95
|
+
return candidate;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
return null;
|
|
99
|
+
}
|
|
100
|
+
function formatToken(token, date, locale) {
|
|
101
|
+
switch (token) {
|
|
102
|
+
// Era
|
|
103
|
+
case "GGGGG":
|
|
104
|
+
return formatPart(date, "era", "narrow", locale);
|
|
105
|
+
case "GGGG":
|
|
106
|
+
return formatPart(date, "era", "long", locale);
|
|
107
|
+
case "GGG":
|
|
108
|
+
case "GG":
|
|
109
|
+
case "G":
|
|
110
|
+
return formatPart(date, "era", "short", locale);
|
|
111
|
+
// Year
|
|
112
|
+
case "yyyy":
|
|
113
|
+
return date.year.toString().padStart(4, "0");
|
|
114
|
+
case "yyy":
|
|
115
|
+
return date.year.toString().padStart(3, "0");
|
|
116
|
+
case "yy":
|
|
117
|
+
return (date.year % 100).toString().padStart(2, "0");
|
|
118
|
+
case "y":
|
|
119
|
+
return date.year.toString();
|
|
120
|
+
// Quarter
|
|
121
|
+
case "QQQQQ":
|
|
122
|
+
return Math.ceil(date.month / 3).toString();
|
|
123
|
+
case "QQQQ": {
|
|
124
|
+
const quarter = Math.ceil(date.month / 3);
|
|
125
|
+
return `${quarter}${getOrdinalSuffix(quarter)} quarter`;
|
|
126
|
+
}
|
|
127
|
+
case "QQQ":
|
|
128
|
+
return `Q${Math.ceil(date.month / 3)}`;
|
|
129
|
+
case "QQ":
|
|
130
|
+
return Math.ceil(date.month / 3).toString().padStart(2, "0");
|
|
131
|
+
case "Q":
|
|
132
|
+
return Math.ceil(date.month / 3).toString();
|
|
133
|
+
// Month
|
|
134
|
+
case "MMMMM":
|
|
135
|
+
return formatPart(date, "month", "narrow", locale);
|
|
136
|
+
case "MMMM":
|
|
137
|
+
return formatPart(date, "month", "long", locale);
|
|
138
|
+
case "MMM":
|
|
139
|
+
return formatPart(date, "month", "short", locale);
|
|
140
|
+
case "MM":
|
|
141
|
+
return date.month.toString().padStart(2, "0");
|
|
142
|
+
case "Mo":
|
|
143
|
+
return `${date.month}${getOrdinalSuffix(date.month)}`;
|
|
144
|
+
case "M":
|
|
145
|
+
return date.month.toString();
|
|
146
|
+
// Day of month
|
|
147
|
+
case "do":
|
|
148
|
+
return `${date.day}${getOrdinalSuffix(date.day)}`;
|
|
149
|
+
case "dd":
|
|
150
|
+
return date.day.toString().padStart(2, "0");
|
|
151
|
+
case "d":
|
|
152
|
+
return date.day.toString();
|
|
153
|
+
// Day of week
|
|
154
|
+
case "EEEEEE":
|
|
155
|
+
return formatPart(date, "weekday", "short", locale).slice(0, 2);
|
|
156
|
+
case "EEEEE":
|
|
157
|
+
return formatPart(date, "weekday", "narrow", locale);
|
|
158
|
+
case "EEEE":
|
|
159
|
+
return formatPart(date, "weekday", "long", locale);
|
|
160
|
+
case "EEE":
|
|
161
|
+
case "EE":
|
|
162
|
+
case "E":
|
|
163
|
+
return formatPart(date, "weekday", "short", locale);
|
|
164
|
+
default:
|
|
165
|
+
return token;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
function formatPart(date, part, style, locale) {
|
|
169
|
+
const options = {
|
|
170
|
+
[part]: style
|
|
171
|
+
};
|
|
172
|
+
return date.toLocaleString(locale, options);
|
|
173
|
+
}
|
|
174
|
+
function getOrdinalSuffix(num) {
|
|
175
|
+
const j = num % 10;
|
|
176
|
+
const k = num % 100;
|
|
177
|
+
if (j === 1 && k !== 11) return "st";
|
|
178
|
+
if (j === 2 && k !== 12) return "nd";
|
|
179
|
+
if (j === 3 && k !== 13) return "rd";
|
|
180
|
+
return "th";
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
export {
|
|
184
|
+
formatPlainDate
|
|
185
|
+
};
|
|
186
|
+
//# sourceMappingURL=chunk-3A6X6WV5.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/formatPlainDate.ts"],"sourcesContent":["import { Temporal } from '@js-temporal/polyfill';\n\nexport interface FormatPlainDateOptions {\n locale?: string;\n}\n\n/**\n * Format a Temporal.PlainDate using date-fns-like format tokens.\n * Uses Intl.DateTimeFormat under the hood for locale support.\n *\n * Only supports date-related tokens (no time or timezone tokens).\n *\n * @param date - A Temporal.PlainDate to format\n * @param formatStr - Format string using date-fns tokens (e.g., \"yyyy-MM-dd\")\n * @param options - Optional configuration for locale\n * @returns Formatted date string\n *\n * @example\n * ```typescript\n * const date = Temporal.PlainDate.from(\"2025-01-20\");\n *\n * formatPlainDate(date, \"yyyy-MM-dd\"); // \"2025-01-20\"\n * formatPlainDate(date, \"MMMM d, yyyy\"); // \"January 20, 2025\"\n * formatPlainDate(date, \"EEEE, MMMM do, yyyy\"); // \"Monday, January 20th, 2025\"\n *\n * // With locale\n * formatPlainDate(date, \"MMMM d, yyyy\", { locale: \"es-ES\" }); // \"enero 20, 2025\"\n * ```\n */\nexport function formatPlainDate(\n date: Temporal.PlainDate,\n formatStr: string,\n options: FormatPlainDateOptions = {}\n): string {\n const { locale = 'en-US' } = options;\n\n let result = '';\n let i = 0;\n const len = formatStr.length;\n\n while (i < len) {\n const char = formatStr[i];\n if (!char) break;\n\n // Handle escaped text\n if (char === \"'\") {\n // Check for double single quote (not inside a string, just '')\n if (i + 1 < len && formatStr[i + 1] === \"'\") {\n result += \"'\";\n i += 2;\n continue;\n }\n // Find closing quote, handling '' inside the string\n i++;\n while (i < len) {\n if (formatStr[i] === \"'\") {\n // Check if it's a doubled quote ''\n if (i + 1 < len && formatStr[i + 1] === \"'\") {\n result += \"'\";\n i += 2;\n } else {\n // End of quoted string\n i++;\n break;\n }\n } else {\n result += formatStr[i];\n i++;\n }\n }\n continue;\n }\n\n // Check for tokens by looking ahead\n const token = consumeToken(formatStr, i, char);\n if (token !== null) {\n result += formatToken(token, date, locale);\n i += token.length;\n } else {\n result += char;\n i++;\n }\n }\n\n return result;\n}\n\nfunction consumeToken(formatStr: string, start: number, char: string): string | null {\n // Special case for 'Mo' and 'do' - these end with 'o'\n if (char === 'M' && start + 1 < formatStr.length && formatStr[start + 1] === 'o') {\n return 'Mo';\n }\n if (char === 'd' && start + 1 < formatStr.length && formatStr[start + 1] === 'o') {\n return 'do';\n }\n\n // Count how many consecutive identical characters\n let end = start;\n while (end < formatStr.length && formatStr[end] === char) {\n end++;\n }\n const count = end - start;\n\n // Valid tokens for PlainDate (date-only, no time/timezone)\n const validTokens = [\n // Era\n 'GGGGG',\n 'GGGG',\n 'GGG',\n 'GG',\n 'G',\n // Year\n 'yyyy',\n 'yyy',\n 'yy',\n 'y',\n // Quarter\n 'QQQQQ',\n 'QQQQ',\n 'QQQ',\n 'QQ',\n 'Q',\n // Month\n 'MMMMM',\n 'MMMM',\n 'MMM',\n 'MM',\n 'M',\n // Day\n 'dd',\n 'd',\n // Weekday\n 'EEEEEE',\n 'EEEEE',\n 'EEEE',\n 'EEE',\n 'EE',\n 'E',\n ];\n\n // Try to match from longest to shortest\n for (let len = Math.min(count, 6); len > 0; len--) {\n const candidate = char.repeat(len);\n if (validTokens.includes(candidate)) {\n return candidate;\n }\n }\n\n return null;\n}\n\nfunction formatToken(token: string, date: Temporal.PlainDate, locale: string): string {\n switch (token) {\n // Era\n case 'GGGGG':\n return formatPart(date, 'era', 'narrow', locale);\n case 'GGGG':\n return formatPart(date, 'era', 'long', locale);\n case 'GGG':\n case 'GG':\n case 'G':\n return formatPart(date, 'era', 'short', locale);\n\n // Year\n case 'yyyy':\n return date.year.toString().padStart(4, '0');\n case 'yyy':\n return date.year.toString().padStart(3, '0');\n case 'yy':\n return (date.year % 100).toString().padStart(2, '0');\n case 'y':\n return date.year.toString();\n\n // Quarter\n case 'QQQQQ':\n return Math.ceil(date.month / 3).toString();\n case 'QQQQ': {\n const quarter = Math.ceil(date.month / 3);\n return `${quarter}${getOrdinalSuffix(quarter)} quarter`;\n }\n case 'QQQ':\n return `Q${Math.ceil(date.month / 3)}`;\n case 'QQ':\n return Math.ceil(date.month / 3)\n .toString()\n .padStart(2, '0');\n case 'Q':\n return Math.ceil(date.month / 3).toString();\n\n // Month\n case 'MMMMM':\n return formatPart(date, 'month', 'narrow', locale);\n case 'MMMM':\n return formatPart(date, 'month', 'long', locale);\n case 'MMM':\n return formatPart(date, 'month', 'short', locale);\n case 'MM':\n return date.month.toString().padStart(2, '0');\n case 'Mo':\n return `${date.month}${getOrdinalSuffix(date.month)}`;\n case 'M':\n return date.month.toString();\n\n // Day of month\n case 'do':\n return `${date.day}${getOrdinalSuffix(date.day)}`;\n case 'dd':\n return date.day.toString().padStart(2, '0');\n case 'd':\n return date.day.toString();\n\n // Day of week\n case 'EEEEEE':\n return formatPart(date, 'weekday', 'short', locale).slice(0, 2);\n case 'EEEEE':\n return formatPart(date, 'weekday', 'narrow', locale);\n case 'EEEE':\n return formatPart(date, 'weekday', 'long', locale);\n case 'EEE':\n case 'EE':\n case 'E':\n return formatPart(date, 'weekday', 'short', locale);\n\n default:\n return token;\n }\n}\n\nfunction formatPart(\n date: Temporal.PlainDate,\n part: 'era' | 'year' | 'month' | 'weekday' | 'day',\n style: 'narrow' | 'short' | 'long' | 'numeric' | '2-digit',\n locale: string\n): string {\n const options: Intl.DateTimeFormatOptions = {\n [part]: style,\n };\n\n return date.toLocaleString(locale, options);\n}\n\nfunction getOrdinalSuffix(num: number): string {\n const j = num % 10;\n const k = num % 100;\n if (j === 1 && k !== 11) return 'st';\n if (j === 2 && k !== 12) return 'nd';\n if (j === 3 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pD;AACE,aAAO;AAAA,EACX;AACF;AAEA,SAAS,WACP,MACA,MACA,OACA,QACQ;AACR,QAAM,UAAsC;AAAA,IAC1C,CAAC,IAAI,GAAG;AAAA,EACV;AAEA,SAAO,KAAK,eAAe,QAAQ,OAAO;AAC5C;AAEA,SAAS,iBAAiB,KAAqB;AAC7C,QAAM,IAAI,MAAM;AAChB,QAAM,IAAI,MAAM;AAChB,MAAI,MAAM,KAAK,MAAM,GAAI,QAAO;AAChC,MAAI,MAAM,KAAK,MAAM,GAAI,QAAO;AAChC,MAAI,MAAM,KAAK,MAAM,GAAI,QAAO;AAChC,SAAO;AACT;","names":[]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// src/isPlainDateBefore.ts
|
|
2
|
+
import { Temporal } from "@js-temporal/polyfill";
|
|
3
|
+
function isPlainDateBefore(date1, date2) {
|
|
4
|
+
return Temporal.PlainDate.compare(date1, date2) < 0;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export {
|
|
8
|
+
isPlainDateBefore
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=chunk-4E7OGJ3F.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/isPlainDateBefore.ts"],"sourcesContent":["import { Temporal } from '@js-temporal/polyfill';\n\n/**\n * Returns true if the first plain date is before the second plain date.\n * Compares calendar dates without time or timezone considerations.\n *\n * @param date1 - First plain date\n * @param date2 - Second plain date\n * @returns true if date1 is before date2, false otherwise\n *\n * @example\n * ```ts\n * const jan20 = Temporal.PlainDate.from('2025-01-20');\n * const jan25 = Temporal.PlainDate.from('2025-01-25');\n *\n * isPlainDateBefore(jan20, jan25); // true\n * isPlainDateBefore(jan25, jan20); // false\n * isPlainDateBefore(jan20, jan20); // false\n * ```\n */\nexport function isPlainDateBefore(\n date1: Temporal.PlainDate,\n date2: Temporal.PlainDate\n): boolean {\n return Temporal.PlainDate.compare(date1, date2) < 0;\n}\n"],"mappings":";AAAA,SAAS,gBAAgB;AAoBlB,SAAS,kBACd,OACA,OACS;AACT,SAAO,SAAS,UAAU,QAAQ,OAAO,KAAK,IAAI;AACpD;","names":[]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// src/isPlainDateAfter.ts
|
|
2
|
+
import { Temporal } from "@js-temporal/polyfill";
|
|
3
|
+
function isPlainDateAfter(date1, date2) {
|
|
4
|
+
return Temporal.PlainDate.compare(date1, date2) > 0;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export {
|
|
8
|
+
isPlainDateAfter
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=chunk-BPZ7BRJW.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/isPlainDateAfter.ts"],"sourcesContent":["import { Temporal } from '@js-temporal/polyfill';\n\n/**\n * Returns true if the first plain date is after the second plain date.\n * Compares calendar dates without time or timezone considerations.\n *\n * @param date1 - First plain date\n * @param date2 - Second plain date\n * @returns true if date1 is after date2, false otherwise\n *\n * @example\n * ```ts\n * const jan20 = Temporal.PlainDate.from('2025-01-20');\n * const jan25 = Temporal.PlainDate.from('2025-01-25');\n *\n * isPlainDateAfter(jan25, jan20); // true\n * isPlainDateAfter(jan20, jan25); // false\n * isPlainDateAfter(jan20, jan20); // false\n * ```\n */\nexport function isPlainDateAfter(\n date1: Temporal.PlainDate,\n date2: Temporal.PlainDate\n): boolean {\n return Temporal.PlainDate.compare(date1, date2) > 0;\n}\n"],"mappings":";AAAA,SAAS,gBAAgB;AAoBlB,SAAS,iBACd,OACA,OACS;AACT,SAAO,SAAS,UAAU,QAAQ,OAAO,KAAK,IAAI;AACpD;","names":[]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// src/isPlainDateEqual.ts
|
|
2
|
+
import { Temporal } from "@js-temporal/polyfill";
|
|
3
|
+
function isPlainDateEqual(date1, date2) {
|
|
4
|
+
return Temporal.PlainDate.compare(date1, date2) === 0;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export {
|
|
8
|
+
isPlainDateEqual
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=chunk-O6RIN7K3.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/isPlainDateEqual.ts"],"sourcesContent":["import { Temporal } from '@js-temporal/polyfill';\n\n/**\n * Returns true if the two plain dates are equal.\n * Compares calendar dates without time or timezone considerations.\n *\n * @param date1 - First plain date\n * @param date2 - Second plain date\n * @returns true if date1 equals date2, false otherwise\n *\n * @example\n * ```ts\n * const jan20a = Temporal.PlainDate.from('2025-01-20');\n * const jan20b = Temporal.PlainDate.from('2025-01-20');\n * const jan25 = Temporal.PlainDate.from('2025-01-25');\n *\n * isPlainDateEqual(jan20a, jan20b); // true\n * isPlainDateEqual(jan20a, jan25); // false\n * ```\n */\nexport function isPlainDateEqual(\n date1: Temporal.PlainDate,\n date2: Temporal.PlainDate\n): boolean {\n return Temporal.PlainDate.compare(date1, date2) === 0;\n}\n"],"mappings":";AAAA,SAAS,gBAAgB;AAoBlB,SAAS,iBACd,OACA,OACS;AACT,SAAO,SAAS,UAAU,QAAQ,OAAO,KAAK,MAAM;AACtD;","names":[]}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Temporal } from '@js-temporal/polyfill';
|
|
2
|
+
export interface FormatPlainDateOptions {
|
|
3
|
+
locale?: string;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Format a Temporal.PlainDate using date-fns-like format tokens.
|
|
7
|
+
* Uses Intl.DateTimeFormat under the hood for locale support.
|
|
8
|
+
*
|
|
9
|
+
* Only supports date-related tokens (no time or timezone tokens).
|
|
10
|
+
*
|
|
11
|
+
* @param date - A Temporal.PlainDate to format
|
|
12
|
+
* @param formatStr - Format string using date-fns tokens (e.g., "yyyy-MM-dd")
|
|
13
|
+
* @param options - Optional configuration for locale
|
|
14
|
+
* @returns Formatted date string
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* const date = Temporal.PlainDate.from("2025-01-20");
|
|
19
|
+
*
|
|
20
|
+
* formatPlainDate(date, "yyyy-MM-dd"); // "2025-01-20"
|
|
21
|
+
* formatPlainDate(date, "MMMM d, yyyy"); // "January 20, 2025"
|
|
22
|
+
* formatPlainDate(date, "EEEE, MMMM do, yyyy"); // "Monday, January 20th, 2025"
|
|
23
|
+
*
|
|
24
|
+
* // With locale
|
|
25
|
+
* formatPlainDate(date, "MMMM d, yyyy", { locale: "es-ES" }); // "enero 20, 2025"
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export declare function formatPlainDate(date: Temporal.PlainDate, formatStr: string, options?: FormatPlainDateOptions): string;
|
|
29
|
+
//# sourceMappingURL=formatPlainDate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formatPlainDate.d.ts","sourceRoot":"","sources":["../src/formatPlainDate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAEjD,MAAM,WAAW,sBAAsB;IACrC,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,eAAe,CAC7B,IAAI,EAAE,QAAQ,CAAC,SAAS,EACxB,SAAS,EAAE,MAAM,EACjB,OAAO,GAAE,sBAA2B,GACnC,MAAM,CAoDR"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formatPlainDate.test.d.ts","sourceRoot":"","sources":["../src/formatPlainDate.test.ts"],"names":[],"mappings":""}
|
package/dist/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ export { toUtc } from './toUtc';
|
|
|
3
3
|
export { toUtcString } from './toUtcString';
|
|
4
4
|
export { toDate } from './toDate';
|
|
5
5
|
export { format, type FormatOptions } from './format';
|
|
6
|
+
export { formatPlainDate, type FormatPlainDateOptions } from './formatPlainDate';
|
|
6
7
|
export { today } from './today';
|
|
7
8
|
export { now } from './now';
|
|
8
9
|
export { startOfDay } from './startOfDay';
|
|
@@ -58,4 +59,7 @@ export { differenceInWeeks } from './differenceInWeeks';
|
|
|
58
59
|
export { differenceInMonths } from './differenceInMonths';
|
|
59
60
|
export { differenceInYears } from './differenceInYears';
|
|
60
61
|
export { intlFormatDistance, type IntlFormatDistanceOptions, } from './intlFormatDistance';
|
|
62
|
+
export { isPlainDateBefore } from './isPlainDateBefore';
|
|
63
|
+
export { isPlainDateAfter } from './isPlainDateAfter';
|
|
64
|
+
export { isPlainDateEqual } from './isPlainDateEqual';
|
|
61
65
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,MAAM,EAAE,KAAK,aAAa,EAAE,MAAM,UAAU,CAAC;AACtD,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAC5B,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OA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,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EACL,kBAAkB,EAClB,KAAK,yBAAyB,GAC/B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,21 @@
|
|
|
1
|
+
import {
|
|
2
|
+
toZonedTime
|
|
3
|
+
} from "./chunk-2MP3ESL7.js";
|
|
4
|
+
import {
|
|
5
|
+
today
|
|
6
|
+
} from "./chunk-67QHALIG.js";
|
|
7
|
+
import {
|
|
8
|
+
subNanoseconds
|
|
9
|
+
} from "./chunk-WVHAYLBW.js";
|
|
10
|
+
import {
|
|
11
|
+
subSeconds
|
|
12
|
+
} from "./chunk-BH2YB4MV.js";
|
|
13
|
+
import {
|
|
14
|
+
subWeeks
|
|
15
|
+
} from "./chunk-U4RNUZXO.js";
|
|
16
|
+
import {
|
|
17
|
+
subYears
|
|
18
|
+
} from "./chunk-AHMKY474.js";
|
|
1
19
|
import {
|
|
2
20
|
toDate
|
|
3
21
|
} from "./chunk-TGKWBQ7L.js";
|
|
@@ -8,11 +26,17 @@ import {
|
|
|
8
26
|
toUtcString
|
|
9
27
|
} from "./chunk-DMKGJY4N.js";
|
|
10
28
|
import {
|
|
11
|
-
|
|
12
|
-
} from "./chunk-
|
|
29
|
+
startOfWeek
|
|
30
|
+
} from "./chunk-2WMXB7QL.js";
|
|
13
31
|
import {
|
|
14
|
-
|
|
15
|
-
} from "./chunk-
|
|
32
|
+
startOfYear
|
|
33
|
+
} from "./chunk-YR2UCUIT.js";
|
|
34
|
+
import {
|
|
35
|
+
subDays
|
|
36
|
+
} from "./chunk-YKBP3G7L.js";
|
|
37
|
+
import {
|
|
38
|
+
subHours
|
|
39
|
+
} from "./chunk-XW5MLXX5.js";
|
|
16
40
|
import {
|
|
17
41
|
subMicroseconds
|
|
18
42
|
} from "./chunk-BQBLSXK2.js";
|
|
@@ -26,17 +50,17 @@ import {
|
|
|
26
50
|
subMonths
|
|
27
51
|
} from "./chunk-52NEOY34.js";
|
|
28
52
|
import {
|
|
29
|
-
|
|
30
|
-
} from "./chunk-
|
|
53
|
+
isSameMonth
|
|
54
|
+
} from "./chunk-ADQTZVMH.js";
|
|
31
55
|
import {
|
|
32
|
-
|
|
33
|
-
} from "./chunk-
|
|
56
|
+
isSameNanosecond
|
|
57
|
+
} from "./chunk-S63QUP4W.js";
|
|
34
58
|
import {
|
|
35
|
-
|
|
36
|
-
} from "./chunk-
|
|
59
|
+
isSameSecond
|
|
60
|
+
} from "./chunk-CY746ZUQ.js";
|
|
37
61
|
import {
|
|
38
|
-
|
|
39
|
-
} from "./chunk-
|
|
62
|
+
isSameWeek
|
|
63
|
+
} from "./chunk-JOD4ATPE.js";
|
|
40
64
|
import {
|
|
41
65
|
isSameYear
|
|
42
66
|
} from "./chunk-VLZ3HQQA.js";
|
|
@@ -50,17 +74,17 @@ import {
|
|
|
50
74
|
startOfMonth
|
|
51
75
|
} from "./chunk-TU2UNOOW.js";
|
|
52
76
|
import {
|
|
53
|
-
|
|
54
|
-
} from "./chunk-
|
|
77
|
+
isPlainDateAfter
|
|
78
|
+
} from "./chunk-BPZ7BRJW.js";
|
|
55
79
|
import {
|
|
56
|
-
|
|
57
|
-
} from "./chunk-
|
|
80
|
+
isPlainDateBefore
|
|
81
|
+
} from "./chunk-4E7OGJ3F.js";
|
|
58
82
|
import {
|
|
59
|
-
|
|
60
|
-
} from "./chunk-
|
|
83
|
+
isPlainDateEqual
|
|
84
|
+
} from "./chunk-O6RIN7K3.js";
|
|
61
85
|
import {
|
|
62
|
-
|
|
63
|
-
} from "./chunk-
|
|
86
|
+
isSameDay
|
|
87
|
+
} from "./chunk-RW3C2677.js";
|
|
64
88
|
import {
|
|
65
89
|
isSameHour
|
|
66
90
|
} from "./chunk-EEQ3REET.js";
|
|
@@ -73,21 +97,12 @@ import {
|
|
|
73
97
|
import {
|
|
74
98
|
isSameMinute
|
|
75
99
|
} from "./chunk-LDO6PRNJ.js";
|
|
76
|
-
import {
|
|
77
|
-
isSameMonth
|
|
78
|
-
} from "./chunk-ADQTZVMH.js";
|
|
79
|
-
import {
|
|
80
|
-
isSameNanosecond
|
|
81
|
-
} from "./chunk-S63QUP4W.js";
|
|
82
|
-
import {
|
|
83
|
-
isSameSecond
|
|
84
|
-
} from "./chunk-CY746ZUQ.js";
|
|
85
|
-
import {
|
|
86
|
-
isSameWeek
|
|
87
|
-
} from "./chunk-JOD4ATPE.js";
|
|
88
100
|
import {
|
|
89
101
|
format
|
|
90
102
|
} from "./chunk-2G5RJGPR.js";
|
|
103
|
+
import {
|
|
104
|
+
formatPlainDate
|
|
105
|
+
} from "./chunk-3A6X6WV5.js";
|
|
91
106
|
import {
|
|
92
107
|
intlFormatDistance
|
|
93
108
|
} from "./chunk-XEDXPI5G.js";
|
|
@@ -103,9 +118,6 @@ import {
|
|
|
103
118
|
import {
|
|
104
119
|
isPast
|
|
105
120
|
} from "./chunk-2H4KLXGL.js";
|
|
106
|
-
import {
|
|
107
|
-
isSameDay
|
|
108
|
-
} from "./chunk-RW3C2677.js";
|
|
109
121
|
import {
|
|
110
122
|
differenceInNanoseconds
|
|
111
123
|
} from "./chunk-OABS374T.js";
|
|
@@ -206,11 +218,15 @@ export {
|
|
|
206
218
|
endOfWeek,
|
|
207
219
|
endOfYear,
|
|
208
220
|
format,
|
|
221
|
+
formatPlainDate,
|
|
209
222
|
intlFormatDistance,
|
|
210
223
|
isAfter,
|
|
211
224
|
isBefore,
|
|
212
225
|
isFuture,
|
|
213
226
|
isPast,
|
|
227
|
+
isPlainDateAfter,
|
|
228
|
+
isPlainDateBefore,
|
|
229
|
+
isPlainDateEqual,
|
|
214
230
|
isSameDay,
|
|
215
231
|
isSameHour,
|
|
216
232
|
isSameMicrosecond,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Temporal } from '@js-temporal/polyfill';
|
|
2
|
+
/**
|
|
3
|
+
* Returns true if the first plain date is after the second plain date.
|
|
4
|
+
* Compares calendar dates without time or timezone considerations.
|
|
5
|
+
*
|
|
6
|
+
* @param date1 - First plain date
|
|
7
|
+
* @param date2 - Second plain date
|
|
8
|
+
* @returns true if date1 is after date2, false otherwise
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* const jan20 = Temporal.PlainDate.from('2025-01-20');
|
|
13
|
+
* const jan25 = Temporal.PlainDate.from('2025-01-25');
|
|
14
|
+
*
|
|
15
|
+
* isPlainDateAfter(jan25, jan20); // true
|
|
16
|
+
* isPlainDateAfter(jan20, jan25); // false
|
|
17
|
+
* isPlainDateAfter(jan20, jan20); // false
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export declare function isPlainDateAfter(date1: Temporal.PlainDate, date2: Temporal.PlainDate): boolean;
|
|
21
|
+
//# sourceMappingURL=isPlainDateAfter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isPlainDateAfter.d.ts","sourceRoot":"","sources":["../src/isPlainDateAfter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAEjD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,QAAQ,CAAC,SAAS,EACzB,KAAK,EAAE,QAAQ,CAAC,SAAS,GACxB,OAAO,CAET"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isPlainDateAfter.test.d.ts","sourceRoot":"","sources":["../src/isPlainDateAfter.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Temporal } from '@js-temporal/polyfill';
|
|
2
|
+
/**
|
|
3
|
+
* Returns true if the first plain date is before the second plain date.
|
|
4
|
+
* Compares calendar dates without time or timezone considerations.
|
|
5
|
+
*
|
|
6
|
+
* @param date1 - First plain date
|
|
7
|
+
* @param date2 - Second plain date
|
|
8
|
+
* @returns true if date1 is before date2, false otherwise
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* const jan20 = Temporal.PlainDate.from('2025-01-20');
|
|
13
|
+
* const jan25 = Temporal.PlainDate.from('2025-01-25');
|
|
14
|
+
*
|
|
15
|
+
* isPlainDateBefore(jan20, jan25); // true
|
|
16
|
+
* isPlainDateBefore(jan25, jan20); // false
|
|
17
|
+
* isPlainDateBefore(jan20, jan20); // false
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export declare function isPlainDateBefore(date1: Temporal.PlainDate, date2: Temporal.PlainDate): boolean;
|
|
21
|
+
//# sourceMappingURL=isPlainDateBefore.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isPlainDateBefore.d.ts","sourceRoot":"","sources":["../src/isPlainDateBefore.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAEjD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,QAAQ,CAAC,SAAS,EACzB,KAAK,EAAE,QAAQ,CAAC,SAAS,GACxB,OAAO,CAET"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isPlainDateBefore.test.d.ts","sourceRoot":"","sources":["../src/isPlainDateBefore.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Temporal } from '@js-temporal/polyfill';
|
|
2
|
+
/**
|
|
3
|
+
* Returns true if the two plain dates are equal.
|
|
4
|
+
* Compares calendar dates without time or timezone considerations.
|
|
5
|
+
*
|
|
6
|
+
* @param date1 - First plain date
|
|
7
|
+
* @param date2 - Second plain date
|
|
8
|
+
* @returns true if date1 equals date2, false otherwise
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* const jan20a = Temporal.PlainDate.from('2025-01-20');
|
|
13
|
+
* const jan20b = Temporal.PlainDate.from('2025-01-20');
|
|
14
|
+
* const jan25 = Temporal.PlainDate.from('2025-01-25');
|
|
15
|
+
*
|
|
16
|
+
* isPlainDateEqual(jan20a, jan20b); // true
|
|
17
|
+
* isPlainDateEqual(jan20a, jan25); // false
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export declare function isPlainDateEqual(date1: Temporal.PlainDate, date2: Temporal.PlainDate): boolean;
|
|
21
|
+
//# sourceMappingURL=isPlainDateEqual.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isPlainDateEqual.d.ts","sourceRoot":"","sources":["../src/isPlainDateEqual.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAEjD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,QAAQ,CAAC,SAAS,EACzB,KAAK,EAAE,QAAQ,CAAC,SAAS,GACxB,OAAO,CAET"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isPlainDateEqual.test.d.ts","sourceRoot":"","sources":["../src/isPlainDateEqual.test.ts"],"names":[],"mappings":""}
|
package/package.json
CHANGED