@powerlines/plugin-date 0.12.299 → 0.12.301

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.
Files changed (76) hide show
  1. package/dist/_virtual/rolldown_runtime.cjs +29 -0
  2. package/dist/components/date-fns.cjs +528 -0
  3. package/dist/components/date-fns.d.cts +14 -0
  4. package/dist/components/date-fns.d.cts.map +1 -0
  5. package/dist/components/date-fns.d.mts +14 -0
  6. package/dist/components/date-fns.d.mts.map +1 -0
  7. package/dist/components/date-fns.mjs +528 -0
  8. package/dist/components/date-fns.mjs.map +1 -0
  9. package/dist/components/dayjs.cjs +473 -0
  10. package/dist/components/dayjs.d.cts +14 -0
  11. package/dist/components/dayjs.d.cts.map +1 -0
  12. package/dist/components/dayjs.d.mts +14 -0
  13. package/dist/components/dayjs.d.mts.map +1 -0
  14. package/dist/components/dayjs.mjs +473 -0
  15. package/dist/components/dayjs.mjs.map +1 -0
  16. package/dist/components/index.cjs +4 -0
  17. package/dist/components/index.d.cts +4 -0
  18. package/dist/components/index.d.mts +4 -0
  19. package/dist/components/index.mjs +6 -0
  20. package/dist/components/luxon.cjs +477 -0
  21. package/dist/components/luxon.d.cts +14 -0
  22. package/dist/components/luxon.d.cts.map +1 -0
  23. package/dist/components/luxon.d.mts +14 -0
  24. package/dist/components/luxon.d.mts.map +1 -0
  25. package/dist/components/luxon.mjs +477 -0
  26. package/dist/components/luxon.mjs.map +1 -0
  27. package/dist/components/moment.cjs +463 -0
  28. package/dist/components/moment.d.cts +14 -0
  29. package/dist/components/moment.d.cts.map +1 -0
  30. package/dist/components/moment.d.mts +14 -0
  31. package/dist/components/moment.d.mts.map +1 -0
  32. package/dist/components/moment.mjs +463 -0
  33. package/dist/components/moment.mjs.map +1 -0
  34. package/dist/index.cjs +17 -2007
  35. package/dist/index.d.cts +8 -40
  36. package/dist/index.d.cts.map +1 -1
  37. package/dist/index.d.mts +8 -40
  38. package/dist/index.d.mts.map +1 -1
  39. package/dist/index.mjs +6 -1970
  40. package/dist/index.mjs.map +1 -1
  41. package/dist/node_modules/.pnpm/defu@6.1.4/node_modules/defu/dist/defu.cjs +43 -0
  42. package/dist/node_modules/.pnpm/defu@6.1.4/node_modules/defu/dist/defu.mjs +43 -0
  43. package/dist/node_modules/.pnpm/defu@6.1.4/node_modules/defu/dist/defu.mjs.map +1 -0
  44. package/dist/types/index.cjs +0 -3
  45. package/dist/types/index.d.cts +2 -3
  46. package/dist/types/index.d.mts +2 -3
  47. package/dist/types/index.mjs +0 -4
  48. package/dist/types/plugin.cjs +0 -1
  49. package/dist/types/plugin.d.cts +44 -2
  50. package/dist/types/plugin.d.cts.map +1 -0
  51. package/dist/types/plugin.d.mts +44 -2
  52. package/dist/types/plugin.d.mts.map +1 -0
  53. package/dist/types/plugin.mjs +0 -2
  54. package/dist/types/runtime.cjs +0 -1
  55. package/dist/types/runtime.d.cts +712 -2
  56. package/dist/types/runtime.d.cts.map +1 -0
  57. package/dist/types/runtime.d.mts +712 -2
  58. package/dist/types/runtime.d.mts.map +1 -0
  59. package/dist/types/runtime.mjs +0 -2
  60. package/package.json +5 -5
  61. package/dist/index-CA4VvAY_.d.mts +0 -1
  62. package/dist/index-CmCelmEL.d.cts +0 -1
  63. package/dist/plugin-CWe-29nA.d.mts +0 -44
  64. package/dist/plugin-CWe-29nA.d.mts.map +0 -1
  65. package/dist/plugin-D82ijYIk.d.cts +0 -44
  66. package/dist/plugin-D82ijYIk.d.cts.map +0 -1
  67. package/dist/plugin-DHXHjv16.cjs +0 -0
  68. package/dist/plugin-ufqFO5xS.mjs +0 -1
  69. package/dist/runtime-B7WoCmC4.mjs +0 -1
  70. package/dist/runtime-B8LVkjWB.d.cts +0 -712
  71. package/dist/runtime-B8LVkjWB.d.cts.map +0 -1
  72. package/dist/runtime-CiYq8JJ6.d.mts +0 -712
  73. package/dist/runtime-CiYq8JJ6.d.mts.map +0 -1
  74. package/dist/runtime-D4zTdSwv.cjs +0 -0
  75. package/dist/types-BReKsBV6.mjs +0 -1
  76. package/dist/types-CBTc19th.cjs +0 -0
@@ -0,0 +1,473 @@
1
+ import { getFileHeader } from "powerlines/lib/utilities/file-header";
2
+
3
+ //#region src/components/dayjs.ts
4
+ /**
5
+ * Generates the Powerlines configuration file.
6
+ *
7
+ * @param context - The build context containing runtime information.
8
+ * @returns A string representing the configuration file content.
9
+ */
10
+ function dayjsModule(context) {
11
+ return `
12
+ /**
13
+ * The Date module provides utility functions for date manipulation and formatting
14
+ *
15
+ * @module ${context.config.framework}:date
16
+ */
17
+
18
+ ${getFileHeader(context)}
19
+
20
+ import defaultDayjs, { QUnitType } from "dayjs";
21
+ import customParseFormatPlugin from "dayjs/plugin/customParseFormat";
22
+ import localizedFormatPlugin from "dayjs/plugin/localizedFormat";
23
+ import isBetweenPlugin from "dayjs/plugin/isBetween";
24
+ import weekOfYear from "dayjs/plugin/weekOfYear";
25
+ import {
26
+ StormDateInterface,
27
+ DateFormats,
28
+ TimeUnit
29
+ } from "@powerlines/plugin-date/types/runtime";
30
+
31
+ defaultDayjs.extend(customParseFormatPlugin);
32
+ defaultDayjs.extend(localizedFormatPlugin);
33
+ defaultDayjs.extend(isBetweenPlugin);
34
+ defaultDayjs.extend(weekOfYear);
35
+
36
+ interface Opts {
37
+ locale?: string;
38
+ /** Make sure that your dayjs instance extends customParseFormat and advancedFormat */
39
+ instance?: typeof defaultDayjs;
40
+ formats?: Partial<DateFormats>;
41
+ }
42
+
43
+ type Dayjs = defaultDayjs.Dayjs;
44
+ type Constructor<TDate extends Dayjs> = (
45
+ ...args: Parameters<typeof defaultDayjs>
46
+ ) => TDate;
47
+ const withLocale = <TDate extends Dayjs>(
48
+ dayjs: any,
49
+ locale?: string
50
+ ): Constructor<TDate> => (!locale ? dayjs : (...args) => dayjs(...args).locale(locale));
51
+
52
+ export const formats: DateFormats = {
53
+ normalDateWithWeekday: "ddd, MMM D",
54
+ normalDate: "D MMMM",
55
+ shortDate: "MMM D",
56
+ monthAndDate: "MMMM D",
57
+ dayOfMonth: "D",
58
+ year: "YYYY",
59
+ month: "MMMM",
60
+ monthShort: "MMM",
61
+ monthAndYear: "MMMM YYYY",
62
+ weekday: "dddd",
63
+ weekdayShort: "ddd",
64
+ minutes: "mm",
65
+ hours12h: "hh",
66
+ hours24h: "HH",
67
+ seconds: "ss",
68
+ fullTime: "LT",
69
+ fullTime12h: "hh:mm A",
70
+ fullTime24h: "HH:mm",
71
+ fullDate: "ll",
72
+ fullDateWithWeekday: "dddd, LL",
73
+ fullDateTime: "lll",
74
+ fullDateTime12h: "ll hh:mm A",
75
+ fullDateTime24h: "ll HH:mm",
76
+ keyboardDate: "L",
77
+ keyboardDateTime: "L LT",
78
+ keyboardDateTime12h: "L hh:mm A",
79
+ keyboardDateTime24h: "L HH:mm",
80
+ systemDateTime: "L HH:mm:ss.SSS",
81
+ filePathDateTime: "L_HH-mm-ss-SSS"
82
+ };
83
+
84
+ export let locale = "${context.env.parsed.DEFAULT_LOCALE || context.workspaceConfig.locale ? `${context.env.parsed.DEFAULT_LOCALE || context.workspaceConfig.locale}` : "en-US"}";
85
+
86
+ export const dayjs = withLocale(defaultDayjs, locale);
87
+
88
+ export const type = "dayjs";
89
+
90
+ /**
91
+ * Creates a date object using the provided value.
92
+ *
93
+ * @remarks
94
+ * This function creates a date object using the provided value. If the value is \`null\`, it returns \`null\`. If the value is \`undefined\`, it returns the current date. If the value is a string, it parses the string as a date. If the value is a number, it treats it as a timestamp. If the value is a date object, it returns the date object.
95
+ *
96
+ * @example
97
+ * \`\`\`ts
98
+ * import { createDate } from "storm:date";
99
+ *
100
+ * const date = createDate("2023-10-01");
101
+ * console.log(date.format("YYYY-MM-DD")); // Outputs: 2023-10-01
102
+ * \`\`\`
103
+ *
104
+ * @param value - The value to create the date object from.
105
+ * @returns A date object or \`null\` if the value is \`null\`.
106
+ */
107
+ export function createDate<
108
+ TArg extends unknown = undefined,
109
+ TResultingDate extends unknown = TArg extends null
110
+ ? null
111
+ : TArg extends undefined
112
+ ? TDate
113
+ : TDate | null
114
+ >(value?: TArg): TResultingDate {
115
+ if (value === null) {
116
+ return null as TResultingDate;
117
+ }
118
+
119
+ return dayjs(value as any) as unknown as TResultingDate;
120
+ }
121
+
122
+ export function is12HourCycleInCurrentLocale() {
123
+ /* istanbul ignore next */
124
+ return /A|a/.test(dayjs.Ls[dayjs.locale() || $storm.env.DEFAULT_LOCALE]?.formats?.LT ?? "");
125
+ };
126
+
127
+ export function getCurrentLocaleCode() {
128
+ return dayjs.locale() || $storm.env.DEFAULT_LOCALE;
129
+ };
130
+
131
+ export function getFormatHelperText(format: string) {
132
+ // @see https://github.com/iamkun/dayjs/blob/dev/src/plugin/localizedFormat/index.js
133
+ const localFormattingTokens = /(\[[^\[]*\])|(\\)?(LTS|LT|LL?L?L?)|./g;
134
+
135
+ return (
136
+ format
137
+ .match(localFormattingTokens)
138
+ ?.map((token) => {
139
+ const firstCharacter = token[0];
140
+ if (firstCharacter === "L") {
141
+ /* istanbul ignore next */
142
+ return (
143
+ dayjs.Ls[dayjs.locale() || $storm.env.DEFAULT_LOCALE]?.formats[
144
+ token as keyof ILocale["formats"]
145
+ ] ?? token
146
+ );
147
+ }
148
+ return token;
149
+ })
150
+ .join("")
151
+ .replace(/a/gi, "(a|p)m")
152
+ .toLocaleLowerCase() ?? format
153
+ );
154
+ };
155
+
156
+ export function parseISO(isoString: string) {
157
+ return dayjs(isoString);
158
+ };
159
+
160
+ export function toISO(value: Dayjs) {
161
+ return value.toISOString();
162
+ };
163
+
164
+ export function parse(value: any, format: string) {
165
+ if (value === "") {
166
+ return null;
167
+ }
168
+
169
+ return dayjs(value, format, dayjs.locale(), true);
170
+ };
171
+
172
+ export function toJsDate(value: Dayjs) {
173
+ return value.toDate();
174
+ };
175
+
176
+ export function isValid(value: any) {
177
+ return dayjs(value).isValid();
178
+ };
179
+
180
+ export function isNull(date: Dayjs | null) {
181
+ return date === null;
182
+ };
183
+
184
+ export function getDiff(date: Dayjs, comparing: Dayjs | string, units?: Unit) {
185
+ if (typeof comparing === "string") {
186
+ comparing = dayjs(comparing);
187
+ }
188
+
189
+ if (!comparing.isValid()) {
190
+ return 0;
191
+ }
192
+
193
+ return date.diff(comparing, units as QUnitType);
194
+ };
195
+
196
+ export function isAfter(date: Dayjs, value: Dayjs) {
197
+ return date.isAfter(value);
198
+ };
199
+
200
+ export function isBefore(date: Dayjs, value: Dayjs) {
201
+ return date.isBefore(value);
202
+ };
203
+
204
+ export function isAfterDay(date: Dayjs, value: Dayjs) {
205
+ return date.isAfter(value, "day");
206
+ };
207
+
208
+ export function isBeforeDay(date: Dayjs, value: Dayjs) {
209
+ return date.isBefore(value, "day");
210
+ };
211
+
212
+ export function isAfterMonth(date: Dayjs, value: Dayjs) {
213
+ return date.isAfter(value, "month");
214
+ };
215
+
216
+ export function isBeforeMonth(date: Dayjs, value: Dayjs) {
217
+ return date.isBefore(value, "month");
218
+ };
219
+
220
+ export function isBeforeYear(date: Dayjs, value: Dayjs) {
221
+ return date.isBefore(value, "year");
222
+ };
223
+
224
+ export function isAfterYear(date: Dayjs, value: Dayjs) {
225
+ return date.isAfter(value, "year");
226
+ };
227
+
228
+ export function startOfDay(date: Dayjs) {
229
+ return date.startOf("day");
230
+ };
231
+
232
+ export function endOfDay(date: Dayjs) {
233
+ return date.endOf("day");
234
+ };
235
+
236
+ export function format(date: Dayjs, formatKey: keyof DateFormats) {
237
+ return formatByString(date, formats[formatKey]);
238
+ };
239
+
240
+ export function formatByString(date: Dayjs, formatString: string) {
241
+ return dayjs(date).format(formatString);
242
+ };
243
+
244
+ export function formatNumber(numberToFormat: string) {
245
+ return numberToFormat;
246
+ };
247
+
248
+ export function getHours(date: Dayjs) {
249
+ return date.hour();
250
+ };
251
+
252
+ export function addSeconds(date: Dayjs, count: number) {
253
+ return count < 0
254
+ ? (date.subtract(Math.abs(count), "second") as Dayjs)
255
+ : (date.add(count, "second") as Dayjs);
256
+ };
257
+
258
+ export function addMinutes(date: Dayjs, count: number) {
259
+ return count < 0
260
+ ? (date.subtract(Math.abs(count), "minute") as Dayjs)
261
+ : (date.add(count, "minute") as Dayjs);
262
+ };
263
+
264
+ export function addHours(date: Dayjs, count: number) {
265
+ return count < 0
266
+ ? (date.subtract(Math.abs(count), "hour") as Dayjs)
267
+ : (date.add(count, "hour") as Dayjs);
268
+ };
269
+
270
+ export function addDays(date: Dayjs, count: number) {
271
+ return count < 0
272
+ ? (date.subtract(Math.abs(count), "day") as Dayjs)
273
+ : (date.add(count, "day") as Dayjs);
274
+ };
275
+
276
+ export function addWeeks(date: Dayjs, count: number) {
277
+ return count < 0
278
+ ? (date.subtract(Math.abs(count), "week") as Dayjs)
279
+ : (date.add(count, "week") as Dayjs);
280
+ };
281
+
282
+ export function addMonths(date: Dayjs, count: number) {
283
+ return count < 0
284
+ ? (date.subtract(Math.abs(count), "month") as Dayjs)
285
+ : (date.add(count, "month") as Dayjs);
286
+ };
287
+
288
+ export function addYears(date: Dayjs, count: number) {
289
+ return count < 0
290
+ ? (date.subtract(Math.abs(count), "year") as Dayjs)
291
+ : (date.add(count, "year") as Dayjs);
292
+ };
293
+
294
+ export function setMonth(date: Dayjs, count: number) {
295
+ return date.set("month", count) as Dayjs;
296
+ };
297
+
298
+ export function setHours(date: Dayjs, count: number) {
299
+ return date.set("hour", count) as Dayjs;
300
+ };
301
+
302
+ export function getMinutes(date: Dayjs) {
303
+ return date.minute();
304
+ };
305
+
306
+ export function setMinutes(date: Dayjs, count: number) {
307
+ return date.set("minute", count) as Dayjs;
308
+ };
309
+
310
+ export function getSeconds(date: Dayjs) {
311
+ return date.second();
312
+ };
313
+
314
+ export function setSeconds(date: Dayjs, count: number) {
315
+ return date.set("second", count) as Dayjs;
316
+ };
317
+
318
+ export function getWeek(date: Dayjs) {
319
+ return date.week();
320
+ };
321
+
322
+ export function getMonth(date: Dayjs) {
323
+ return date.month();
324
+ };
325
+
326
+ export function getDate(date: Dayjs) {
327
+ return date.date();
328
+ };
329
+
330
+ export function setDate(date: Dayjs, count: number) {
331
+ return date.set("date", count) as Dayjs;
332
+ };
333
+
334
+ export function getDaysInMonth(date: Dayjs) {
335
+ return date.daysInMonth();
336
+ };
337
+
338
+ export function isSameDay(date: Dayjs, comparing: Dayjs) {
339
+ return date.isSame(comparing, "day");
340
+ };
341
+
342
+ export function isSameMonth(date: Dayjs, comparing: Dayjs) {
343
+ return date.isSame(comparing, "month");
344
+ };
345
+
346
+ export function isSameYear(date: Dayjs, comparing: Dayjs) {
347
+ return date.isSame(comparing, "year");
348
+ };
349
+
350
+ export function isSameHour(date: Dayjs, comparing: Dayjs) {
351
+ return date.isSame(comparing, "hour");
352
+ };
353
+
354
+ export function getMeridiemText(meridiem: "am" | "pm") {
355
+ return meridiem === "am" ? "AM" : "PM";
356
+ };
357
+
358
+ export function startOfYear(date: Dayjs) {
359
+ return date.startOf("year") as Dayjs;
360
+ };
361
+
362
+ export function endOfYear(date: Dayjs) {
363
+ return date.endOf("year") as Dayjs;
364
+ };
365
+
366
+ export function startOfMonth(date: Dayjs) {
367
+ return date.startOf("month") as Dayjs;
368
+ };
369
+
370
+ export function endOfMonth(date: Dayjs) {
371
+ return date.endOf("month") as Dayjs;
372
+ };
373
+
374
+ export function startOfWeek(date: Dayjs) {
375
+ return date.startOf("week") as Dayjs;
376
+ };
377
+
378
+ export function endOfWeek(date: Dayjs) {
379
+ return date.endOf("week") as Dayjs;
380
+ };
381
+
382
+ export function getNextMonth(date: Dayjs) {
383
+ return date.add(1, "month") as Dayjs;
384
+ };
385
+
386
+ export function getPreviousMonth(date: Dayjs) {
387
+ return date.subtract(1, "month") as Dayjs;
388
+ };
389
+
390
+ export function getMonthArray(date: Dayjs) {
391
+ const firstMonth = date.startOf("year") as Dayjs;
392
+ const monthArray = [firstMonth];
393
+
394
+ while (monthArray.length < 12) {
395
+ const prevMonth = monthArray[monthArray.length - 1];
396
+ monthArray.push(getNextMonth(prevMonth));
397
+ }
398
+
399
+ return monthArray;
400
+ };
401
+
402
+ export function getYear(date: Dayjs) {
403
+ return date.year();
404
+ };
405
+
406
+ export function setYear(date: Dayjs, year: number) {
407
+ return date.set("year", year) as Dayjs;
408
+ };
409
+
410
+ export function mergeDateAndTime(date: Dayjs, time: Dayjs) {
411
+ return date.hour(time.hour()).minute(time.minute()).second(time.second()) as Dayjs;
412
+ };
413
+
414
+ export function getWeekdays() {
415
+ const start = dayjs().startOf("week");
416
+ return [0, 1, 2, 3, 4, 5, 6].map((diff) =>
417
+ formatByString(start.add(diff, "day"), "dd")
418
+ );
419
+ };
420
+
421
+ export function isEqual(value: any, comparing: any) {
422
+ if (value === null && comparing === null) {
423
+ return true;
424
+ }
425
+
426
+ return dayjs(value).isSame(comparing);
427
+ };
428
+
429
+ export function getWeekArray(date: Dayjs) {
430
+ const start = dayjs(date).startOf("month").startOf("week") as Dayjs;
431
+ const end = dayjs(date).endOf("month").endOf("week") as Dayjs;
432
+
433
+ let count = 0;
434
+ let current = start;
435
+ const nestedWeeks: Dayjs[][] = [];
436
+
437
+ while (current.isBefore(end)) {
438
+ const weekNumber = Math.floor(count / 7);
439
+ nestedWeeks[weekNumber] = nestedWeeks[weekNumber] || [];
440
+ nestedWeeks[weekNumber].push(current);
441
+
442
+ current = current.add(1, "day") as TDate;
443
+ count += 1;
444
+ }
445
+
446
+ return nestedWeeks;
447
+ };
448
+
449
+ export function getYearRange(start: Dayjs, end: Dayjs) {
450
+ const startDate = start.startOf("year");
451
+ const endDate = end.endOf("year");
452
+ const years: Dayjs[] = [];
453
+
454
+ let current = startDate;
455
+ while (current.isBefore(endDate)) {
456
+ years.push(current);
457
+ current = current.add(1, "year");
458
+ }
459
+
460
+ return years;
461
+ };
462
+
463
+ export function isWithinRange(date: Dayjs, [start, end]: [Dayjs, Dayjs]) {
464
+ return date.isBetween(start, end, null, "[]");
465
+ };
466
+
467
+
468
+ `;
469
+ }
470
+
471
+ //#endregion
472
+ export { dayjsModule };
473
+ //# sourceMappingURL=dayjs.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dayjs.mjs","names":[],"sources":["../../src/components/dayjs.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { getFileHeader } from \"powerlines/lib/utilities/file-header\";\nimport { DatePluginContext } from \"../types/plugin\";\n\n/**\n * Generates the Powerlines configuration file.\n *\n * @param context - The build context containing runtime information.\n * @returns A string representing the configuration file content.\n */\nexport function dayjsModule(context: DatePluginContext) {\n return `\n/**\n * The Date module provides utility functions for date manipulation and formatting\n *\n * @module ${context.config.framework}:date\n */\n\n${getFileHeader(context)}\n\nimport defaultDayjs, { QUnitType } from \"dayjs\";\nimport customParseFormatPlugin from \"dayjs/plugin/customParseFormat\";\nimport localizedFormatPlugin from \"dayjs/plugin/localizedFormat\";\nimport isBetweenPlugin from \"dayjs/plugin/isBetween\";\nimport weekOfYear from \"dayjs/plugin/weekOfYear\";\nimport {\n StormDateInterface,\n DateFormats,\n TimeUnit\n} from \"@powerlines/plugin-date/types/runtime\";\n\ndefaultDayjs.extend(customParseFormatPlugin);\ndefaultDayjs.extend(localizedFormatPlugin);\ndefaultDayjs.extend(isBetweenPlugin);\ndefaultDayjs.extend(weekOfYear);\n\ninterface Opts {\n locale?: string;\n /** Make sure that your dayjs instance extends customParseFormat and advancedFormat */\n instance?: typeof defaultDayjs;\n formats?: Partial<DateFormats>;\n}\n\ntype Dayjs = defaultDayjs.Dayjs;\ntype Constructor<TDate extends Dayjs> = (\n ...args: Parameters<typeof defaultDayjs>\n) => TDate;\nconst withLocale = <TDate extends Dayjs>(\n dayjs: any,\n locale?: string\n): Constructor<TDate> => (!locale ? dayjs : (...args) => dayjs(...args).locale(locale));\n\nexport const formats: DateFormats = {\n normalDateWithWeekday: \"ddd, MMM D\",\n normalDate: \"D MMMM\",\n shortDate: \"MMM D\",\n monthAndDate: \"MMMM D\",\n dayOfMonth: \"D\",\n year: \"YYYY\",\n month: \"MMMM\",\n monthShort: \"MMM\",\n monthAndYear: \"MMMM YYYY\",\n weekday: \"dddd\",\n weekdayShort: \"ddd\",\n minutes: \"mm\",\n hours12h: \"hh\",\n hours24h: \"HH\",\n seconds: \"ss\",\n fullTime: \"LT\",\n fullTime12h: \"hh:mm A\",\n fullTime24h: \"HH:mm\",\n fullDate: \"ll\",\n fullDateWithWeekday: \"dddd, LL\",\n fullDateTime: \"lll\",\n fullDateTime12h: \"ll hh:mm A\",\n fullDateTime24h: \"ll HH:mm\",\n keyboardDate: \"L\",\n keyboardDateTime: \"L LT\",\n keyboardDateTime12h: \"L hh:mm A\",\n keyboardDateTime24h: \"L HH:mm\",\n systemDateTime: \"L HH:mm:ss.SSS\",\n filePathDateTime: \"L_HH-mm-ss-SSS\"\n};\n\nexport let locale = \"${\n context.env.parsed.DEFAULT_LOCALE || context.workspaceConfig.locale\n ? `${context.env.parsed.DEFAULT_LOCALE || context.workspaceConfig.locale}`\n : \"en-US\"\n }\";\n\nexport const dayjs = withLocale(defaultDayjs, locale);\n\nexport const type = \"dayjs\";\n\n/**\n * Creates a date object using the provided value.\n *\n * @remarks\n * This function creates a date object using the provided value. If the value is \\`null\\`, it returns \\`null\\`. If the value is \\`undefined\\`, it returns the current date. If the value is a string, it parses the string as a date. If the value is a number, it treats it as a timestamp. If the value is a date object, it returns the date object.\n *\n * @example\n * \\`\\`\\`ts\n * import { createDate } from \"storm:date\";\n *\n * const date = createDate(\"2023-10-01\");\n * console.log(date.format(\"YYYY-MM-DD\")); // Outputs: 2023-10-01\n * \\`\\`\\`\n *\n * @param value - The value to create the date object from.\n * @returns A date object or \\`null\\` if the value is \\`null\\`.\n */\nexport function createDate<\n TArg extends unknown = undefined,\n TResultingDate extends unknown = TArg extends null\n ? null\n : TArg extends undefined\n ? TDate\n : TDate | null\n>(value?: TArg): TResultingDate {\n if (value === null) {\n return null as TResultingDate;\n }\n\n return dayjs(value as any) as unknown as TResultingDate;\n}\n\nexport function is12HourCycleInCurrentLocale() {\n /* istanbul ignore next */\n return /A|a/.test(dayjs.Ls[dayjs.locale() || $storm.env.DEFAULT_LOCALE]?.formats?.LT ?? \"\");\n};\n\nexport function getCurrentLocaleCode() {\n return dayjs.locale() || $storm.env.DEFAULT_LOCALE;\n};\n\nexport function getFormatHelperText(format: string) {\n // @see https://github.com/iamkun/dayjs/blob/dev/src/plugin/localizedFormat/index.js\n const localFormattingTokens = /(\\[[^\\[]*\\])|(\\\\)?(LTS|LT|LL?L?L?)|./g;\n\n return (\n format\n .match(localFormattingTokens)\n ?.map((token) => {\n const firstCharacter = token[0];\n if (firstCharacter === \"L\") {\n /* istanbul ignore next */\n return (\n dayjs.Ls[dayjs.locale() || $storm.env.DEFAULT_LOCALE]?.formats[\n token as keyof ILocale[\"formats\"]\n ] ?? token\n );\n }\n return token;\n })\n .join(\"\")\n .replace(/a/gi, \"(a|p)m\")\n .toLocaleLowerCase() ?? format\n );\n};\n\nexport function parseISO(isoString: string) {\n return dayjs(isoString);\n};\n\nexport function toISO(value: Dayjs) {\n return value.toISOString();\n};\n\nexport function parse(value: any, format: string) {\n if (value === \"\") {\n return null;\n }\n\n return dayjs(value, format, dayjs.locale(), true);\n};\n\nexport function toJsDate(value: Dayjs) {\n return value.toDate();\n};\n\nexport function isValid(value: any) {\n return dayjs(value).isValid();\n};\n\nexport function isNull(date: Dayjs | null) {\n return date === null;\n};\n\nexport function getDiff(date: Dayjs, comparing: Dayjs | string, units?: Unit) {\n if (typeof comparing === \"string\") {\n comparing = dayjs(comparing);\n }\n\n if (!comparing.isValid()) {\n return 0;\n }\n\n return date.diff(comparing, units as QUnitType);\n};\n\nexport function isAfter(date: Dayjs, value: Dayjs) {\n return date.isAfter(value);\n};\n\nexport function isBefore(date: Dayjs, value: Dayjs) {\n return date.isBefore(value);\n};\n\nexport function isAfterDay(date: Dayjs, value: Dayjs) {\n return date.isAfter(value, \"day\");\n};\n\nexport function isBeforeDay(date: Dayjs, value: Dayjs) {\n return date.isBefore(value, \"day\");\n};\n\nexport function isAfterMonth(date: Dayjs, value: Dayjs) {\n return date.isAfter(value, \"month\");\n};\n\nexport function isBeforeMonth(date: Dayjs, value: Dayjs) {\n return date.isBefore(value, \"month\");\n};\n\nexport function isBeforeYear(date: Dayjs, value: Dayjs) {\n return date.isBefore(value, \"year\");\n};\n\nexport function isAfterYear(date: Dayjs, value: Dayjs) {\n return date.isAfter(value, \"year\");\n};\n\nexport function startOfDay(date: Dayjs) {\n return date.startOf(\"day\");\n};\n\nexport function endOfDay(date: Dayjs) {\n return date.endOf(\"day\");\n};\n\nexport function format(date: Dayjs, formatKey: keyof DateFormats) {\n return formatByString(date, formats[formatKey]);\n};\n\nexport function formatByString(date: Dayjs, formatString: string) {\n return dayjs(date).format(formatString);\n};\n\nexport function formatNumber(numberToFormat: string) {\n return numberToFormat;\n};\n\nexport function getHours(date: Dayjs) {\n return date.hour();\n};\n\nexport function addSeconds(date: Dayjs, count: number) {\n return count < 0\n ? (date.subtract(Math.abs(count), \"second\") as Dayjs)\n : (date.add(count, \"second\") as Dayjs);\n};\n\nexport function addMinutes(date: Dayjs, count: number) {\n return count < 0\n ? (date.subtract(Math.abs(count), \"minute\") as Dayjs)\n : (date.add(count, \"minute\") as Dayjs);\n};\n\nexport function addHours(date: Dayjs, count: number) {\n return count < 0\n ? (date.subtract(Math.abs(count), \"hour\") as Dayjs)\n : (date.add(count, \"hour\") as Dayjs);\n};\n\nexport function addDays(date: Dayjs, count: number) {\n return count < 0\n ? (date.subtract(Math.abs(count), \"day\") as Dayjs)\n : (date.add(count, \"day\") as Dayjs);\n};\n\nexport function addWeeks(date: Dayjs, count: number) {\n return count < 0\n ? (date.subtract(Math.abs(count), \"week\") as Dayjs)\n : (date.add(count, \"week\") as Dayjs);\n};\n\nexport function addMonths(date: Dayjs, count: number) {\n return count < 0\n ? (date.subtract(Math.abs(count), \"month\") as Dayjs)\n : (date.add(count, \"month\") as Dayjs);\n};\n\nexport function addYears(date: Dayjs, count: number) {\n return count < 0\n ? (date.subtract(Math.abs(count), \"year\") as Dayjs)\n : (date.add(count, \"year\") as Dayjs);\n};\n\nexport function setMonth(date: Dayjs, count: number) {\n return date.set(\"month\", count) as Dayjs;\n};\n\nexport function setHours(date: Dayjs, count: number) {\n return date.set(\"hour\", count) as Dayjs;\n};\n\nexport function getMinutes(date: Dayjs) {\n return date.minute();\n};\n\nexport function setMinutes(date: Dayjs, count: number) {\n return date.set(\"minute\", count) as Dayjs;\n};\n\nexport function getSeconds(date: Dayjs) {\n return date.second();\n};\n\nexport function setSeconds(date: Dayjs, count: number) {\n return date.set(\"second\", count) as Dayjs;\n};\n\nexport function getWeek(date: Dayjs) {\n return date.week();\n};\n\nexport function getMonth(date: Dayjs) {\n return date.month();\n};\n\nexport function getDate(date: Dayjs) {\n return date.date();\n};\n\nexport function setDate(date: Dayjs, count: number) {\n return date.set(\"date\", count) as Dayjs;\n};\n\nexport function getDaysInMonth(date: Dayjs) {\n return date.daysInMonth();\n};\n\nexport function isSameDay(date: Dayjs, comparing: Dayjs) {\n return date.isSame(comparing, \"day\");\n};\n\nexport function isSameMonth(date: Dayjs, comparing: Dayjs) {\n return date.isSame(comparing, \"month\");\n};\n\nexport function isSameYear(date: Dayjs, comparing: Dayjs) {\n return date.isSame(comparing, \"year\");\n};\n\nexport function isSameHour(date: Dayjs, comparing: Dayjs) {\n return date.isSame(comparing, \"hour\");\n};\n\nexport function getMeridiemText(meridiem: \"am\" | \"pm\") {\n return meridiem === \"am\" ? \"AM\" : \"PM\";\n};\n\nexport function startOfYear(date: Dayjs) {\n return date.startOf(\"year\") as Dayjs;\n};\n\nexport function endOfYear(date: Dayjs) {\n return date.endOf(\"year\") as Dayjs;\n};\n\nexport function startOfMonth(date: Dayjs) {\n return date.startOf(\"month\") as Dayjs;\n};\n\nexport function endOfMonth(date: Dayjs) {\n return date.endOf(\"month\") as Dayjs;\n};\n\nexport function startOfWeek(date: Dayjs) {\n return date.startOf(\"week\") as Dayjs;\n};\n\nexport function endOfWeek(date: Dayjs) {\n return date.endOf(\"week\") as Dayjs;\n};\n\nexport function getNextMonth(date: Dayjs) {\n return date.add(1, \"month\") as Dayjs;\n};\n\nexport function getPreviousMonth(date: Dayjs) {\n return date.subtract(1, \"month\") as Dayjs;\n};\n\nexport function getMonthArray(date: Dayjs) {\n const firstMonth = date.startOf(\"year\") as Dayjs;\n const monthArray = [firstMonth];\n\n while (monthArray.length < 12) {\n const prevMonth = monthArray[monthArray.length - 1];\n monthArray.push(getNextMonth(prevMonth));\n }\n\n return monthArray;\n};\n\nexport function getYear(date: Dayjs) {\n return date.year();\n};\n\nexport function setYear(date: Dayjs, year: number) {\n return date.set(\"year\", year) as Dayjs;\n};\n\nexport function mergeDateAndTime(date: Dayjs, time: Dayjs) {\n return date.hour(time.hour()).minute(time.minute()).second(time.second()) as Dayjs;\n};\n\nexport function getWeekdays() {\n const start = dayjs().startOf(\"week\");\n return [0, 1, 2, 3, 4, 5, 6].map((diff) =>\n formatByString(start.add(diff, \"day\"), \"dd\")\n );\n};\n\nexport function isEqual(value: any, comparing: any) {\n if (value === null && comparing === null) {\n return true;\n }\n\n return dayjs(value).isSame(comparing);\n};\n\nexport function getWeekArray(date: Dayjs) {\n const start = dayjs(date).startOf(\"month\").startOf(\"week\") as Dayjs;\n const end = dayjs(date).endOf(\"month\").endOf(\"week\") as Dayjs;\n\n let count = 0;\n let current = start;\n const nestedWeeks: Dayjs[][] = [];\n\n while (current.isBefore(end)) {\n const weekNumber = Math.floor(count / 7);\n nestedWeeks[weekNumber] = nestedWeeks[weekNumber] || [];\n nestedWeeks[weekNumber].push(current);\n\n current = current.add(1, \"day\") as TDate;\n count += 1;\n }\n\n return nestedWeeks;\n};\n\nexport function getYearRange(start: Dayjs, end: Dayjs) {\n const startDate = start.startOf(\"year\");\n const endDate = end.endOf(\"year\");\n const years: Dayjs[] = [];\n\n let current = startDate;\n while (current.isBefore(endDate)) {\n years.push(current);\n current = current.add(1, \"year\");\n }\n\n return years;\n};\n\nexport function isWithinRange(date: Dayjs, [start, end]: [Dayjs, Dayjs]) {\n return date.isBetween(start, end, null, \"[]\");\n};\n\n\n`;\n}\n"],"mappings":";;;;;;;;;AA2BA,SAAgB,YAAY,SAA4B;AACtD,QAAO;;;;aAII,QAAQ,OAAO,UAAU;;;EAGpC,cAAc,QAAQ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;uBAmErB,QAAQ,IAAI,OAAO,kBAAkB,QAAQ,gBAAgB,SACzD,GAAG,QAAQ,IAAI,OAAO,kBAAkB,QAAQ,gBAAgB,WAChE,QACL"}
@@ -0,0 +1,4 @@
1
+ const require_date_fns = require('./date-fns.cjs');
2
+ const require_dayjs = require('./dayjs.cjs');
3
+ const require_luxon = require('./luxon.cjs');
4
+ const require_moment = require('./moment.cjs');
@@ -0,0 +1,4 @@
1
+ import { dateFnsModule } from "./date-fns.cjs";
2
+ import { dayjsModule } from "./dayjs.cjs";
3
+ import { luxonModule } from "./luxon.cjs";
4
+ import { momentModule } from "./moment.cjs";
@@ -0,0 +1,4 @@
1
+ import { dateFnsModule } from "./date-fns.mjs";
2
+ import { dayjsModule } from "./dayjs.mjs";
3
+ import { luxonModule } from "./luxon.mjs";
4
+ import { momentModule } from "./moment.mjs";
@@ -0,0 +1,6 @@
1
+ import { dateFnsModule } from "./date-fns.mjs";
2
+ import { dayjsModule } from "./dayjs.mjs";
3
+ import { luxonModule } from "./luxon.mjs";
4
+ import { momentModule } from "./moment.mjs";
5
+
6
+ export { };