@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,463 @@
1
+ import { getFileHeader } from "powerlines/lib/utilities/file-header";
2
+
3
+ //#region src/components/moment.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 momentModule(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 defaultMoment, { LongDateFormatKey } from "moment";
21
+ import {
22
+ StormDateInterface,
23
+ DateFormats,
24
+ TimeUnit
25
+ } from "@powerlines/plugin-date/types/runtime";
26
+
27
+ type Moment = defaultMoment.Moment;
28
+
29
+ export const formats: DateFormats = {
30
+ normalDateWithWeekday: "ddd, MMM D",
31
+ normalDate: "D MMMM",
32
+ shortDate: "MMM D",
33
+ monthAndDate: "MMMM D",
34
+ dayOfMonth: "D",
35
+ year: "YYYY",
36
+ month: "MMMM",
37
+ monthShort: "MMM",
38
+ monthAndYear: "MMMM YYYY",
39
+ weekday: "dddd",
40
+ weekdayShort: "ddd",
41
+ minutes: "mm",
42
+ hours12h: "hh",
43
+ hours24h: "HH",
44
+ seconds: "ss",
45
+ fullTime: "LT",
46
+ fullTime12h: "hh:mm A",
47
+ fullTime24h: "HH:mm",
48
+ fullDate: "ll",
49
+ fullDateWithWeekday: "dddd, LL",
50
+ fullDateTime: "lll",
51
+ fullDateTime12h: "ll hh:mm A",
52
+ fullDateTime24h: "ll HH:mm",
53
+ keyboardDate: "L",
54
+ keyboardDateTime: "L LT",
55
+ keyboardDateTime12h: "L hh:mm A",
56
+ keyboardDateTime24h: "L HH:mm",
57
+ systemDateTime: "L HH:mm:ss.SSS",
58
+ filePathDateTime: "L_HH-mm-ss-SSS"
59
+ };
60
+
61
+ export let locale = "${context.env.parsed.DEFAULT_LOCALE || context.workspaceConfig.locale ? `${context.env.parsed.DEFAULT_LOCALE || context.workspaceConfig.locale}` : "en-US"}";
62
+
63
+ export const type = "moment";
64
+
65
+ const moment = defaultMoment;
66
+
67
+ /**
68
+ * Creates a date object using the provided value.
69
+ *
70
+ * @remarks
71
+ * 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.
72
+ *
73
+ * @example
74
+ * \`\`\`ts
75
+ * import { createDate } from "storm:date";
76
+ *
77
+ * const date = createDate("2023-10-01");
78
+ * console.log(date.format("YYYY-MM-DD")); // Outputs: 2023-10-01
79
+ * \`\`\`
80
+ *
81
+ * @param value - The value to create the date object from.
82
+ * @returns A date object or \`null\` if the value is \`null\`.
83
+ */
84
+ export function createDate<
85
+ TArg extends unknown = undefined,
86
+ TResultingDate extends unknown = TArg extends null
87
+ ? null
88
+ : TArg extends undefined
89
+ ? defaultMoment.Moment
90
+ : defaultMoment.Moment | null
91
+ >(value?: TArg): TResultingDate {
92
+ if (value === null) {
93
+ return null as TResultingDate;
94
+ }
95
+
96
+ const _moment = moment(value);
97
+ if (locale) {
98
+ _moment.locale(locale);
99
+ }
100
+
101
+ return _moment as TResultingDate;
102
+ }
103
+
104
+
105
+ export function is12HourCycleInCurrentLocale(): boolean {
106
+ return /A|a/.test(
107
+ moment.localeData(getCurrentLocaleCode()).longDateFormat("LT")
108
+ );
109
+ };
110
+
111
+ export function getFormatHelperText(format: string) {
112
+ // @see https://github.com/moment/moment/blob/develop/src/lib/format/format.js#L6
113
+ const localFormattingTokens = /(\[[^\[]*\])|(\\)?(LTS|LT|LL?L?L?|l{1,4})|./g;
114
+
115
+ return (
116
+ format
117
+ .match(localFormattingTokens)
118
+ ?.map((token) => {
119
+ const firstCharacter = token[0];
120
+ if (firstCharacter === "L" || firstCharacter === ";") {
121
+ return moment
122
+ .localeData(getCurrentLocaleCode())
123
+ .longDateFormat(token as LongDateFormatKey);
124
+ }
125
+
126
+ return token;
127
+ })
128
+ .join("")
129
+ .replace(/a/gi, "(a|p)m")
130
+ .toLocaleLowerCase() ?? format
131
+ );
132
+ };
133
+
134
+ export function getCurrentLocaleCode() {
135
+ return locale || moment.locale();
136
+ };
137
+
138
+ export function parseISO(isoString: string) {
139
+ return moment(isoString, true);
140
+ };
141
+
142
+ export function toISO(value: Moment) {
143
+ return value.toISOString();
144
+ };
145
+
146
+ export function parse(value: string, format: string) {
147
+ if (value === "") {
148
+ return null;
149
+ }
150
+
151
+ if (locale) {
152
+ return moment(value, format, locale, true);
153
+ }
154
+
155
+ return moment(value, format, true);
156
+ };
157
+
158
+ export function toJsDate(value: Moment) {
159
+ return value.toDate();
160
+ };
161
+
162
+ export function isValid(value: any) {
163
+ return moment(value).isValid();
164
+ };
165
+
166
+ export function isNull(date: Moment) {
167
+ return date === null;
168
+ };
169
+
170
+ export function getDiff(date: Moment, comparing: Moment | string, unit?: TimeUnit) {
171
+ if (!moment(comparing).isValid()) {
172
+ return 0;
173
+ }
174
+
175
+ return date.diff(comparing, unit);
176
+ };
177
+
178
+ export function isAfter(date: Moment, value: Moment) {
179
+ return date.isAfter(value);
180
+ };
181
+
182
+ export function isBefore(date: Moment, value: Moment) {
183
+ return date.isBefore(value);
184
+ };
185
+
186
+ export function isAfterDay(date: Moment, value: Moment) {
187
+ return date.isAfter(value, "day");
188
+ };
189
+
190
+ export function isBeforeDay(date: Moment, value: Moment) {
191
+ return date.isBefore(value, "day");
192
+ };
193
+
194
+ export function isBeforeMonth(date: Moment, value: Moment) {
195
+ return date.isBefore(value, "month");
196
+ };
197
+
198
+ export function isAfterMonth(date: Moment, value: Moment) {
199
+ return date.isAfter(value, "month");
200
+ };
201
+
202
+ export function isBeforeYear(date: Moment, value: Moment) {
203
+ return date.isBefore(value, "year");
204
+ };
205
+
206
+ export function isAfterYear(date: Moment, value: Moment) {
207
+ return date.isAfter(value, "year");
208
+ };
209
+
210
+ export function startOfDay(date: Moment) {
211
+ return date.clone().startOf("day");
212
+ };
213
+
214
+ export function endOfDay(date: Moment) {
215
+ return date.clone().endOf("day");
216
+ };
217
+
218
+ export function format(date: Moment, formatKey: keyof DateFormats) {
219
+ return formatByString(date, formats[formatKey]);
220
+ };
221
+
222
+ export function formatByString(date: Moment, formatString: string) {
223
+ const clonedDate = date.clone();
224
+ if (locale) {
225
+ clonedDate.locale(locale);
226
+ }
227
+ return clonedDate.format(formatString);
228
+ };
229
+
230
+ export function formatNumber(numberToFormat: string) {
231
+ return numberToFormat;
232
+ };
233
+
234
+ export function getHours(date: Moment) {
235
+ return date.get("hours");
236
+ };
237
+
238
+ export function addSeconds(date: Moment, count: number) {
239
+ return count < 0
240
+ ? date.clone().subtract(Math.abs(count), "seconds")
241
+ : date.clone().add(count, "seconds");
242
+ };
243
+
244
+ export function addMinutes(date: Moment, count: number) {
245
+ return count < 0
246
+ ? date.clone().subtract(Math.abs(count), "minutes")
247
+ : date.clone().add(count, "minutes");
248
+ };
249
+
250
+ export function addHours(date: Moment, count: number) {
251
+ return count < 0
252
+ ? date.clone().subtract(Math.abs(count), "hours")
253
+ : date.clone().add(count, "hours");
254
+ };
255
+
256
+ export function addDays(date: Moment, count: number) {
257
+ return count < 0
258
+ ? date.clone().subtract(Math.abs(count), "days")
259
+ : date.clone().add(count, "days");
260
+ };
261
+
262
+ export function addWeeks(date: Moment, count: number) {
263
+ return count < 0
264
+ ? date.clone().subtract(Math.abs(count), "weeks")
265
+ : date.clone().add(count, "weeks");
266
+ };
267
+
268
+ export function addMonths(date: Moment, count: number) {
269
+ return count < 0
270
+ ? date.clone().subtract(Math.abs(count), "months")
271
+ : date.clone().add(count, "months");
272
+ };
273
+
274
+ export function addYears(date: Moment, count: number) {
275
+ return count < 0
276
+ ? date.clone().subtract(Math.abs(count), "years")
277
+ : date.clone().add(count, "years");
278
+ };
279
+
280
+ export function setHours(date: Moment, count: number) {
281
+ return date.clone().hours(count);
282
+ };
283
+
284
+ export function getMinutes(date: Moment) {
285
+ return date.get("minutes");
286
+ };
287
+
288
+ export function setMinutes(date: Moment, count: number) {
289
+ return date.clone().minutes(count);
290
+ };
291
+
292
+ export function getSeconds(date: Moment) {
293
+ return date.get("seconds");
294
+ };
295
+
296
+ export function setSeconds(date: Moment, count: number) {
297
+ return date.clone().seconds(count);
298
+ };
299
+
300
+ export function getWeek(date: Moment) {
301
+ return date.get("week");
302
+ };
303
+
304
+ export function getMonth(date: Moment) {
305
+ return date.get("month");
306
+ };
307
+
308
+ export function getDaysInMonth(date: Moment) {
309
+ return date.daysInMonth();
310
+ };
311
+
312
+ export function isSameDay(date: Moment, comparing: Moment) {
313
+ return date.isSame(comparing, "day");
314
+ };
315
+
316
+ export function isSameMonth(date: Moment, comparing: Moment) {
317
+ return date.isSame(comparing, "month");
318
+ };
319
+
320
+ export function isSameYear(date: Moment, comparing: Moment) {
321
+ return date.isSame(comparing, "year");
322
+ };
323
+
324
+ export function isSameHour(date: Moment, comparing: Moment) {
325
+ return date.isSame(comparing, "hour");
326
+ };
327
+
328
+ export function setMonth(date: Moment, count: number) {
329
+ return date.clone().month(count);
330
+ };
331
+
332
+ export function getMeridiemText(meridiem: "am" | "pm") {
333
+ if (is12HourCycleInCurrentLocale()) {
334
+ // AM/PM translation only possible in those who have 12 hour cycle in locale.
335
+ return moment
336
+ .localeData(getCurrentLocaleCode())
337
+ .meridiem(meridiem === "am" ? 0 : 13, 0, false);
338
+ }
339
+
340
+ return meridiem === "am" ? "AM" : "PM"; // fallback for de, ru, ...etc
341
+ };
342
+
343
+ export function startOfYear(date: Moment) {
344
+ return date.clone().startOf("year");
345
+ };
346
+
347
+ export function endOfYear(date: Moment) {
348
+ return date.clone().endOf("year");
349
+ };
350
+
351
+ export function startOfMonth(date: Moment) {
352
+ return date.clone().startOf("month");
353
+ };
354
+
355
+ export function endOfMonth(date: Moment) {
356
+ return date.clone().endOf("month");
357
+ };
358
+
359
+ export function startOfWeek(date: Moment) {
360
+ return date.clone().startOf("week");
361
+ };
362
+
363
+ export function endOfWeek(date: Moment) {
364
+ return date.clone().endOf("week");
365
+ };
366
+
367
+ export function getNextMonth(date: Moment) {
368
+ return date.clone().add(1, "month");
369
+ };
370
+
371
+ export function getPreviousMonth(date: Moment) {
372
+ return date.clone().subtract(1, "month");
373
+ };
374
+
375
+ export function getMonthArray(date: Moment) {
376
+ const firstMonth = date.clone().startOf("year");
377
+ const monthArray = [firstMonth];
378
+
379
+ while (monthArray.length < 12) {
380
+ const prevMonth = monthArray[monthArray.length - 1];
381
+ monthArray.push(getNextMonth(prevMonth));
382
+ }
383
+
384
+ return monthArray;
385
+ };
386
+
387
+ export function getYear(date: Moment) {
388
+ return date.get("year");
389
+ };
390
+
391
+ export function setYear(date: Moment, year: number) {
392
+ return date.clone().set("year", year);
393
+ };
394
+
395
+ export function getDate(date: Moment) {
396
+ return date.get("date");
397
+ };
398
+
399
+ export function setDate(date: Moment, day: number) {
400
+ return date.clone().set("date", day);
401
+ };
402
+
403
+ export function mergeDateAndTime(date: Moment, time: Moment) {
404
+ return date.hour(time.hour()).minute(time.minute()).second(time.second());
405
+ };
406
+
407
+ export function getWeekdays() {
408
+ return moment.weekdaysShort(true);
409
+ };
410
+
411
+ export function isEqual(value: any, comparing: any) {
412
+ if (value === null && comparing === null) {
413
+ return true;
414
+ }
415
+
416
+ return moment(value).isSame(comparing);
417
+ };
418
+
419
+ export function getWeekArray(date: Moment) {
420
+ const start = date.clone().startOf("month").startOf("week");
421
+ const end = date.clone().endOf("month").endOf("week");
422
+
423
+ let count = 0;
424
+ let current = start;
425
+ const nestedWeeks: Moment[][] = [];
426
+
427
+ while (current.isBefore(end)) {
428
+ const weekNumber = Math.floor(count / 7);
429
+ nestedWeeks[weekNumber] = nestedWeeks[weekNumber] || [];
430
+ nestedWeeks[weekNumber].push(current);
431
+
432
+ current = current.clone().add(1, "day");
433
+ count += 1;
434
+ }
435
+
436
+ return nestedWeeks;
437
+ };
438
+
439
+ export function getYearRange(start: Moment, end: Moment) {
440
+ const startDate = moment(start).startOf("year");
441
+ const endDate = moment(end).endOf("year");
442
+ const years: Moment[] = [];
443
+
444
+ let current = startDate;
445
+ while (current.isBefore(endDate)) {
446
+ years.push(current);
447
+ current = current.clone().add(1, "year");
448
+ }
449
+
450
+ return years;
451
+ };
452
+
453
+ export function isWithinRange(date: Moment, [start, end]: [Moment, Moment]) {
454
+ return date.isBetween(start, end, null, "[]");
455
+ };
456
+
457
+
458
+ `;
459
+ }
460
+
461
+ //#endregion
462
+ export { momentModule };
463
+ //# sourceMappingURL=moment.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"moment.mjs","names":[],"sources":["../../src/components/moment.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 momentModule(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 defaultMoment, { LongDateFormatKey } from \"moment\";\nimport {\n StormDateInterface,\n DateFormats,\n TimeUnit\n} from \"@powerlines/plugin-date/types/runtime\";\n\ntype Moment = defaultMoment.Moment;\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 type = \"moment\";\n\nconst moment = defaultMoment;\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 ? defaultMoment.Moment\n : defaultMoment.Moment | null\n>(value?: TArg): TResultingDate {\n if (value === null) {\n return null as TResultingDate;\n }\n\n const _moment = moment(value);\n if (locale) {\n _moment.locale(locale);\n }\n\n return _moment as TResultingDate;\n}\n\n\nexport function is12HourCycleInCurrentLocale(): boolean {\n return /A|a/.test(\n moment.localeData(getCurrentLocaleCode()).longDateFormat(\"LT\")\n );\n};\n\nexport function getFormatHelperText(format: string) {\n // @see https://github.com/moment/moment/blob/develop/src/lib/format/format.js#L6\n const localFormattingTokens = /(\\[[^\\[]*\\])|(\\\\)?(LTS|LT|LL?L?L?|l{1,4})|./g;\n\n return (\n format\n .match(localFormattingTokens)\n ?.map((token) => {\n const firstCharacter = token[0];\n if (firstCharacter === \"L\" || firstCharacter === \";\") {\n return moment\n .localeData(getCurrentLocaleCode())\n .longDateFormat(token as LongDateFormatKey);\n }\n\n return token;\n })\n .join(\"\")\n .replace(/a/gi, \"(a|p)m\")\n .toLocaleLowerCase() ?? format\n );\n};\n\nexport function getCurrentLocaleCode() {\n return locale || moment.locale();\n};\n\nexport function parseISO(isoString: string) {\n return moment(isoString, true);\n};\n\nexport function toISO(value: Moment) {\n return value.toISOString();\n};\n\nexport function parse(value: string, format: string) {\n if (value === \"\") {\n return null;\n }\n\n if (locale) {\n return moment(value, format, locale, true);\n }\n\n return moment(value, format, true);\n};\n\nexport function toJsDate(value: Moment) {\n return value.toDate();\n};\n\nexport function isValid(value: any) {\n return moment(value).isValid();\n};\n\nexport function isNull(date: Moment) {\n return date === null;\n};\n\nexport function getDiff(date: Moment, comparing: Moment | string, unit?: TimeUnit) {\n if (!moment(comparing).isValid()) {\n return 0;\n }\n\n return date.diff(comparing, unit);\n};\n\nexport function isAfter(date: Moment, value: Moment) {\n return date.isAfter(value);\n};\n\nexport function isBefore(date: Moment, value: Moment) {\n return date.isBefore(value);\n};\n\nexport function isAfterDay(date: Moment, value: Moment) {\n return date.isAfter(value, \"day\");\n};\n\nexport function isBeforeDay(date: Moment, value: Moment) {\n return date.isBefore(value, \"day\");\n};\n\nexport function isBeforeMonth(date: Moment, value: Moment) {\n return date.isBefore(value, \"month\");\n};\n\nexport function isAfterMonth(date: Moment, value: Moment) {\n return date.isAfter(value, \"month\");\n};\n\nexport function isBeforeYear(date: Moment, value: Moment) {\n return date.isBefore(value, \"year\");\n};\n\nexport function isAfterYear(date: Moment, value: Moment) {\n return date.isAfter(value, \"year\");\n};\n\nexport function startOfDay(date: Moment) {\n return date.clone().startOf(\"day\");\n};\n\nexport function endOfDay(date: Moment) {\n return date.clone().endOf(\"day\");\n};\n\nexport function format(date: Moment, formatKey: keyof DateFormats) {\n return formatByString(date, formats[formatKey]);\n};\n\nexport function formatByString(date: Moment, formatString: string) {\n const clonedDate = date.clone();\n if (locale) {\n clonedDate.locale(locale);\n }\n return clonedDate.format(formatString);\n};\n\nexport function formatNumber(numberToFormat: string) {\n return numberToFormat;\n};\n\nexport function getHours(date: Moment) {\n return date.get(\"hours\");\n};\n\nexport function addSeconds(date: Moment, count: number) {\n return count < 0\n ? date.clone().subtract(Math.abs(count), \"seconds\")\n : date.clone().add(count, \"seconds\");\n};\n\nexport function addMinutes(date: Moment, count: number) {\n return count < 0\n ? date.clone().subtract(Math.abs(count), \"minutes\")\n : date.clone().add(count, \"minutes\");\n};\n\nexport function addHours(date: Moment, count: number) {\n return count < 0\n ? date.clone().subtract(Math.abs(count), \"hours\")\n : date.clone().add(count, \"hours\");\n};\n\nexport function addDays(date: Moment, count: number) {\n return count < 0\n ? date.clone().subtract(Math.abs(count), \"days\")\n : date.clone().add(count, \"days\");\n};\n\nexport function addWeeks(date: Moment, count: number) {\n return count < 0\n ? date.clone().subtract(Math.abs(count), \"weeks\")\n : date.clone().add(count, \"weeks\");\n};\n\nexport function addMonths(date: Moment, count: number) {\n return count < 0\n ? date.clone().subtract(Math.abs(count), \"months\")\n : date.clone().add(count, \"months\");\n};\n\nexport function addYears(date: Moment, count: number) {\n return count < 0\n ? date.clone().subtract(Math.abs(count), \"years\")\n : date.clone().add(count, \"years\");\n};\n\nexport function setHours(date: Moment, count: number) {\n return date.clone().hours(count);\n};\n\nexport function getMinutes(date: Moment) {\n return date.get(\"minutes\");\n};\n\nexport function setMinutes(date: Moment, count: number) {\n return date.clone().minutes(count);\n};\n\nexport function getSeconds(date: Moment) {\n return date.get(\"seconds\");\n};\n\nexport function setSeconds(date: Moment, count: number) {\n return date.clone().seconds(count);\n};\n\nexport function getWeek(date: Moment) {\n return date.get(\"week\");\n};\n\nexport function getMonth(date: Moment) {\n return date.get(\"month\");\n};\n\nexport function getDaysInMonth(date: Moment) {\n return date.daysInMonth();\n};\n\nexport function isSameDay(date: Moment, comparing: Moment) {\n return date.isSame(comparing, \"day\");\n};\n\nexport function isSameMonth(date: Moment, comparing: Moment) {\n return date.isSame(comparing, \"month\");\n};\n\nexport function isSameYear(date: Moment, comparing: Moment) {\n return date.isSame(comparing, \"year\");\n};\n\nexport function isSameHour(date: Moment, comparing: Moment) {\n return date.isSame(comparing, \"hour\");\n};\n\nexport function setMonth(date: Moment, count: number) {\n return date.clone().month(count);\n};\n\nexport function getMeridiemText(meridiem: \"am\" | \"pm\") {\n if (is12HourCycleInCurrentLocale()) {\n // AM/PM translation only possible in those who have 12 hour cycle in locale.\n return moment\n .localeData(getCurrentLocaleCode())\n .meridiem(meridiem === \"am\" ? 0 : 13, 0, false);\n }\n\n return meridiem === \"am\" ? \"AM\" : \"PM\"; // fallback for de, ru, ...etc\n};\n\nexport function startOfYear(date: Moment) {\n return date.clone().startOf(\"year\");\n};\n\nexport function endOfYear(date: Moment) {\n return date.clone().endOf(\"year\");\n};\n\nexport function startOfMonth(date: Moment) {\n return date.clone().startOf(\"month\");\n};\n\nexport function endOfMonth(date: Moment) {\n return date.clone().endOf(\"month\");\n};\n\nexport function startOfWeek(date: Moment) {\n return date.clone().startOf(\"week\");\n};\n\nexport function endOfWeek(date: Moment) {\n return date.clone().endOf(\"week\");\n};\n\nexport function getNextMonth(date: Moment) {\n return date.clone().add(1, \"month\");\n};\n\nexport function getPreviousMonth(date: Moment) {\n return date.clone().subtract(1, \"month\");\n};\n\nexport function getMonthArray(date: Moment) {\n const firstMonth = date.clone().startOf(\"year\");\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: Moment) {\n return date.get(\"year\");\n};\n\nexport function setYear(date: Moment, year: number) {\n return date.clone().set(\"year\", year);\n};\n\nexport function getDate(date: Moment) {\n return date.get(\"date\");\n};\n\nexport function setDate(date: Moment, day: number) {\n return date.clone().set(\"date\", day);\n};\n\nexport function mergeDateAndTime(date: Moment, time: Moment) {\n return date.hour(time.hour()).minute(time.minute()).second(time.second());\n};\n\nexport function getWeekdays() {\n return moment.weekdaysShort(true);\n};\n\nexport function isEqual(value: any, comparing: any) {\n if (value === null && comparing === null) {\n return true;\n }\n\n return moment(value).isSame(comparing);\n};\n\nexport function getWeekArray(date: Moment) {\n const start = date.clone().startOf(\"month\").startOf(\"week\");\n const end = date.clone().endOf(\"month\").endOf(\"week\");\n\n let count = 0;\n let current = start;\n const nestedWeeks: Moment[][] = [];\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.clone().add(1, \"day\");\n count += 1;\n }\n\n return nestedWeeks;\n};\n\nexport function getYearRange(start: Moment, end: Moment) {\n const startDate = moment(start).startOf(\"year\");\n const endDate = moment(end).endOf(\"year\");\n const years: Moment[] = [];\n\n let current = startDate;\n while (current.isBefore(endDate)) {\n years.push(current);\n current = current.clone().add(1, \"year\");\n }\n\n return years;\n};\n\nexport function isWithinRange(date: Moment, [start, end]: [Moment, Moment]) {\n return date.isBetween(start, end, null, \"[]\");\n};\n\n\n`;\n}\n"],"mappings":";;;;;;;;;AA2BA,SAAgB,aAAa,SAA4B;AACvD,QAAO;;;;aAII,QAAQ,OAAO,UAAU;;;EAGpC,cAAc,QAAQ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;uBA4CrB,QAAQ,IAAI,OAAO,kBAAkB,QAAQ,gBAAgB,SACzD,GAAG,QAAQ,IAAI,OAAO,kBAAkB,QAAQ,gBAAgB,WAChE,QACL"}