katanakit-js 6.2.0 → 6.6.1
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 +11 -3
- package/dist/adapters/better-auth/better-auth.service.d.ts +83 -0
- package/dist/adapters/better-auth/better-auth.service.d.ts.map +1 -0
- package/dist/adapters/better-auth/better-auth.service.js +110 -0
- package/dist/adapters/better-auth/better-auth.service.js.map +1 -0
- package/dist/adapters/better-auth/client.d.ts +51 -0
- package/dist/adapters/better-auth/client.d.ts.map +1 -0
- package/dist/adapters/better-auth/client.js +67 -0
- package/dist/adapters/better-auth/client.js.map +1 -0
- package/dist/adapters/better-auth/index.d.ts +3 -0
- package/dist/adapters/better-auth/index.d.ts.map +1 -0
- package/dist/adapters/better-auth/index.js +3 -0
- package/dist/adapters/better-auth/index.js.map +1 -0
- package/dist/adapters/express/server.d.ts +133 -1
- package/dist/adapters/express/server.d.ts.map +1 -1
- package/dist/adapters/express/server.js +199 -97
- package/dist/adapters/express/server.js.map +1 -1
- package/dist/adapters/index.d.ts +2 -0
- package/dist/adapters/index.d.ts.map +1 -1
- package/dist/adapters/index.js +2 -0
- package/dist/adapters/index.js.map +1 -1
- package/dist/adapters/insforge/insforge.service.d.ts +139 -4
- package/dist/adapters/insforge/insforge.service.d.ts.map +1 -1
- package/dist/adapters/insforge/insforge.service.js +383 -213
- package/dist/adapters/insforge/insforge.service.js.map +1 -1
- package/dist/adapters/notion/notion.service.d.ts +130 -144
- package/dist/adapters/notion/notion.service.d.ts.map +1 -1
- package/dist/adapters/notion/notion.service.js +330 -341
- package/dist/adapters/notion/notion.service.js.map +1 -1
- package/dist/adapters/photoswipe/index.d.ts +2 -0
- package/dist/adapters/photoswipe/index.d.ts.map +1 -0
- package/dist/adapters/photoswipe/index.js +2 -0
- package/dist/adapters/photoswipe/index.js.map +1 -0
- package/dist/adapters/photoswipe/photoswipe.service.d.ts +99 -0
- package/dist/adapters/photoswipe/photoswipe.service.d.ts.map +1 -0
- package/dist/adapters/photoswipe/photoswipe.service.js +150 -0
- package/dist/adapters/photoswipe/photoswipe.service.js.map +1 -0
- package/dist/adapters/telegram/telegram.service.d.ts +82 -13
- package/dist/adapters/telegram/telegram.service.d.ts.map +1 -1
- package/dist/adapters/telegram/telegram.service.js +133 -55
- package/dist/adapters/telegram/telegram.service.js.map +1 -1
- package/dist/adapters/wordpress/wordpress.service.d.ts +181 -110
- package/dist/adapters/wordpress/wordpress.service.d.ts.map +1 -1
- package/dist/adapters/wordpress/wordpress.service.js +556 -465
- package/dist/adapters/wordpress/wordpress.service.js.map +1 -1
- package/dist/config/seo.service.d.ts +1 -1
- package/dist/config/seo.service.d.ts.map +1 -1
- package/dist/config/seo.service.js +1 -1
- package/dist/config/seo.service.js.map +1 -1
- package/dist/core/services/access.service.d.ts +167 -4
- package/dist/core/services/access.service.d.ts.map +1 -1
- package/dist/core/services/access.service.js +241 -31
- package/dist/core/services/access.service.js.map +1 -1
- package/dist/core/services/agent.service.d.ts +182 -27
- package/dist/core/services/agent.service.d.ts.map +1 -1
- package/dist/core/services/agent.service.js +296 -164
- package/dist/core/services/agent.service.js.map +1 -1
- package/dist/core/services/assistant.service.d.ts +96 -5
- package/dist/core/services/assistant.service.d.ts.map +1 -1
- package/dist/core/services/assistant.service.js +171 -66
- package/dist/core/services/assistant.service.js.map +1 -1
- package/dist/core/services/dates.service.d.ts +183 -11
- package/dist/core/services/dates.service.d.ts.map +1 -1
- package/dist/core/services/dates.service.js +256 -57
- package/dist/core/services/dates.service.js.map +1 -1
- package/dist/core/services/http.service.d.ts +172 -133
- package/dist/core/services/http.service.d.ts.map +1 -1
- package/dist/core/services/http.service.js +367 -310
- package/dist/core/services/http.service.js.map +1 -1
- package/dist/core/services/logger.service.d.ts +96 -34
- package/dist/core/services/logger.service.d.ts.map +1 -1
- package/dist/core/services/logger.service.js +128 -41
- package/dist/core/services/logger.service.js.map +1 -1
- package/dist/core/services/query.service.d.ts +101 -0
- package/dist/core/services/query.service.d.ts.map +1 -1
- package/dist/core/services/query.service.js +131 -14
- package/dist/core/services/query.service.js.map +1 -1
- package/dist/core/services/utils.service.d.ts +286 -131
- package/dist/core/services/utils.service.d.ts.map +1 -1
- package/dist/core/services/utils.service.js +417 -227
- package/dist/core/services/utils.service.js.map +1 -1
- package/dist/core/services/validation.service.d.ts +48 -3
- package/dist/core/services/validation.service.d.ts.map +1 -1
- package/dist/core/services/validation.service.js +75 -23
- package/dist/core/services/validation.service.js.map +1 -1
- package/dist/infrastructure/decorators/cache.decorator.d.ts +53 -0
- package/dist/infrastructure/decorators/cache.decorator.d.ts.map +1 -0
- package/dist/infrastructure/decorators/cache.decorator.js +47 -0
- package/dist/infrastructure/decorators/cache.decorator.js.map +1 -0
- package/dist/infrastructure/decorators/index.d.ts +4 -0
- package/dist/infrastructure/decorators/index.d.ts.map +1 -0
- package/dist/infrastructure/decorators/index.js +4 -0
- package/dist/infrastructure/decorators/index.js.map +1 -0
- package/dist/infrastructure/decorators/logger.decorator.d.ts +38 -0
- package/dist/infrastructure/decorators/logger.decorator.d.ts.map +1 -0
- package/dist/infrastructure/decorators/logger.decorator.js +66 -0
- package/dist/infrastructure/decorators/logger.decorator.js.map +1 -0
- package/dist/infrastructure/decorators/retry.decorator.d.ts +37 -0
- package/dist/infrastructure/decorators/retry.decorator.d.ts.map +1 -0
- package/dist/infrastructure/decorators/retry.decorator.js +54 -0
- package/dist/infrastructure/decorators/retry.decorator.js.map +1 -0
- package/dist/infrastructure/index.d.ts +1 -0
- package/dist/infrastructure/index.d.ts.map +1 -1
- package/dist/infrastructure/index.js +1 -0
- package/dist/infrastructure/index.js.map +1 -1
- package/dist/styles.css +2 -0
- package/package.json +49 -14
- package/scss/_flags.scss +179 -0
- package/scss/_functions.scss +168 -0
- package/scss/_mixins.scss +658 -0
- package/scss/_reset.scss +275 -0
- package/scss/_utilities.scss +449 -0
- package/scss/_variables.scss +539 -0
- package/scss/components/_index.scss +50 -0
- package/scss/demo.scss +12 -0
- package/scss/main.scss +56 -0
|
@@ -1,5 +1,186 @@
|
|
|
1
1
|
import { Temporal } from "@js-temporal/polyfill";
|
|
2
2
|
import type { Locale, TemporalInput } from "../../types/index.js";
|
|
3
|
+
/**
|
|
4
|
+
* DatesService - Singleton para operaciones de fechas.
|
|
5
|
+
*
|
|
6
|
+
* Aplica el patrón Singleton: una única instancia reutilizable que centraliza
|
|
7
|
+
* toda la lógica de fechas (diferencias, formateo, aritmética y comparaciones).
|
|
8
|
+
* Puro, sin I/O, seguro para SSR.
|
|
9
|
+
*/
|
|
10
|
+
export declare class DatesService {
|
|
11
|
+
private static instance;
|
|
12
|
+
/**
|
|
13
|
+
* Constructor privado - enforce singleton.
|
|
14
|
+
*/
|
|
15
|
+
private constructor();
|
|
16
|
+
/**
|
|
17
|
+
* Obtiene la instancia única del DatesService (Singleton).
|
|
18
|
+
*
|
|
19
|
+
* @returns La instancia única de {@link DatesService}.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```ts
|
|
23
|
+
* const dates = DatesService.getInstance();
|
|
24
|
+
* dates.useNow();
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
static getInstance(): DatesService;
|
|
28
|
+
/**
|
|
29
|
+
* Internal helper that adapts flexible inputs into a `PlainDate`.
|
|
30
|
+
*
|
|
31
|
+
* @param date - An ISO date string or a `Temporal.PlainDate`.
|
|
32
|
+
* @returns A `Temporal.PlainDate`.
|
|
33
|
+
*/
|
|
34
|
+
private toPlainDate;
|
|
35
|
+
/**
|
|
36
|
+
* Returns a human-readable diff between two dates as years, months, and days.
|
|
37
|
+
*
|
|
38
|
+
* @param start - Start date (ISO string or `PlainDate`).
|
|
39
|
+
* @param end - End date (ISO string or `PlainDate`).
|
|
40
|
+
* @returns A formatted string, e.g. `"2 years, 3 months and 15 days"`.
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* ```ts
|
|
44
|
+
* useDiff("2020-01-01", "2022-04-16");
|
|
45
|
+
* // "2 years, 3 months and 15 days"
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
useDiff(start: string | Temporal.PlainDate, end: string | Temporal.PlainDate): string;
|
|
49
|
+
/**
|
|
50
|
+
* Formats a date input into a localised string using `Intl.DateTimeFormat`.
|
|
51
|
+
*
|
|
52
|
+
* Accepts epoch milliseconds, ISO strings, native `Date` objects,
|
|
53
|
+
* `Temporal.Instant`, or any `Temporal` date/time type.
|
|
54
|
+
*
|
|
55
|
+
* @param dateInput - The value to format.
|
|
56
|
+
* @param locale - BCP 47 locale tag (defaults to `"en"`).
|
|
57
|
+
* @param options - `Intl.DateTimeFormatOptions` (defaults to `{}`).
|
|
58
|
+
* @returns The formatted date string.
|
|
59
|
+
* @throws {Error} If the input cannot be parsed as a date.
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* ```ts
|
|
63
|
+
* useFormat("2024-06-15"); // "6/15/2024" (en-US)
|
|
64
|
+
* useFormat(Date.now(), "es", { dateStyle: "full" }); // "sábado, 15 de junio de 2024"
|
|
65
|
+
* ```
|
|
66
|
+
*/
|
|
67
|
+
useFormat(dateInput: TemporalInput, locale?: Locale, options?: Intl.DateTimeFormatOptions): string;
|
|
68
|
+
/**
|
|
69
|
+
* Returns today's date as an ISO date string.
|
|
70
|
+
*
|
|
71
|
+
* @returns The current date in `YYYY-MM-DD` format.
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* ```ts
|
|
75
|
+
* useNow(); // "2024-06-15"
|
|
76
|
+
* ```
|
|
77
|
+
*/
|
|
78
|
+
useNow(): string;
|
|
79
|
+
/**
|
|
80
|
+
* Returns the current date and time as an ISO string (no timezone offset).
|
|
81
|
+
*
|
|
82
|
+
* @returns The current date-time in `YYYY-MM-DDTHH:MM:SS` format.
|
|
83
|
+
*
|
|
84
|
+
* @example
|
|
85
|
+
* ```ts
|
|
86
|
+
* useNowDateTime(); // "2024-06-15T14:30:00"
|
|
87
|
+
* ```
|
|
88
|
+
*/
|
|
89
|
+
useNowDateTime(): string;
|
|
90
|
+
/**
|
|
91
|
+
* Adds a number of days to a date.
|
|
92
|
+
*
|
|
93
|
+
* @param date - Base date (ISO string or `PlainDate`).
|
|
94
|
+
* @param days - Number of days to add (can be negative).
|
|
95
|
+
* @returns The resulting date as an ISO string.
|
|
96
|
+
*
|
|
97
|
+
* @example
|
|
98
|
+
* ```ts
|
|
99
|
+
* useAddDays("2024-01-01", 10); // "2024-01-11"
|
|
100
|
+
* ```
|
|
101
|
+
*/
|
|
102
|
+
useAddDays(date: string | Temporal.PlainDate, days: number): string;
|
|
103
|
+
/**
|
|
104
|
+
* Subtracts a number of days from a date.
|
|
105
|
+
*
|
|
106
|
+
* @param date - Base date (ISO string or `PlainDate`).
|
|
107
|
+
* @param days - Number of days to subtract.
|
|
108
|
+
* @returns The resulting date as an ISO string.
|
|
109
|
+
*
|
|
110
|
+
* @example
|
|
111
|
+
* ```ts
|
|
112
|
+
* useSubtractDays("2024-01-11", 10); // "2024-01-01"
|
|
113
|
+
* ```
|
|
114
|
+
*/
|
|
115
|
+
useSubtractDays(date: string | Temporal.PlainDate, days: number): string;
|
|
116
|
+
/**
|
|
117
|
+
* Checks whether two dates are equal.
|
|
118
|
+
*
|
|
119
|
+
* @param date1 - First date (ISO string or `PlainDate`).
|
|
120
|
+
* @param date2 - Second date (ISO string or `PlainDate`).
|
|
121
|
+
* @returns `true` if the dates represent the same day.
|
|
122
|
+
*
|
|
123
|
+
* @example
|
|
124
|
+
* ```ts
|
|
125
|
+
* useIsEqual("2024-06-15", "2024-06-15"); // true
|
|
126
|
+
* useIsEqual("2024-06-15", "2024-06-16"); // false
|
|
127
|
+
* ```
|
|
128
|
+
*/
|
|
129
|
+
useIsEqual(date1: string | Temporal.PlainDate, date2: string | Temporal.PlainDate): boolean;
|
|
130
|
+
/**
|
|
131
|
+
* Checks whether `date1` is before `date2`.
|
|
132
|
+
*
|
|
133
|
+
* @param date1 - First date (ISO string or `PlainDate`).
|
|
134
|
+
* @param date2 - Second date (ISO string or `PlainDate`).
|
|
135
|
+
* @returns `true` if `date1` is strictly before `date2`.
|
|
136
|
+
*
|
|
137
|
+
* @example
|
|
138
|
+
* ```ts
|
|
139
|
+
* useIsBefore("2024-01-01", "2024-06-15"); // true
|
|
140
|
+
* useIsBefore("2024-06-15", "2024-06-15"); // false
|
|
141
|
+
* ```
|
|
142
|
+
*/
|
|
143
|
+
useIsBefore(date1: string | Temporal.PlainDate, date2: string | Temporal.PlainDate): boolean;
|
|
144
|
+
/**
|
|
145
|
+
* Checks whether `date1` is after `date2`.
|
|
146
|
+
*
|
|
147
|
+
* @param date1 - First date (ISO string or `PlainDate`).
|
|
148
|
+
* @param date2 - Second date (ISO string or `PlainDate`).
|
|
149
|
+
* @returns `true` if `date1` is strictly after `date2`.
|
|
150
|
+
*
|
|
151
|
+
* @example
|
|
152
|
+
* ```ts
|
|
153
|
+
* useIsAfter("2024-06-15", "2024-01-01"); // true
|
|
154
|
+
* useIsAfter("2024-06-15", "2024-06-15"); // false
|
|
155
|
+
* ```
|
|
156
|
+
*/
|
|
157
|
+
useIsAfter(date1: string | Temporal.PlainDate, date2: string | Temporal.PlainDate): boolean;
|
|
158
|
+
/**
|
|
159
|
+
* Returns the first day of the month for a given date.
|
|
160
|
+
*
|
|
161
|
+
* @param date - Base date (defaults to today).
|
|
162
|
+
* @returns The first day of the month as an ISO string.
|
|
163
|
+
*
|
|
164
|
+
* @example
|
|
165
|
+
* ```ts
|
|
166
|
+
* useFirstDayOfMonth("2024-06-15"); // "2024-06-01"
|
|
167
|
+
* ```
|
|
168
|
+
*/
|
|
169
|
+
useFirstDayOfMonth(date?: string | Temporal.PlainDate): string;
|
|
170
|
+
/**
|
|
171
|
+
* Returns the last day of the month for a given date.
|
|
172
|
+
*
|
|
173
|
+
* @param date - Base date (defaults to today).
|
|
174
|
+
* @returns The last day of the month as an ISO string.
|
|
175
|
+
*
|
|
176
|
+
* @example
|
|
177
|
+
* ```ts
|
|
178
|
+
* useLastDayOfMonth("2024-02-10"); // "2024-02-29" (leap year)
|
|
179
|
+
* useLastDayOfMonth("2024-06-15"); // "2024-06-30"
|
|
180
|
+
* ```
|
|
181
|
+
*/
|
|
182
|
+
useLastDayOfMonth(date?: string | Temporal.PlainDate): string;
|
|
183
|
+
}
|
|
3
184
|
/**
|
|
4
185
|
* Returns a human-readable diff between two dates as years, months, and days.
|
|
5
186
|
*
|
|
@@ -17,19 +198,14 @@ export declare function useDiff(start: string | Temporal.PlainDate, end: string
|
|
|
17
198
|
/**
|
|
18
199
|
* Formats a date input into a localised string using `Intl.DateTimeFormat`.
|
|
19
200
|
*
|
|
20
|
-
* Accepts epoch milliseconds, ISO strings, native `Date` objects,
|
|
21
|
-
* `Temporal.Instant`, or any `Temporal` date/time type.
|
|
22
|
-
*
|
|
23
201
|
* @param dateInput - The value to format.
|
|
24
202
|
* @param locale - BCP 47 locale tag (defaults to `"en"`).
|
|
25
203
|
* @param options - `Intl.DateTimeFormatOptions` (defaults to `{}`).
|
|
26
204
|
* @returns The formatted date string.
|
|
27
|
-
* @throws {Error} If the input cannot be parsed as a date.
|
|
28
205
|
*
|
|
29
206
|
* @example
|
|
30
207
|
* ```ts
|
|
31
|
-
* useFormat("2024-06-15");
|
|
32
|
-
* useFormat(Date.now(), "es", { dateStyle: "full" }); // "sábado, 15 de junio de 2024"
|
|
208
|
+
* useFormat("2024-06-15");
|
|
33
209
|
* ```
|
|
34
210
|
*/
|
|
35
211
|
export declare function useFormat(dateInput: TemporalInput, locale?: Locale, options?: Intl.DateTimeFormatOptions): string;
|
|
@@ -91,7 +267,6 @@ export declare function useSubtractDays(date: string | Temporal.PlainDate, days:
|
|
|
91
267
|
* @example
|
|
92
268
|
* ```ts
|
|
93
269
|
* useIsEqual("2024-06-15", "2024-06-15"); // true
|
|
94
|
-
* useIsEqual("2024-06-15", "2024-06-16"); // false
|
|
95
270
|
* ```
|
|
96
271
|
*/
|
|
97
272
|
export declare function useIsEqual(date1: string | Temporal.PlainDate, date2: string | Temporal.PlainDate): boolean;
|
|
@@ -105,7 +280,6 @@ export declare function useIsEqual(date1: string | Temporal.PlainDate, date2: st
|
|
|
105
280
|
* @example
|
|
106
281
|
* ```ts
|
|
107
282
|
* useIsBefore("2024-01-01", "2024-06-15"); // true
|
|
108
|
-
* useIsBefore("2024-06-15", "2024-06-15"); // false
|
|
109
283
|
* ```
|
|
110
284
|
*/
|
|
111
285
|
export declare function useIsBefore(date1: string | Temporal.PlainDate, date2: string | Temporal.PlainDate): boolean;
|
|
@@ -119,7 +293,6 @@ export declare function useIsBefore(date1: string | Temporal.PlainDate, date2: s
|
|
|
119
293
|
* @example
|
|
120
294
|
* ```ts
|
|
121
295
|
* useIsAfter("2024-06-15", "2024-01-01"); // true
|
|
122
|
-
* useIsAfter("2024-06-15", "2024-06-15"); // false
|
|
123
296
|
* ```
|
|
124
297
|
*/
|
|
125
298
|
export declare function useIsAfter(date1: string | Temporal.PlainDate, date2: string | Temporal.PlainDate): boolean;
|
|
@@ -143,8 +316,7 @@ export declare function useFirstDayOfMonth(date?: string | Temporal.PlainDate):
|
|
|
143
316
|
*
|
|
144
317
|
* @example
|
|
145
318
|
* ```ts
|
|
146
|
-
* useLastDayOfMonth("2024-02-10"); // "2024-02-29"
|
|
147
|
-
* useLastDayOfMonth("2024-06-15"); // "2024-06-30"
|
|
319
|
+
* useLastDayOfMonth("2024-02-10"); // "2024-02-29"
|
|
148
320
|
* ```
|
|
149
321
|
*/
|
|
150
322
|
export declare function useLastDayOfMonth(date?: string | Temporal.PlainDate): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dates.service.d.ts","sourceRoot":"","sources":["../../../src/core/services/dates.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAEjD,OAAO,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"dates.service.d.ts","sourceRoot":"","sources":["../../../src/core/services/dates.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAEjD,OAAO,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAGlE;;;;;;GAMG;AACH,qBAAa,YAAY;IACxB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAe;IAEtC;;OAEG;IACH,OAAO;IAEP;;;;;;;;;;OAUG;IACH,MAAM,CAAC,WAAW,IAAI,YAAY;IAOlC;;;;;OAKG;IACH,OAAO,CAAC,WAAW;IAInB;;;;;;;;;;;;OAYG;IACH,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,QAAQ,CAAC,SAAS,EAAE,GAAG,EAAE,MAAM,GAAG,QAAQ,CAAC,SAAS,GAAG,MAAM;IAQrF;;;;;;;;;;;;;;;;;OAiBG;IACH,SAAS,CACR,SAAS,EAAE,aAAa,EACxB,MAAM,GAAE,MAAa,EACrB,OAAO,GAAE,IAAI,CAAC,qBAA0B,GACtC,MAAM;IA+BT;;;;;;;;;OASG;IACH,MAAM,IAAI,MAAM;IAIhB;;;;;;;;;OASG;IACH,cAAc,IAAI,MAAM;IAIxB;;;;;;;;;;;OAWG;IACH,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,QAAQ,CAAC,SAAS,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM;IAInE;;;;;;;;;;;OAWG;IACH,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,QAAQ,CAAC,SAAS,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM;IAIxE;;;;;;;;;;;;OAYG;IACH,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,QAAQ,CAAC,SAAS,EAAE,KAAK,EAAE,MAAM,GAAG,QAAQ,CAAC,SAAS,GAAG,OAAO;IAI3F;;;;;;;;;;;;OAYG;IACH,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,QAAQ,CAAC,SAAS,EAAE,KAAK,EAAE,MAAM,GAAG,QAAQ,CAAC,SAAS,GAAG,OAAO;IAI5F;;;;;;;;;;;;OAYG;IACH,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,QAAQ,CAAC,SAAS,EAAE,KAAK,EAAE,MAAM,GAAG,QAAQ,CAAC,SAAS,GAAG,OAAO;IAI3F;;;;;;;;;;OAUG;IACH,kBAAkB,CAAC,IAAI,GAAE,MAAM,GAAG,QAAQ,CAAC,SAAuC,GAAG,MAAM;IAI3F;;;;;;;;;;;OAWG;IACH,iBAAiB,CAAC,IAAI,GAAE,MAAM,GAAG,QAAQ,CAAC,SAAuC,GAAG,MAAM;CAO1F;AAMD;;;;;;;;;;;;GAYG;AACH,wBAAgB,OAAO,CACtB,KAAK,EAAE,MAAM,GAAG,QAAQ,CAAC,SAAS,EAClC,GAAG,EAAE,MAAM,GAAG,QAAQ,CAAC,SAAS,GAC9B,MAAM,CAER;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,SAAS,CACxB,SAAS,EAAE,aAAa,EACxB,MAAM,GAAE,MAAa,EACrB,OAAO,GAAE,IAAI,CAAC,qBAA0B,GACtC,MAAM,CAER;AAED;;;;;;;;;GASG;AACH,wBAAgB,MAAM,IAAI,MAAM,CAE/B;AAED;;;;;;;;;GASG;AACH,wBAAgB,cAAc,IAAI,MAAM,CAEvC;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,QAAQ,CAAC,SAAS,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAElF;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,QAAQ,CAAC,SAAS,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAEvF;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,UAAU,CACzB,KAAK,EAAE,MAAM,GAAG,QAAQ,CAAC,SAAS,EAClC,KAAK,EAAE,MAAM,GAAG,QAAQ,CAAC,SAAS,GAChC,OAAO,CAET;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,WAAW,CAC1B,KAAK,EAAE,MAAM,GAAG,QAAQ,CAAC,SAAS,EAClC,KAAK,EAAE,MAAM,GAAG,QAAQ,CAAC,SAAS,GAChC,OAAO,CAET;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,UAAU,CACzB,KAAK,EAAE,MAAM,GAAG,QAAQ,CAAC,SAAS,EAClC,KAAK,EAAE,MAAM,GAAG,QAAQ,CAAC,SAAS,GAChC,OAAO,CAET;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,kBAAkB,CACjC,IAAI,GAAE,MAAM,GAAG,QAAQ,CAAC,SAAuC,GAC7D,MAAM,CAER;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,iBAAiB,CAChC,IAAI,GAAE,MAAM,GAAG,QAAQ,CAAC,SAAuC,GAC7D,MAAM,CAER"}
|
|
@@ -1,14 +1,252 @@
|
|
|
1
1
|
import { Temporal } from "@js-temporal/polyfill";
|
|
2
2
|
import { useLogger } from "./logger.service.js";
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* DatesService - Singleton para operaciones de fechas.
|
|
5
5
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
6
|
+
* Aplica el patrón Singleton: una única instancia reutilizable que centraliza
|
|
7
|
+
* toda la lógica de fechas (diferencias, formateo, aritmética y comparaciones).
|
|
8
|
+
* Puro, sin I/O, seguro para SSR.
|
|
8
9
|
*/
|
|
9
|
-
|
|
10
|
-
|
|
10
|
+
export class DatesService {
|
|
11
|
+
static instance;
|
|
12
|
+
/**
|
|
13
|
+
* Constructor privado - enforce singleton.
|
|
14
|
+
*/
|
|
15
|
+
constructor() { }
|
|
16
|
+
/**
|
|
17
|
+
* Obtiene la instancia única del DatesService (Singleton).
|
|
18
|
+
*
|
|
19
|
+
* @returns La instancia única de {@link DatesService}.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```ts
|
|
23
|
+
* const dates = DatesService.getInstance();
|
|
24
|
+
* dates.useNow();
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
static getInstance() {
|
|
28
|
+
if (!DatesService.instance) {
|
|
29
|
+
DatesService.instance = new DatesService();
|
|
30
|
+
}
|
|
31
|
+
return DatesService.instance;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Internal helper that adapts flexible inputs into a `PlainDate`.
|
|
35
|
+
*
|
|
36
|
+
* @param date - An ISO date string or a `Temporal.PlainDate`.
|
|
37
|
+
* @returns A `Temporal.PlainDate`.
|
|
38
|
+
*/
|
|
39
|
+
toPlainDate(date) {
|
|
40
|
+
return typeof date === "string" ? Temporal.PlainDate.from(date) : date;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Returns a human-readable diff between two dates as years, months, and days.
|
|
44
|
+
*
|
|
45
|
+
* @param start - Start date (ISO string or `PlainDate`).
|
|
46
|
+
* @param end - End date (ISO string or `PlainDate`).
|
|
47
|
+
* @returns A formatted string, e.g. `"2 years, 3 months and 15 days"`.
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* ```ts
|
|
51
|
+
* useDiff("2020-01-01", "2022-04-16");
|
|
52
|
+
* // "2 years, 3 months and 15 days"
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
useDiff(start, end) {
|
|
56
|
+
const startDate = this.toPlainDate(start);
|
|
57
|
+
const endDate = this.toPlainDate(end);
|
|
58
|
+
const duration = startDate.until(endDate, { largestUnit: "year" });
|
|
59
|
+
return `${duration.years} years, ${duration.months} months and ${duration.days} days`;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Formats a date input into a localised string using `Intl.DateTimeFormat`.
|
|
63
|
+
*
|
|
64
|
+
* Accepts epoch milliseconds, ISO strings, native `Date` objects,
|
|
65
|
+
* `Temporal.Instant`, or any `Temporal` date/time type.
|
|
66
|
+
*
|
|
67
|
+
* @param dateInput - The value to format.
|
|
68
|
+
* @param locale - BCP 47 locale tag (defaults to `"en"`).
|
|
69
|
+
* @param options - `Intl.DateTimeFormatOptions` (defaults to `{}`).
|
|
70
|
+
* @returns The formatted date string.
|
|
71
|
+
* @throws {Error} If the input cannot be parsed as a date.
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* ```ts
|
|
75
|
+
* useFormat("2024-06-15"); // "6/15/2024" (en-US)
|
|
76
|
+
* useFormat(Date.now(), "es", { dateStyle: "full" }); // "sábado, 15 de junio de 2024"
|
|
77
|
+
* ```
|
|
78
|
+
*/
|
|
79
|
+
useFormat(dateInput, locale = "en", options = {}) {
|
|
80
|
+
let date;
|
|
81
|
+
try {
|
|
82
|
+
if (typeof dateInput === "number") {
|
|
83
|
+
date = Temporal.Instant.fromEpochMilliseconds(dateInput).toZonedDateTimeISO(Temporal.Now.timeZoneId());
|
|
84
|
+
}
|
|
85
|
+
else if (typeof dateInput === "string") {
|
|
86
|
+
try {
|
|
87
|
+
date = Temporal.PlainDate.from(dateInput);
|
|
88
|
+
}
|
|
89
|
+
catch {
|
|
90
|
+
date = Temporal.PlainDateTime.from(dateInput);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
else if (dateInput instanceof Date) {
|
|
94
|
+
date = Temporal.Instant.fromEpochMilliseconds(dateInput.getTime()).toZonedDateTimeISO(Temporal.Now.timeZoneId());
|
|
95
|
+
}
|
|
96
|
+
else if (dateInput instanceof Temporal.Instant) {
|
|
97
|
+
date = dateInput.toZonedDateTimeISO(Temporal.Now.timeZoneId());
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
date = dateInput;
|
|
101
|
+
}
|
|
102
|
+
return date.toLocaleString(locale, options);
|
|
103
|
+
}
|
|
104
|
+
catch (error) {
|
|
105
|
+
useLogger("Invalid date input:", error, "error");
|
|
106
|
+
throw new Error(`Invalid date input: ${dateInput}`);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Returns today's date as an ISO date string.
|
|
111
|
+
*
|
|
112
|
+
* @returns The current date in `YYYY-MM-DD` format.
|
|
113
|
+
*
|
|
114
|
+
* @example
|
|
115
|
+
* ```ts
|
|
116
|
+
* useNow(); // "2024-06-15"
|
|
117
|
+
* ```
|
|
118
|
+
*/
|
|
119
|
+
useNow() {
|
|
120
|
+
return Temporal.Now.plainDateISO().toString();
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Returns the current date and time as an ISO string (no timezone offset).
|
|
124
|
+
*
|
|
125
|
+
* @returns The current date-time in `YYYY-MM-DDTHH:MM:SS` format.
|
|
126
|
+
*
|
|
127
|
+
* @example
|
|
128
|
+
* ```ts
|
|
129
|
+
* useNowDateTime(); // "2024-06-15T14:30:00"
|
|
130
|
+
* ```
|
|
131
|
+
*/
|
|
132
|
+
useNowDateTime() {
|
|
133
|
+
return Temporal.Now.plainDateTimeISO().toString();
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Adds a number of days to a date.
|
|
137
|
+
*
|
|
138
|
+
* @param date - Base date (ISO string or `PlainDate`).
|
|
139
|
+
* @param days - Number of days to add (can be negative).
|
|
140
|
+
* @returns The resulting date as an ISO string.
|
|
141
|
+
*
|
|
142
|
+
* @example
|
|
143
|
+
* ```ts
|
|
144
|
+
* useAddDays("2024-01-01", 10); // "2024-01-11"
|
|
145
|
+
* ```
|
|
146
|
+
*/
|
|
147
|
+
useAddDays(date, days) {
|
|
148
|
+
return this.toPlainDate(date).add({ days }).toString();
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Subtracts a number of days from a date.
|
|
152
|
+
*
|
|
153
|
+
* @param date - Base date (ISO string or `PlainDate`).
|
|
154
|
+
* @param days - Number of days to subtract.
|
|
155
|
+
* @returns The resulting date as an ISO string.
|
|
156
|
+
*
|
|
157
|
+
* @example
|
|
158
|
+
* ```ts
|
|
159
|
+
* useSubtractDays("2024-01-11", 10); // "2024-01-01"
|
|
160
|
+
* ```
|
|
161
|
+
*/
|
|
162
|
+
useSubtractDays(date, days) {
|
|
163
|
+
return this.toPlainDate(date).subtract({ days }).toString();
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Checks whether two dates are equal.
|
|
167
|
+
*
|
|
168
|
+
* @param date1 - First date (ISO string or `PlainDate`).
|
|
169
|
+
* @param date2 - Second date (ISO string or `PlainDate`).
|
|
170
|
+
* @returns `true` if the dates represent the same day.
|
|
171
|
+
*
|
|
172
|
+
* @example
|
|
173
|
+
* ```ts
|
|
174
|
+
* useIsEqual("2024-06-15", "2024-06-15"); // true
|
|
175
|
+
* useIsEqual("2024-06-15", "2024-06-16"); // false
|
|
176
|
+
* ```
|
|
177
|
+
*/
|
|
178
|
+
useIsEqual(date1, date2) {
|
|
179
|
+
return Temporal.PlainDate.compare(this.toPlainDate(date1), this.toPlainDate(date2)) === 0;
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Checks whether `date1` is before `date2`.
|
|
183
|
+
*
|
|
184
|
+
* @param date1 - First date (ISO string or `PlainDate`).
|
|
185
|
+
* @param date2 - Second date (ISO string or `PlainDate`).
|
|
186
|
+
* @returns `true` if `date1` is strictly before `date2`.
|
|
187
|
+
*
|
|
188
|
+
* @example
|
|
189
|
+
* ```ts
|
|
190
|
+
* useIsBefore("2024-01-01", "2024-06-15"); // true
|
|
191
|
+
* useIsBefore("2024-06-15", "2024-06-15"); // false
|
|
192
|
+
* ```
|
|
193
|
+
*/
|
|
194
|
+
useIsBefore(date1, date2) {
|
|
195
|
+
return Temporal.PlainDate.compare(this.toPlainDate(date1), this.toPlainDate(date2)) < 0;
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Checks whether `date1` is after `date2`.
|
|
199
|
+
*
|
|
200
|
+
* @param date1 - First date (ISO string or `PlainDate`).
|
|
201
|
+
* @param date2 - Second date (ISO string or `PlainDate`).
|
|
202
|
+
* @returns `true` if `date1` is strictly after `date2`.
|
|
203
|
+
*
|
|
204
|
+
* @example
|
|
205
|
+
* ```ts
|
|
206
|
+
* useIsAfter("2024-06-15", "2024-01-01"); // true
|
|
207
|
+
* useIsAfter("2024-06-15", "2024-06-15"); // false
|
|
208
|
+
* ```
|
|
209
|
+
*/
|
|
210
|
+
useIsAfter(date1, date2) {
|
|
211
|
+
return Temporal.PlainDate.compare(this.toPlainDate(date1), this.toPlainDate(date2)) > 0;
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Returns the first day of the month for a given date.
|
|
215
|
+
*
|
|
216
|
+
* @param date - Base date (defaults to today).
|
|
217
|
+
* @returns The first day of the month as an ISO string.
|
|
218
|
+
*
|
|
219
|
+
* @example
|
|
220
|
+
* ```ts
|
|
221
|
+
* useFirstDayOfMonth("2024-06-15"); // "2024-06-01"
|
|
222
|
+
* ```
|
|
223
|
+
*/
|
|
224
|
+
useFirstDayOfMonth(date = Temporal.Now.plainDateISO()) {
|
|
225
|
+
return this.toPlainDate(date).with({ day: 1 }).toString();
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Returns the last day of the month for a given date.
|
|
229
|
+
*
|
|
230
|
+
* @param date - Base date (defaults to today).
|
|
231
|
+
* @returns The last day of the month as an ISO string.
|
|
232
|
+
*
|
|
233
|
+
* @example
|
|
234
|
+
* ```ts
|
|
235
|
+
* useLastDayOfMonth("2024-02-10"); // "2024-02-29" (leap year)
|
|
236
|
+
* useLastDayOfMonth("2024-06-15"); // "2024-06-30"
|
|
237
|
+
* ```
|
|
238
|
+
*/
|
|
239
|
+
useLastDayOfMonth(date = Temporal.Now.plainDateISO()) {
|
|
240
|
+
return this.toPlainDate(date)
|
|
241
|
+
.add({ months: 1 })
|
|
242
|
+
.with({ day: 1 })
|
|
243
|
+
.subtract({ days: 1 })
|
|
244
|
+
.toString();
|
|
245
|
+
}
|
|
11
246
|
}
|
|
247
|
+
/* -------------------------------------------------------------------------- */
|
|
248
|
+
/* Wrappers (backward compatibility) */
|
|
249
|
+
/* -------------------------------------------------------------------------- */
|
|
12
250
|
/**
|
|
13
251
|
* Returns a human-readable diff between two dates as years, months, and days.
|
|
14
252
|
*
|
|
@@ -23,58 +261,23 @@ function toPlainDate(date) {
|
|
|
23
261
|
* ```
|
|
24
262
|
*/
|
|
25
263
|
export function useDiff(start, end) {
|
|
26
|
-
|
|
27
|
-
const endDate = toPlainDate(end);
|
|
28
|
-
const duration = startDate.until(endDate, { largestUnit: "year" });
|
|
29
|
-
return `${duration.years} years, ${duration.months} months and ${duration.days} days`;
|
|
264
|
+
return DatesService.getInstance().useDiff(start, end);
|
|
30
265
|
}
|
|
31
266
|
/**
|
|
32
267
|
* Formats a date input into a localised string using `Intl.DateTimeFormat`.
|
|
33
268
|
*
|
|
34
|
-
* Accepts epoch milliseconds, ISO strings, native `Date` objects,
|
|
35
|
-
* `Temporal.Instant`, or any `Temporal` date/time type.
|
|
36
|
-
*
|
|
37
269
|
* @param dateInput - The value to format.
|
|
38
270
|
* @param locale - BCP 47 locale tag (defaults to `"en"`).
|
|
39
271
|
* @param options - `Intl.DateTimeFormatOptions` (defaults to `{}`).
|
|
40
272
|
* @returns The formatted date string.
|
|
41
|
-
* @throws {Error} If the input cannot be parsed as a date.
|
|
42
273
|
*
|
|
43
274
|
* @example
|
|
44
275
|
* ```ts
|
|
45
|
-
* useFormat("2024-06-15");
|
|
46
|
-
* useFormat(Date.now(), "es", { dateStyle: "full" }); // "sábado, 15 de junio de 2024"
|
|
276
|
+
* useFormat("2024-06-15");
|
|
47
277
|
* ```
|
|
48
278
|
*/
|
|
49
279
|
export function useFormat(dateInput, locale = "en", options = {}) {
|
|
50
|
-
|
|
51
|
-
try {
|
|
52
|
-
if (typeof dateInput === "number") {
|
|
53
|
-
date = Temporal.Instant.fromEpochMilliseconds(dateInput).toZonedDateTimeISO(Temporal.Now.timeZoneId());
|
|
54
|
-
}
|
|
55
|
-
else if (typeof dateInput === "string") {
|
|
56
|
-
try {
|
|
57
|
-
date = Temporal.PlainDate.from(dateInput);
|
|
58
|
-
}
|
|
59
|
-
catch {
|
|
60
|
-
date = Temporal.PlainDateTime.from(dateInput);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
else if (dateInput instanceof Date) {
|
|
64
|
-
date = Temporal.Instant.fromEpochMilliseconds(dateInput.getTime()).toZonedDateTimeISO(Temporal.Now.timeZoneId());
|
|
65
|
-
}
|
|
66
|
-
else if (dateInput instanceof Temporal.Instant) {
|
|
67
|
-
date = dateInput.toZonedDateTimeISO(Temporal.Now.timeZoneId());
|
|
68
|
-
}
|
|
69
|
-
else {
|
|
70
|
-
date = dateInput;
|
|
71
|
-
}
|
|
72
|
-
return date.toLocaleString(locale, options);
|
|
73
|
-
}
|
|
74
|
-
catch (error) {
|
|
75
|
-
useLogger("Invalid date input:", error, "error");
|
|
76
|
-
throw new Error(`Invalid date input: ${dateInput}`);
|
|
77
|
-
}
|
|
280
|
+
return DatesService.getInstance().useFormat(dateInput, locale, options);
|
|
78
281
|
}
|
|
79
282
|
/**
|
|
80
283
|
* Returns today's date as an ISO date string.
|
|
@@ -87,7 +290,7 @@ export function useFormat(dateInput, locale = "en", options = {}) {
|
|
|
87
290
|
* ```
|
|
88
291
|
*/
|
|
89
292
|
export function useNow() {
|
|
90
|
-
return
|
|
293
|
+
return DatesService.getInstance().useNow();
|
|
91
294
|
}
|
|
92
295
|
/**
|
|
93
296
|
* Returns the current date and time as an ISO string (no timezone offset).
|
|
@@ -100,7 +303,7 @@ export function useNow() {
|
|
|
100
303
|
* ```
|
|
101
304
|
*/
|
|
102
305
|
export function useNowDateTime() {
|
|
103
|
-
return
|
|
306
|
+
return DatesService.getInstance().useNowDateTime();
|
|
104
307
|
}
|
|
105
308
|
/**
|
|
106
309
|
* Adds a number of days to a date.
|
|
@@ -115,7 +318,7 @@ export function useNowDateTime() {
|
|
|
115
318
|
* ```
|
|
116
319
|
*/
|
|
117
320
|
export function useAddDays(date, days) {
|
|
118
|
-
return
|
|
321
|
+
return DatesService.getInstance().useAddDays(date, days);
|
|
119
322
|
}
|
|
120
323
|
/**
|
|
121
324
|
* Subtracts a number of days from a date.
|
|
@@ -130,7 +333,7 @@ export function useAddDays(date, days) {
|
|
|
130
333
|
* ```
|
|
131
334
|
*/
|
|
132
335
|
export function useSubtractDays(date, days) {
|
|
133
|
-
return
|
|
336
|
+
return DatesService.getInstance().useSubtractDays(date, days);
|
|
134
337
|
}
|
|
135
338
|
/**
|
|
136
339
|
* Checks whether two dates are equal.
|
|
@@ -142,11 +345,10 @@ export function useSubtractDays(date, days) {
|
|
|
142
345
|
* @example
|
|
143
346
|
* ```ts
|
|
144
347
|
* useIsEqual("2024-06-15", "2024-06-15"); // true
|
|
145
|
-
* useIsEqual("2024-06-15", "2024-06-16"); // false
|
|
146
348
|
* ```
|
|
147
349
|
*/
|
|
148
350
|
export function useIsEqual(date1, date2) {
|
|
149
|
-
return
|
|
351
|
+
return DatesService.getInstance().useIsEqual(date1, date2);
|
|
150
352
|
}
|
|
151
353
|
/**
|
|
152
354
|
* Checks whether `date1` is before `date2`.
|
|
@@ -158,11 +360,10 @@ export function useIsEqual(date1, date2) {
|
|
|
158
360
|
* @example
|
|
159
361
|
* ```ts
|
|
160
362
|
* useIsBefore("2024-01-01", "2024-06-15"); // true
|
|
161
|
-
* useIsBefore("2024-06-15", "2024-06-15"); // false
|
|
162
363
|
* ```
|
|
163
364
|
*/
|
|
164
365
|
export function useIsBefore(date1, date2) {
|
|
165
|
-
return
|
|
366
|
+
return DatesService.getInstance().useIsBefore(date1, date2);
|
|
166
367
|
}
|
|
167
368
|
/**
|
|
168
369
|
* Checks whether `date1` is after `date2`.
|
|
@@ -174,11 +375,10 @@ export function useIsBefore(date1, date2) {
|
|
|
174
375
|
* @example
|
|
175
376
|
* ```ts
|
|
176
377
|
* useIsAfter("2024-06-15", "2024-01-01"); // true
|
|
177
|
-
* useIsAfter("2024-06-15", "2024-06-15"); // false
|
|
178
378
|
* ```
|
|
179
379
|
*/
|
|
180
380
|
export function useIsAfter(date1, date2) {
|
|
181
|
-
return
|
|
381
|
+
return DatesService.getInstance().useIsAfter(date1, date2);
|
|
182
382
|
}
|
|
183
383
|
/**
|
|
184
384
|
* Returns the first day of the month for a given date.
|
|
@@ -192,7 +392,7 @@ export function useIsAfter(date1, date2) {
|
|
|
192
392
|
* ```
|
|
193
393
|
*/
|
|
194
394
|
export function useFirstDayOfMonth(date = Temporal.Now.plainDateISO()) {
|
|
195
|
-
return
|
|
395
|
+
return DatesService.getInstance().useFirstDayOfMonth(date);
|
|
196
396
|
}
|
|
197
397
|
/**
|
|
198
398
|
* Returns the last day of the month for a given date.
|
|
@@ -202,11 +402,10 @@ export function useFirstDayOfMonth(date = Temporal.Now.plainDateISO()) {
|
|
|
202
402
|
*
|
|
203
403
|
* @example
|
|
204
404
|
* ```ts
|
|
205
|
-
* useLastDayOfMonth("2024-02-10"); // "2024-02-29"
|
|
206
|
-
* useLastDayOfMonth("2024-06-15"); // "2024-06-30"
|
|
405
|
+
* useLastDayOfMonth("2024-02-10"); // "2024-02-29"
|
|
207
406
|
* ```
|
|
208
407
|
*/
|
|
209
408
|
export function useLastDayOfMonth(date = Temporal.Now.plainDateISO()) {
|
|
210
|
-
return
|
|
409
|
+
return DatesService.getInstance().useLastDayOfMonth(date);
|
|
211
410
|
}
|
|
212
411
|
//# sourceMappingURL=dates.service.js.map
|