@hotmeshio/hotmesh 0.14.1 → 0.14.2
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/build/package.json +1 -1
- package/build/services/pipe/functions/array.d.ts +219 -0
- package/build/services/pipe/functions/array.js +219 -0
- package/build/services/pipe/functions/bitwise.d.ts +94 -0
- package/build/services/pipe/functions/bitwise.js +94 -0
- package/build/services/pipe/functions/conditional.d.ts +161 -0
- package/build/services/pipe/functions/conditional.js +161 -0
- package/build/services/pipe/functions/cron.d.ts +23 -4
- package/build/services/pipe/functions/cron.js +23 -4
- package/build/services/pipe/functions/date.d.ts +737 -6
- package/build/services/pipe/functions/date.js +742 -5
- package/build/services/pipe/functions/json.d.ts +42 -0
- package/build/services/pipe/functions/json.js +42 -0
- package/build/services/pipe/functions/logical.d.ts +38 -0
- package/build/services/pipe/functions/logical.js +38 -0
- package/build/services/pipe/functions/math.d.ts +533 -0
- package/build/services/pipe/functions/math.js +533 -0
- package/build/services/pipe/functions/number.d.ts +258 -0
- package/build/services/pipe/functions/number.js +258 -0
- package/build/services/pipe/functions/object.d.ts +321 -0
- package/build/services/pipe/functions/object.js +321 -0
- package/build/services/pipe/functions/string.d.ts +306 -0
- package/build/services/pipe/functions/string.js +306 -0
- package/build/services/pipe/functions/symbol.d.ts +112 -0
- package/build/services/pipe/functions/symbol.js +112 -0
- package/build/services/pipe/functions/unary.d.ts +65 -0
- package/build/services/pipe/functions/unary.js +65 -0
- package/build/services/virtual/index.js +6 -0
- package/build/services/virtual/schemas/factory.js +1 -1
- package/build/types/virtual.d.ts +21 -0
- package/package.json +1 -1
|
@@ -2,13 +2,33 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DateHandler = void 0;
|
|
4
4
|
const utils_1 = require("../../../modules/utils");
|
|
5
|
+
/**
|
|
6
|
+
* Provides date manipulation and formatting functions for use in HotMesh
|
|
7
|
+
* mapping rules. Although inspired by JavaScript's Date API, these methods
|
|
8
|
+
* follow a functional approach where each transformation expects one or more
|
|
9
|
+
* input parameters from the prior row in the `@pipe` structure.
|
|
10
|
+
*
|
|
11
|
+
* Many methods accept various input formats (`Date`, `string`, and `number`),
|
|
12
|
+
* implicitly casting to dates as necessary. The ISO 8601 Extended Format is
|
|
13
|
+
* supported, including date strings like `YYYY-MM-DD`,
|
|
14
|
+
* `YYYY-MM-DDTHH:mm:ss`, and `YYYY-MM-DDTHH:mm:ss.sssZ`. Strings or numbers
|
|
15
|
+
* representing milliseconds since the Unix epoch are also accepted.
|
|
16
|
+
*
|
|
17
|
+
* @remarks Methods are invoked as `{@date.<method>}`, e.g., `{@date.now}` or `{@date.getFullYear}`.
|
|
18
|
+
*/
|
|
5
19
|
class DateHandler {
|
|
6
20
|
/**
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
21
|
+
* Converts a date input (ISO string, milliseconds, or Date instance) into a
|
|
22
|
+
* native Date object. This static helper centralises the parsing logic used
|
|
23
|
+
* by every other DateHandler method, allowing concise mapping rules that
|
|
24
|
+
* avoid date-initialisation boilerplate.
|
|
25
|
+
*
|
|
26
|
+
* @param {DateInput} input - A date value as an ISO 8601 string, numeric milliseconds since epoch, or an existing Date instance.
|
|
27
|
+
* @returns {Date} A native Date object corresponding to the input.
|
|
28
|
+
* @example
|
|
29
|
+
* ```typescript
|
|
30
|
+
* const d = DateHandler.getDateInstance('2023-04-23T12:00:00.000Z');
|
|
31
|
+
* ```
|
|
12
32
|
*/
|
|
13
33
|
static getDateInstance(input) {
|
|
14
34
|
const ISO_REGEX = /^\d{4}-\d{2}-\d{2}(?:T\d{2}:\d{2}:\d{2}(?:\.\d{3})?Z)?$/;
|
|
@@ -29,141 +49,858 @@ class DateHandler {
|
|
|
29
49
|
}
|
|
30
50
|
throw new Error('Invalid date format');
|
|
31
51
|
}
|
|
52
|
+
/**
|
|
53
|
+
* Creates a new Date object from a string representation of a date in
|
|
54
|
+
* ISO 8601 format.
|
|
55
|
+
*
|
|
56
|
+
* @param {string} isoString - An ISO 8601 date string (e.g., `"2023-04-23T12:00:00.000Z"`).
|
|
57
|
+
* @returns {Date} A Date object corresponding to the provided ISO string.
|
|
58
|
+
* @example
|
|
59
|
+
* ```yaml
|
|
60
|
+
* date_obj:
|
|
61
|
+
* "@pipe":
|
|
62
|
+
* - ["{a.output.data.isoDate}"]
|
|
63
|
+
* - ["{@date.fromISOString}"]
|
|
64
|
+
* ```
|
|
65
|
+
*/
|
|
32
66
|
fromISOString(isoString) {
|
|
33
67
|
return new Date(isoString);
|
|
34
68
|
}
|
|
69
|
+
/**
|
|
70
|
+
* Returns the current time in milliseconds since the Unix epoch
|
|
71
|
+
* (January 1, 1970 00:00:00 UTC). Takes no parameters.
|
|
72
|
+
*
|
|
73
|
+
* @returns {number} The current timestamp in milliseconds.
|
|
74
|
+
* @example
|
|
75
|
+
* ```yaml
|
|
76
|
+
* current_time:
|
|
77
|
+
* "@pipe":
|
|
78
|
+
* - ["{@date.now}"]
|
|
79
|
+
* ```
|
|
80
|
+
*/
|
|
35
81
|
now() {
|
|
36
82
|
return Date.now();
|
|
37
83
|
}
|
|
84
|
+
/**
|
|
85
|
+
* Returns today's date formatted as a `YYYY-MM-DD` string using UTC.
|
|
86
|
+
* Takes no parameters, similar to `date.now`.
|
|
87
|
+
*
|
|
88
|
+
* @returns {string} Today's date in `YYYY-MM-DD` format.
|
|
89
|
+
* @example
|
|
90
|
+
* ```yaml
|
|
91
|
+
* today:
|
|
92
|
+
* "@pipe":
|
|
93
|
+
* - ["{@date.yyyymmdd}"]
|
|
94
|
+
* ```
|
|
95
|
+
*/
|
|
96
|
+
yyyymmdd() {
|
|
97
|
+
const d = new Date();
|
|
98
|
+
const year = d.getUTCFullYear();
|
|
99
|
+
const month = String(d.getUTCMonth() + 1).padStart(2, '0');
|
|
100
|
+
const day = String(d.getUTCDate()).padStart(2, '0');
|
|
101
|
+
return `${year}-${month}-${day}`;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Parses a string representation of a date and returns the number of
|
|
105
|
+
* milliseconds since the Unix epoch (January 1, 1970 00:00:00 UTC).
|
|
106
|
+
*
|
|
107
|
+
* @param {string} dateString - A date string to parse (e.g., `"April 23, 2023 12:00:00"`).
|
|
108
|
+
* @returns {number} Milliseconds since the Unix epoch for the given date string.
|
|
109
|
+
* @example
|
|
110
|
+
* ```yaml
|
|
111
|
+
* date_milliseconds:
|
|
112
|
+
* "@pipe":
|
|
113
|
+
* - ["{a.output.data.dateString}"]
|
|
114
|
+
* - ["{@date.parse}"]
|
|
115
|
+
* ```
|
|
116
|
+
*/
|
|
38
117
|
parse(dateString) {
|
|
39
118
|
return Date.parse(dateString);
|
|
40
119
|
}
|
|
120
|
+
/**
|
|
121
|
+
* Returns the day of the month (1--31) for the specified date according to
|
|
122
|
+
* local time.
|
|
123
|
+
*
|
|
124
|
+
* @param {DateInput} date - A date value (ISO string, milliseconds, or Date).
|
|
125
|
+
* @returns {number} The day of the month (1--31).
|
|
126
|
+
* @example
|
|
127
|
+
* ```yaml
|
|
128
|
+
* day_of_month:
|
|
129
|
+
* "@pipe":
|
|
130
|
+
* - ["{a.output.data.date}"]
|
|
131
|
+
* - ["{@date.getDate}"]
|
|
132
|
+
* ```
|
|
133
|
+
*/
|
|
41
134
|
getDate(date) {
|
|
42
135
|
return DateHandler.getDateInstance(date).getDate();
|
|
43
136
|
}
|
|
137
|
+
/**
|
|
138
|
+
* Returns the day of the week (0--6, where 0 is Sunday) for the specified
|
|
139
|
+
* date according to local time.
|
|
140
|
+
*
|
|
141
|
+
* @param {DateInput} date - A date value (ISO string, milliseconds, or Date).
|
|
142
|
+
* @returns {number} The day of the week (0 = Sunday, 6 = Saturday).
|
|
143
|
+
* @example
|
|
144
|
+
* ```yaml
|
|
145
|
+
* day_of_week:
|
|
146
|
+
* "@pipe":
|
|
147
|
+
* - ["{a.output.data.date}"]
|
|
148
|
+
* - ["{@date.getDay}"]
|
|
149
|
+
* ```
|
|
150
|
+
*/
|
|
44
151
|
getDay(date) {
|
|
45
152
|
return DateHandler.getDateInstance(date).getDay();
|
|
46
153
|
}
|
|
154
|
+
/**
|
|
155
|
+
* Returns the full year (4 digits) for the specified date according to
|
|
156
|
+
* local time.
|
|
157
|
+
*
|
|
158
|
+
* @param {DateInput} date - A date value (ISO string, milliseconds, or Date).
|
|
159
|
+
* @returns {number} The four-digit year.
|
|
160
|
+
* @example
|
|
161
|
+
* ```yaml
|
|
162
|
+
* full_year:
|
|
163
|
+
* "@pipe":
|
|
164
|
+
* - ["{a.output.data.date}"]
|
|
165
|
+
* - ["{@date.getFullYear}"]
|
|
166
|
+
* ```
|
|
167
|
+
*/
|
|
47
168
|
getFullYear(date) {
|
|
48
169
|
return DateHandler.getDateInstance(date).getFullYear();
|
|
49
170
|
}
|
|
171
|
+
/**
|
|
172
|
+
* Returns the hour (0--23) for the specified date according to local time.
|
|
173
|
+
*
|
|
174
|
+
* @param {DateInput} date - A date value (ISO string, milliseconds, or Date).
|
|
175
|
+
* @returns {number} The hour (0--23).
|
|
176
|
+
* @example
|
|
177
|
+
* ```yaml
|
|
178
|
+
* hour:
|
|
179
|
+
* "@pipe":
|
|
180
|
+
* - ["{a.output.data.date}"]
|
|
181
|
+
* - ["{@date.getHours}"]
|
|
182
|
+
* ```
|
|
183
|
+
*/
|
|
50
184
|
getHours(date) {
|
|
51
185
|
return DateHandler.getDateInstance(date).getHours();
|
|
52
186
|
}
|
|
187
|
+
/**
|
|
188
|
+
* Returns the milliseconds (0--999) for the specified date according to
|
|
189
|
+
* local time.
|
|
190
|
+
*
|
|
191
|
+
* @param {DateInput} date - A date value (ISO string, milliseconds, or Date).
|
|
192
|
+
* @returns {number} The milliseconds component (0--999).
|
|
193
|
+
* @example
|
|
194
|
+
* ```yaml
|
|
195
|
+
* milliseconds:
|
|
196
|
+
* "@pipe":
|
|
197
|
+
* - ["{a.output.data.date}"]
|
|
198
|
+
* - ["{@date.getMilliseconds}"]
|
|
199
|
+
* ```
|
|
200
|
+
*/
|
|
53
201
|
getMilliseconds(date) {
|
|
54
202
|
return DateHandler.getDateInstance(date).getMilliseconds();
|
|
55
203
|
}
|
|
204
|
+
/**
|
|
205
|
+
* Returns the minutes (0--59) for the specified date according to local
|
|
206
|
+
* time.
|
|
207
|
+
*
|
|
208
|
+
* @param {DateInput} date - A date value (ISO string, milliseconds, or Date).
|
|
209
|
+
* @returns {number} The minutes component (0--59).
|
|
210
|
+
* @example
|
|
211
|
+
* ```yaml
|
|
212
|
+
* minutes:
|
|
213
|
+
* "@pipe":
|
|
214
|
+
* - ["{a.output.data.date}"]
|
|
215
|
+
* - ["{@date.getMinutes}"]
|
|
216
|
+
* ```
|
|
217
|
+
*/
|
|
56
218
|
getMinutes(date) {
|
|
57
219
|
return DateHandler.getDateInstance(date).getMinutes();
|
|
58
220
|
}
|
|
221
|
+
/**
|
|
222
|
+
* Returns the month (0--11, where 0 is January) for the specified date
|
|
223
|
+
* according to local time.
|
|
224
|
+
*
|
|
225
|
+
* @param {DateInput} date - A date value (ISO string, milliseconds, or Date).
|
|
226
|
+
* @returns {number} The month (0 = January, 11 = December).
|
|
227
|
+
* @example
|
|
228
|
+
* ```yaml
|
|
229
|
+
* month:
|
|
230
|
+
* "@pipe":
|
|
231
|
+
* - ["{a.output.data.date}"]
|
|
232
|
+
* - ["{@date.getMonth}"]
|
|
233
|
+
* ```
|
|
234
|
+
*/
|
|
59
235
|
getMonth(date) {
|
|
60
236
|
return DateHandler.getDateInstance(date).getMonth();
|
|
61
237
|
}
|
|
238
|
+
/**
|
|
239
|
+
* Returns the seconds (0--59) for the specified date according to local
|
|
240
|
+
* time.
|
|
241
|
+
*
|
|
242
|
+
* @param {DateInput} date - A date value (ISO string, milliseconds, or Date).
|
|
243
|
+
* @returns {number} The seconds component (0--59).
|
|
244
|
+
* @example
|
|
245
|
+
* ```yaml
|
|
246
|
+
* seconds:
|
|
247
|
+
* "@pipe":
|
|
248
|
+
* - ["{a.output.data.date}"]
|
|
249
|
+
* - ["{@date.getSeconds}"]
|
|
250
|
+
* ```
|
|
251
|
+
*/
|
|
62
252
|
getSeconds(date) {
|
|
63
253
|
return DateHandler.getDateInstance(date).getSeconds();
|
|
64
254
|
}
|
|
255
|
+
/**
|
|
256
|
+
* Returns the number of milliseconds since January 1, 1970, 00:00:00 UTC
|
|
257
|
+
* for the specified date.
|
|
258
|
+
*
|
|
259
|
+
* @param {DateInput} date - A date value (ISO string, milliseconds, or Date).
|
|
260
|
+
* @returns {number} Milliseconds since the Unix epoch.
|
|
261
|
+
* @example
|
|
262
|
+
* ```yaml
|
|
263
|
+
* time:
|
|
264
|
+
* "@pipe":
|
|
265
|
+
* - ["{a.output.data.date}"]
|
|
266
|
+
* - ["{@date.getTime}"]
|
|
267
|
+
* ```
|
|
268
|
+
*/
|
|
65
269
|
getTime(date) {
|
|
66
270
|
return DateHandler.getDateInstance(date).getTime();
|
|
67
271
|
}
|
|
272
|
+
/**
|
|
273
|
+
* Returns the time zone difference, in minutes, from the current locale
|
|
274
|
+
* (host system settings) to UTC.
|
|
275
|
+
*
|
|
276
|
+
* @param {DateInput} date - A date value (ISO string, milliseconds, or Date).
|
|
277
|
+
* @returns {number} The timezone offset in minutes.
|
|
278
|
+
* @example
|
|
279
|
+
* ```yaml
|
|
280
|
+
* timezone_offset:
|
|
281
|
+
* "@pipe":
|
|
282
|
+
* - ["{a.output.data.date}"]
|
|
283
|
+
* - ["{@date.getTimezoneOffset}"]
|
|
284
|
+
* ```
|
|
285
|
+
*/
|
|
68
286
|
getTimezoneOffset(date) {
|
|
69
287
|
return DateHandler.getDateInstance(date).getTimezoneOffset();
|
|
70
288
|
}
|
|
289
|
+
/**
|
|
290
|
+
* Returns the day of the month (1--31) for the specified date according to
|
|
291
|
+
* universal time (UTC).
|
|
292
|
+
*
|
|
293
|
+
* @param {DateInput} date - A date value (ISO string, milliseconds, or Date).
|
|
294
|
+
* @returns {number} The UTC day of the month (1--31).
|
|
295
|
+
* @example
|
|
296
|
+
* ```yaml
|
|
297
|
+
* utc_day:
|
|
298
|
+
* "@pipe":
|
|
299
|
+
* - ["{a.output.data.date}"]
|
|
300
|
+
* - ["{@date.getUTCDate}"]
|
|
301
|
+
* ```
|
|
302
|
+
*/
|
|
71
303
|
getUTCDate(date) {
|
|
72
304
|
return DateHandler.getDateInstance(date).getUTCDate();
|
|
73
305
|
}
|
|
306
|
+
/**
|
|
307
|
+
* Returns the day of the week (0--6, where 0 is Sunday) for the specified
|
|
308
|
+
* date according to universal time (UTC).
|
|
309
|
+
*
|
|
310
|
+
* @param {DateInput} date - A date value (ISO string, milliseconds, or Date).
|
|
311
|
+
* @returns {number} The UTC day of the week (0 = Sunday, 6 = Saturday).
|
|
312
|
+
* @example
|
|
313
|
+
* ```yaml
|
|
314
|
+
* utc_weekday:
|
|
315
|
+
* "@pipe":
|
|
316
|
+
* - ["{a.output.data.date}"]
|
|
317
|
+
* - ["{@date.getUTCDay}"]
|
|
318
|
+
* ```
|
|
319
|
+
*/
|
|
74
320
|
getUTCDay(date) {
|
|
75
321
|
return DateHandler.getDateInstance(date).getUTCDay();
|
|
76
322
|
}
|
|
323
|
+
/**
|
|
324
|
+
* Returns the year of the specified date according to universal time (UTC).
|
|
325
|
+
*
|
|
326
|
+
* @param {DateInput} date - A date value (ISO string, milliseconds, or Date).
|
|
327
|
+
* @returns {number} The four-digit UTC year.
|
|
328
|
+
* @example
|
|
329
|
+
* ```yaml
|
|
330
|
+
* utc_year:
|
|
331
|
+
* "@pipe":
|
|
332
|
+
* - ["{a.output.data.date}"]
|
|
333
|
+
* - ["{@date.getUTCFullYear}"]
|
|
334
|
+
* ```
|
|
335
|
+
*/
|
|
77
336
|
getUTCFullYear(date) {
|
|
78
337
|
return DateHandler.getDateInstance(date).getUTCFullYear();
|
|
79
338
|
}
|
|
339
|
+
/**
|
|
340
|
+
* Returns the hours (0--23) of the specified date according to universal
|
|
341
|
+
* time (UTC).
|
|
342
|
+
*
|
|
343
|
+
* @param {DateInput} date - A date value (ISO string, milliseconds, or Date).
|
|
344
|
+
* @returns {number} The UTC hours (0--23).
|
|
345
|
+
* @example
|
|
346
|
+
* ```yaml
|
|
347
|
+
* utc_hours:
|
|
348
|
+
* "@pipe":
|
|
349
|
+
* - ["{a.output.data.date}"]
|
|
350
|
+
* - ["{@date.getUTCHours}"]
|
|
351
|
+
* ```
|
|
352
|
+
*/
|
|
80
353
|
getUTCHours(date) {
|
|
81
354
|
return DateHandler.getDateInstance(date).getUTCHours();
|
|
82
355
|
}
|
|
356
|
+
/**
|
|
357
|
+
* Returns the milliseconds (0--999) of the specified date according to
|
|
358
|
+
* universal time (UTC).
|
|
359
|
+
*
|
|
360
|
+
* @param {DateInput} date - A date value (ISO string, milliseconds, or Date).
|
|
361
|
+
* @returns {number} The UTC milliseconds (0--999).
|
|
362
|
+
* @example
|
|
363
|
+
* ```yaml
|
|
364
|
+
* utc_milliseconds:
|
|
365
|
+
* "@pipe":
|
|
366
|
+
* - ["{a.output.data.date}"]
|
|
367
|
+
* - ["{@date.getUTCMilliseconds}"]
|
|
368
|
+
* ```
|
|
369
|
+
*/
|
|
83
370
|
getUTCMilliseconds(date) {
|
|
84
371
|
return DateHandler.getDateInstance(date).getUTCMilliseconds();
|
|
85
372
|
}
|
|
373
|
+
/**
|
|
374
|
+
* Returns the minutes (0--59) of the specified date according to universal
|
|
375
|
+
* time (UTC).
|
|
376
|
+
*
|
|
377
|
+
* @param {DateInput} date - A date value (ISO string, milliseconds, or Date).
|
|
378
|
+
* @returns {number} The UTC minutes (0--59).
|
|
379
|
+
* @example
|
|
380
|
+
* ```yaml
|
|
381
|
+
* utc_minutes:
|
|
382
|
+
* "@pipe":
|
|
383
|
+
* - ["{a.output.data.date}"]
|
|
384
|
+
* - ["{@date.getUTCMinutes}"]
|
|
385
|
+
* ```
|
|
386
|
+
*/
|
|
86
387
|
getUTCMinutes(date) {
|
|
87
388
|
return DateHandler.getDateInstance(date).getUTCMinutes();
|
|
88
389
|
}
|
|
390
|
+
/**
|
|
391
|
+
* Returns the month (0--11) of the specified date according to universal
|
|
392
|
+
* time (UTC), where 0 is January and 11 is December.
|
|
393
|
+
*
|
|
394
|
+
* @param {DateInput} date - A date value (ISO string, milliseconds, or Date).
|
|
395
|
+
* @returns {number} The UTC month (0 = January, 11 = December).
|
|
396
|
+
* @example
|
|
397
|
+
* ```yaml
|
|
398
|
+
* utc_month:
|
|
399
|
+
* "@pipe":
|
|
400
|
+
* - ["{a.output.data.date}"]
|
|
401
|
+
* - ["{@date.getUTCMonth}"]
|
|
402
|
+
* ```
|
|
403
|
+
*/
|
|
89
404
|
getUTCMonth(date) {
|
|
90
405
|
return DateHandler.getDateInstance(date).getUTCMonth();
|
|
91
406
|
}
|
|
407
|
+
/**
|
|
408
|
+
* Returns the seconds (0--59) of the specified date according to universal
|
|
409
|
+
* time (UTC).
|
|
410
|
+
*
|
|
411
|
+
* @param {DateInput} date - A date value (ISO string, milliseconds, or Date).
|
|
412
|
+
* @returns {number} The UTC seconds (0--59).
|
|
413
|
+
* @example
|
|
414
|
+
* ```yaml
|
|
415
|
+
* utc_seconds:
|
|
416
|
+
* "@pipe":
|
|
417
|
+
* - ["{a.output.data.date}"]
|
|
418
|
+
* - ["{@date.getUTCSeconds}"]
|
|
419
|
+
* ```
|
|
420
|
+
*/
|
|
92
421
|
getUTCSeconds(date) {
|
|
93
422
|
return DateHandler.getDateInstance(date).getUTCSeconds();
|
|
94
423
|
}
|
|
424
|
+
/**
|
|
425
|
+
* Sets the milliseconds value (0--999) of a date object according to local
|
|
426
|
+
* time and returns the new timestamp in milliseconds.
|
|
427
|
+
*
|
|
428
|
+
* @param {DateInput} date - A date value (ISO string, milliseconds, or Date).
|
|
429
|
+
* @param {number} ms - The milliseconds value to set (0--999).
|
|
430
|
+
* @returns {number} The updated timestamp in milliseconds since epoch.
|
|
431
|
+
* @example
|
|
432
|
+
* ```yaml
|
|
433
|
+
* new_date:
|
|
434
|
+
* "@pipe":
|
|
435
|
+
* - ["{a.output.data.date}", 123]
|
|
436
|
+
* - ["{@date.setMilliseconds}"]
|
|
437
|
+
* ```
|
|
438
|
+
*/
|
|
95
439
|
setMilliseconds(date, ms) {
|
|
96
440
|
return DateHandler.getDateInstance(date).setMilliseconds(ms);
|
|
97
441
|
}
|
|
442
|
+
/**
|
|
443
|
+
* Sets the minutes value (0--59) of a date object according to local time,
|
|
444
|
+
* with optional seconds and milliseconds. Returns the new timestamp in
|
|
445
|
+
* milliseconds.
|
|
446
|
+
*
|
|
447
|
+
* @param {DateInput} date - A date value (ISO string, milliseconds, or Date).
|
|
448
|
+
* @param {number} minutes - The minutes value to set (0--59).
|
|
449
|
+
* @param {number} [seconds] - Optional seconds value to set (0--59).
|
|
450
|
+
* @param {number} [ms] - Optional milliseconds value to set (0--999).
|
|
451
|
+
* @returns {number} The updated timestamp in milliseconds since epoch.
|
|
452
|
+
* @example
|
|
453
|
+
* ```yaml
|
|
454
|
+
* new_date:
|
|
455
|
+
* "@pipe":
|
|
456
|
+
* - ["{a.output.data.date}", 45, 30]
|
|
457
|
+
* - ["{@date.setMinutes}"]
|
|
458
|
+
* ```
|
|
459
|
+
*/
|
|
98
460
|
setMinutes(date, minutes, seconds, ms) {
|
|
99
461
|
return DateHandler.getDateInstance(date).setMinutes(minutes, seconds, ms);
|
|
100
462
|
}
|
|
463
|
+
/**
|
|
464
|
+
* Sets the month value (0--11) of a date object according to local time,
|
|
465
|
+
* with an optional day of the month. Returns the new timestamp in
|
|
466
|
+
* milliseconds.
|
|
467
|
+
*
|
|
468
|
+
* @param {DateInput} date - A date value (ISO string, milliseconds, or Date).
|
|
469
|
+
* @param {number} month - The month value to set (0 = January, 11 = December).
|
|
470
|
+
* @param {number} [day] - Optional day of the month to set (1--31).
|
|
471
|
+
* @returns {number} The updated timestamp in milliseconds since epoch.
|
|
472
|
+
* @example
|
|
473
|
+
* ```yaml
|
|
474
|
+
* new_date:
|
|
475
|
+
* "@pipe":
|
|
476
|
+
* - ["{a.output.data.date}", 7, 15]
|
|
477
|
+
* - ["{@date.setMonth}"]
|
|
478
|
+
* ```
|
|
479
|
+
*/
|
|
101
480
|
setMonth(date, month, day) {
|
|
102
481
|
return DateHandler.getDateInstance(date).setMonth(month, day);
|
|
103
482
|
}
|
|
483
|
+
/**
|
|
484
|
+
* Sets the seconds value (0--59) of a date object according to local time,
|
|
485
|
+
* with optional milliseconds. Returns the new timestamp in milliseconds.
|
|
486
|
+
*
|
|
487
|
+
* @param {DateInput} date - A date value (ISO string, milliseconds, or Date).
|
|
488
|
+
* @param {number} seconds - The seconds value to set (0--59).
|
|
489
|
+
* @param {number} [ms] - Optional milliseconds value to set (0--999).
|
|
490
|
+
* @returns {number} The updated timestamp in milliseconds since epoch.
|
|
491
|
+
* @example
|
|
492
|
+
* ```yaml
|
|
493
|
+
* new_date:
|
|
494
|
+
* "@pipe":
|
|
495
|
+
* - ["{a.output.data.date}", 30, 123]
|
|
496
|
+
* - ["{@date.setSeconds}"]
|
|
497
|
+
* ```
|
|
498
|
+
*/
|
|
104
499
|
setSeconds(date, seconds, ms) {
|
|
105
500
|
return DateHandler.getDateInstance(date).setSeconds(seconds, ms);
|
|
106
501
|
}
|
|
502
|
+
/**
|
|
503
|
+
* Sets the date object to the time represented by the number of
|
|
504
|
+
* milliseconds since January 1, 1970, 00:00:00 UTC. Returns the new
|
|
505
|
+
* timestamp.
|
|
506
|
+
*
|
|
507
|
+
* @param {DateInput} date - A date value (ISO string, milliseconds, or Date).
|
|
508
|
+
* @param {number} time - The number of milliseconds since the Unix epoch.
|
|
509
|
+
* @returns {number} The updated timestamp in milliseconds since epoch.
|
|
510
|
+
* @example
|
|
511
|
+
* ```yaml
|
|
512
|
+
* new_date:
|
|
513
|
+
* "@pipe":
|
|
514
|
+
* - ["{a.output.data.date}", 1620000000000]
|
|
515
|
+
* - ["{@date.setTime}"]
|
|
516
|
+
* ```
|
|
517
|
+
*/
|
|
107
518
|
setTime(date, time) {
|
|
108
519
|
return DateHandler.getDateInstance(date).setTime(time);
|
|
109
520
|
}
|
|
521
|
+
/**
|
|
522
|
+
* Sets the day of the month (1--31) of a date object according to
|
|
523
|
+
* universal time (UTC). Returns the new timestamp in milliseconds.
|
|
524
|
+
*
|
|
525
|
+
* @param {DateInput} date - A date value (ISO string, milliseconds, or Date).
|
|
526
|
+
* @param {number} day - The UTC day of the month to set (1--31).
|
|
527
|
+
* @returns {number} The updated timestamp in milliseconds since epoch.
|
|
528
|
+
* @example
|
|
529
|
+
* ```yaml
|
|
530
|
+
* new_date:
|
|
531
|
+
* "@pipe":
|
|
532
|
+
* - ["{a.output.data.date}", 15]
|
|
533
|
+
* - ["{@date.setUTCDate}"]
|
|
534
|
+
* ```
|
|
535
|
+
*/
|
|
110
536
|
setUTCDate(date, day) {
|
|
111
537
|
return DateHandler.getDateInstance(date).setUTCDate(day);
|
|
112
538
|
}
|
|
539
|
+
/**
|
|
540
|
+
* Sets the full year of a date object according to universal time (UTC),
|
|
541
|
+
* with optional month and day parameters. Returns the new timestamp in
|
|
542
|
+
* milliseconds.
|
|
543
|
+
*
|
|
544
|
+
* @param {DateInput} date - A date value (ISO string, milliseconds, or Date).
|
|
545
|
+
* @param {number} year - The UTC full year value to set.
|
|
546
|
+
* @param {number} [month] - Optional UTC month to set (0--11).
|
|
547
|
+
* @param {number} [day] - Optional UTC day of the month to set (1--31).
|
|
548
|
+
* @returns {number} The updated timestamp in milliseconds since epoch.
|
|
549
|
+
* @example
|
|
550
|
+
* ```yaml
|
|
551
|
+
* new_date:
|
|
552
|
+
* "@pipe":
|
|
553
|
+
* - ["{a.output.data.date}", 2025]
|
|
554
|
+
* - ["{@date.setUTCFullYear}"]
|
|
555
|
+
* ```
|
|
556
|
+
*/
|
|
113
557
|
setUTCFullYear(date, year, month, day) {
|
|
114
558
|
return DateHandler.getDateInstance(date).setUTCFullYear(year, month, day);
|
|
115
559
|
}
|
|
560
|
+
/**
|
|
561
|
+
* Sets the hours (0--23) of a date object according to universal time
|
|
562
|
+
* (UTC), with optional minutes, seconds, and milliseconds. Returns the new
|
|
563
|
+
* timestamp in milliseconds.
|
|
564
|
+
*
|
|
565
|
+
* @param {DateInput} date - A date value (ISO string, milliseconds, or Date).
|
|
566
|
+
* @param {number} hours - The UTC hours value to set (0--23).
|
|
567
|
+
* @param {number} [minutes] - Optional UTC minutes to set (0--59).
|
|
568
|
+
* @param {number} [seconds] - Optional UTC seconds to set (0--59).
|
|
569
|
+
* @param {number} [ms] - Optional UTC milliseconds to set (0--999).
|
|
570
|
+
* @returns {number} The updated timestamp in milliseconds since epoch.
|
|
571
|
+
* @example
|
|
572
|
+
* ```yaml
|
|
573
|
+
* new_date:
|
|
574
|
+
* "@pipe":
|
|
575
|
+
* - ["{a.output.data.date}", 18]
|
|
576
|
+
* - ["{@date.setUTCHours}"]
|
|
577
|
+
* ```
|
|
578
|
+
*/
|
|
116
579
|
setUTCHours(date, hours, minutes, seconds, ms) {
|
|
117
580
|
return DateHandler.getDateInstance(date).setUTCHours(hours, minutes, seconds, ms);
|
|
118
581
|
}
|
|
582
|
+
/**
|
|
583
|
+
* Sets the milliseconds value (0--999) of a date object according to
|
|
584
|
+
* universal time (UTC). Returns the new timestamp in milliseconds.
|
|
585
|
+
*
|
|
586
|
+
* @param {DateInput} date - A date value (ISO string, milliseconds, or Date).
|
|
587
|
+
* @param {number} ms - The UTC milliseconds value to set (0--999).
|
|
588
|
+
* @returns {number} The updated timestamp in milliseconds since epoch.
|
|
589
|
+
* @example
|
|
590
|
+
* ```yaml
|
|
591
|
+
* new_date:
|
|
592
|
+
* "@pipe":
|
|
593
|
+
* - ["{a.output.data.date}", 500]
|
|
594
|
+
* - ["{@date.setUTCMilliseconds}"]
|
|
595
|
+
* ```
|
|
596
|
+
*/
|
|
119
597
|
setUTCMilliseconds(date, ms) {
|
|
120
598
|
return DateHandler.getDateInstance(date).setUTCMilliseconds(ms);
|
|
121
599
|
}
|
|
600
|
+
/**
|
|
601
|
+
* Sets the minutes value (0--59) of a date object according to universal
|
|
602
|
+
* time (UTC), with optional seconds and milliseconds. Returns the new
|
|
603
|
+
* timestamp in milliseconds.
|
|
604
|
+
*
|
|
605
|
+
* @param {DateInput} date - A date value (ISO string, milliseconds, or Date).
|
|
606
|
+
* @param {number} minutes - The UTC minutes value to set (0--59).
|
|
607
|
+
* @param {number} [seconds] - Optional UTC seconds to set (0--59).
|
|
608
|
+
* @param {number} [ms] - Optional UTC milliseconds to set (0--999).
|
|
609
|
+
* @returns {number} The updated timestamp in milliseconds since epoch.
|
|
610
|
+
* @example
|
|
611
|
+
* ```yaml
|
|
612
|
+
* new_date:
|
|
613
|
+
* "@pipe":
|
|
614
|
+
* - ["{a.output.data.date}", 45]
|
|
615
|
+
* - ["{@date.setUTCMinutes}"]
|
|
616
|
+
* ```
|
|
617
|
+
*/
|
|
122
618
|
setUTCMinutes(date, minutes, seconds, ms) {
|
|
123
619
|
return DateHandler.getDateInstance(date).setUTCMinutes(minutes, seconds, ms);
|
|
124
620
|
}
|
|
621
|
+
/**
|
|
622
|
+
* Sets the month value (0--11) of a date object according to universal
|
|
623
|
+
* time (UTC), with an optional day parameter. Returns the new timestamp in
|
|
624
|
+
* milliseconds.
|
|
625
|
+
*
|
|
626
|
+
* @param {DateInput} date - A date value (ISO string, milliseconds, or Date).
|
|
627
|
+
* @param {number} month - The UTC month value to set (0 = January, 11 = December).
|
|
628
|
+
* @param {number} [day] - Optional UTC day of the month to set (1--31).
|
|
629
|
+
* @returns {number} The updated timestamp in milliseconds since epoch.
|
|
630
|
+
* @example
|
|
631
|
+
* ```yaml
|
|
632
|
+
* new_date:
|
|
633
|
+
* "@pipe":
|
|
634
|
+
* - ["{a.output.data.date}", 2]
|
|
635
|
+
* - ["{@date.setUTCMonth}"]
|
|
636
|
+
* ```
|
|
637
|
+
*/
|
|
125
638
|
setUTCMonth(date, month, day) {
|
|
126
639
|
return DateHandler.getDateInstance(date).setUTCMonth(month, day);
|
|
127
640
|
}
|
|
641
|
+
/**
|
|
642
|
+
* Sets the seconds value (0--59) of a date object according to universal
|
|
643
|
+
* time (UTC), with an optional milliseconds parameter. Returns the new
|
|
644
|
+
* timestamp in milliseconds.
|
|
645
|
+
*
|
|
646
|
+
* @param {DateInput} date - A date value (ISO string, milliseconds, or Date).
|
|
647
|
+
* @param {number} seconds - The UTC seconds value to set (0--59).
|
|
648
|
+
* @param {number} [ms] - Optional UTC milliseconds to set (0--999).
|
|
649
|
+
* @returns {number} The updated timestamp in milliseconds since epoch.
|
|
650
|
+
* @example
|
|
651
|
+
* ```yaml
|
|
652
|
+
* new_date:
|
|
653
|
+
* "@pipe":
|
|
654
|
+
* - ["{a.output.data.date}", 30]
|
|
655
|
+
* - ["{@date.setUTCSeconds}"]
|
|
656
|
+
* ```
|
|
657
|
+
*/
|
|
128
658
|
setUTCSeconds(date, seconds, ms) {
|
|
129
659
|
return DateHandler.getDateInstance(date).setUTCSeconds(seconds, ms);
|
|
130
660
|
}
|
|
661
|
+
/**
|
|
662
|
+
* Sets the day of the month (1--31) of a date object according to local
|
|
663
|
+
* time. Returns the new timestamp in milliseconds.
|
|
664
|
+
*
|
|
665
|
+
* @param {DateInput} date - A date value (ISO string, milliseconds, or Date).
|
|
666
|
+
* @param {number} day - The day of the month to set (1--31).
|
|
667
|
+
* @returns {number} The updated timestamp in milliseconds since epoch.
|
|
668
|
+
* @example
|
|
669
|
+
* ```yaml
|
|
670
|
+
* new_date:
|
|
671
|
+
* "@pipe":
|
|
672
|
+
* - ["{a.output.data.date}", 15]
|
|
673
|
+
* - ["{@date.setDate}"]
|
|
674
|
+
* ```
|
|
675
|
+
*/
|
|
131
676
|
setDate(date, day) {
|
|
132
677
|
return DateHandler.getDateInstance(date).setDate(day);
|
|
133
678
|
}
|
|
679
|
+
/**
|
|
680
|
+
* Sets the full year of a date object according to local time, with
|
|
681
|
+
* optional month and day parameters. Returns the new timestamp in
|
|
682
|
+
* milliseconds.
|
|
683
|
+
*
|
|
684
|
+
* @param {DateInput} date - A date value (ISO string, milliseconds, or Date).
|
|
685
|
+
* @param {number} year - The full year value to set.
|
|
686
|
+
* @param {number} [month] - Optional month to set (0--11).
|
|
687
|
+
* @param {number} [day] - Optional day of the month to set (1--31).
|
|
688
|
+
* @returns {number} The updated timestamp in milliseconds since epoch.
|
|
689
|
+
* @example
|
|
690
|
+
* ```yaml
|
|
691
|
+
* new_date:
|
|
692
|
+
* "@pipe":
|
|
693
|
+
* - ["{a.output.data.date}", 2024]
|
|
694
|
+
* - ["{@date.setFullYear}"]
|
|
695
|
+
* ```
|
|
696
|
+
*/
|
|
134
697
|
setFullYear(date, year, month, day) {
|
|
135
698
|
return DateHandler.getDateInstance(date).setFullYear(year, month, day);
|
|
136
699
|
}
|
|
700
|
+
/**
|
|
701
|
+
* Sets the hours (0--23) of a date object according to local time, with
|
|
702
|
+
* optional minutes, seconds, and milliseconds. Returns the new timestamp
|
|
703
|
+
* in milliseconds.
|
|
704
|
+
*
|
|
705
|
+
* @param {DateInput} date - A date value (ISO string, milliseconds, or Date).
|
|
706
|
+
* @param {number} hours - The hours value to set (0--23).
|
|
707
|
+
* @param {number} [minutes] - Optional minutes to set (0--59).
|
|
708
|
+
* @param {number} [seconds] - Optional seconds to set (0--59).
|
|
709
|
+
* @param {number} [ms] - Optional milliseconds to set (0--999).
|
|
710
|
+
* @returns {number} The updated timestamp in milliseconds since epoch.
|
|
711
|
+
* @example
|
|
712
|
+
* ```yaml
|
|
713
|
+
* new_date:
|
|
714
|
+
* "@pipe":
|
|
715
|
+
* - ["{a.output.data.date}", 15]
|
|
716
|
+
* - ["{@date.setHours}"]
|
|
717
|
+
* ```
|
|
718
|
+
*/
|
|
137
719
|
setHours(date, hours, minutes, seconds, ms) {
|
|
138
720
|
return DateHandler.getDateInstance(date).setHours(hours, minutes, seconds, ms);
|
|
139
721
|
}
|
|
722
|
+
/**
|
|
723
|
+
* Returns the date portion of a date object in a human-readable form as a
|
|
724
|
+
* string (e.g., `"Sun Apr 23 2023"`).
|
|
725
|
+
*
|
|
726
|
+
* @param {DateInput} date - A date value (ISO string, milliseconds, or Date).
|
|
727
|
+
* @returns {string} The date portion as a human-readable string.
|
|
728
|
+
* @example
|
|
729
|
+
* ```yaml
|
|
730
|
+
* date_string:
|
|
731
|
+
* "@pipe":
|
|
732
|
+
* - ["{a.output.data.date}"]
|
|
733
|
+
* - ["{@date.toDateString}"]
|
|
734
|
+
* ```
|
|
735
|
+
*/
|
|
140
736
|
toDateString(date) {
|
|
141
737
|
return DateHandler.getDateInstance(date).toDateString();
|
|
142
738
|
}
|
|
739
|
+
/**
|
|
740
|
+
* Returns the date object as a string in ISO 8601 format
|
|
741
|
+
* (e.g., `"2023-04-23T12:34:56.000Z"`).
|
|
742
|
+
*
|
|
743
|
+
* @param {DateInput} date - A date value (ISO string, milliseconds, or Date).
|
|
744
|
+
* @returns {string} The date as an ISO 8601 string.
|
|
745
|
+
* @example
|
|
746
|
+
* ```yaml
|
|
747
|
+
* iso_date:
|
|
748
|
+
* "@pipe":
|
|
749
|
+
* - ["{a.output.data.date}"]
|
|
750
|
+
* - ["{@date.toISOString}"]
|
|
751
|
+
* ```
|
|
752
|
+
*/
|
|
143
753
|
toISOString(date) {
|
|
144
754
|
return DateHandler.getDateInstance(date).toISOString();
|
|
145
755
|
}
|
|
756
|
+
/**
|
|
757
|
+
* Returns an ISO date (or current date if none provided) as a string
|
|
758
|
+
* formatted as a compact decimal (e.g., `"20240423123456.789"`). This is
|
|
759
|
+
* useful for sorting dates in string format while keeping the output more
|
|
760
|
+
* human-friendly than `date.valueOf`. Uses the `formatISODate` utility
|
|
761
|
+
* internally.
|
|
762
|
+
*
|
|
763
|
+
* @param {DateInput} [date] - Optional date value (ISO string, milliseconds, or Date). Defaults to now.
|
|
764
|
+
* @returns {string} The date formatted as a compact decimal string.
|
|
765
|
+
* @example
|
|
766
|
+
* ```yaml
|
|
767
|
+
* formatted_date:
|
|
768
|
+
* "@pipe":
|
|
769
|
+
* - ["{a.output.data.date}"]
|
|
770
|
+
* - ["{@date.toISOXString}"]
|
|
771
|
+
* ```
|
|
772
|
+
*/
|
|
146
773
|
toISOXString(date) {
|
|
147
774
|
return (0, utils_1.formatISODate)(date ? DateHandler.getDateInstance(date) : new Date());
|
|
148
775
|
}
|
|
776
|
+
/**
|
|
777
|
+
* Returns the date object as a string in a JSON-compatible format, which
|
|
778
|
+
* is similar to the ISO 8601 format.
|
|
779
|
+
*
|
|
780
|
+
* @param {DateInput} date - A date value (ISO string, milliseconds, or Date).
|
|
781
|
+
* @returns {string} The date as a JSON-compatible string.
|
|
782
|
+
* @example
|
|
783
|
+
* ```yaml
|
|
784
|
+
* json_date:
|
|
785
|
+
* "@pipe":
|
|
786
|
+
* - ["{a.output.data.date}"]
|
|
787
|
+
* - ["{@date.toJSON}"]
|
|
788
|
+
* ```
|
|
789
|
+
*/
|
|
149
790
|
toJSON(date) {
|
|
150
791
|
return DateHandler.getDateInstance(date).toJSON();
|
|
151
792
|
}
|
|
793
|
+
/**
|
|
794
|
+
* Returns the date object as a string formatted according to the given
|
|
795
|
+
* locale(s) and formatting options, showing only the date portion.
|
|
796
|
+
*
|
|
797
|
+
* @param {DateInput} date - A date value (ISO string, milliseconds, or Date).
|
|
798
|
+
* @param {string | string[]} [locales] - Optional locale string or array of locale strings (e.g., `"en-US"`).
|
|
799
|
+
* @param {Intl.DateTimeFormatOptions} [options] - Optional formatting options.
|
|
800
|
+
* @returns {string} The localized date string.
|
|
801
|
+
* @example
|
|
802
|
+
* ```yaml
|
|
803
|
+
* localized_date:
|
|
804
|
+
* "@pipe":
|
|
805
|
+
* - ["{a.output.data.date}", "en-US"]
|
|
806
|
+
* - ["{@date.toLocaleDateString}"]
|
|
807
|
+
* ```
|
|
808
|
+
*/
|
|
152
809
|
toLocaleDateString(date, locales, options) {
|
|
153
810
|
return DateHandler.getDateInstance(date).toLocaleDateString(locales, options);
|
|
154
811
|
}
|
|
812
|
+
/**
|
|
813
|
+
* Returns the date object as a string formatted according to the given
|
|
814
|
+
* locale(s) and formatting options, including both date and time portions.
|
|
815
|
+
*
|
|
816
|
+
* @param {DateInput} date - A date value (ISO string, milliseconds, or Date).
|
|
817
|
+
* @param {string | string[]} [locales] - Optional locale string or array of locale strings (e.g., `"en-US"`).
|
|
818
|
+
* @param {Intl.DateTimeFormatOptions} [options] - Optional formatting options.
|
|
819
|
+
* @returns {string} The localized date and time string.
|
|
820
|
+
* @example
|
|
821
|
+
* ```yaml
|
|
822
|
+
* localized_date_time:
|
|
823
|
+
* "@pipe":
|
|
824
|
+
* - ["{a.output.data.date}", "en-US"]
|
|
825
|
+
* - ["{@date.toLocaleString}"]
|
|
826
|
+
* ```
|
|
827
|
+
*/
|
|
155
828
|
toLocaleString(date, locales, options) {
|
|
156
829
|
return DateHandler.getDateInstance(date).toLocaleString(locales, options);
|
|
157
830
|
}
|
|
831
|
+
/**
|
|
832
|
+
* Returns the time portion of a date object as a string formatted
|
|
833
|
+
* according to the given locale(s) and formatting options.
|
|
834
|
+
*
|
|
835
|
+
* @param {DateInput} date - A date value (ISO string, milliseconds, or Date).
|
|
836
|
+
* @param {string | string[]} [locales] - Optional locale string or array of locale strings (e.g., `"en-US"`).
|
|
837
|
+
* @param {Intl.DateTimeFormatOptions} [options] - Optional formatting options.
|
|
838
|
+
* @returns {string} The localized time string.
|
|
839
|
+
* @example
|
|
840
|
+
* ```yaml
|
|
841
|
+
* localized_time:
|
|
842
|
+
* "@pipe":
|
|
843
|
+
* - ["{a.output.data.date}", "en-US"]
|
|
844
|
+
* - ["{@date.toLocaleTimeString}"]
|
|
845
|
+
* ```
|
|
846
|
+
*/
|
|
158
847
|
toLocaleTimeString(date, locales, options) {
|
|
159
848
|
return DateHandler.getDateInstance(date).toLocaleTimeString(locales, options);
|
|
160
849
|
}
|
|
850
|
+
/**
|
|
851
|
+
* Converts a date object to a string using the default formatting for the
|
|
852
|
+
* local time zone.
|
|
853
|
+
*
|
|
854
|
+
* @param {DateInput} date - A date value (ISO string, milliseconds, or Date).
|
|
855
|
+
* @returns {string} The date and time as a string in the local time zone.
|
|
856
|
+
* @example
|
|
857
|
+
* ```yaml
|
|
858
|
+
* date_string:
|
|
859
|
+
* "@pipe":
|
|
860
|
+
* - ["{a.output.data.date}"]
|
|
861
|
+
* - ["{@date.toString}"]
|
|
862
|
+
* ```
|
|
863
|
+
*/
|
|
161
864
|
toString(date) {
|
|
162
865
|
return DateHandler.getDateInstance(date).toString();
|
|
163
866
|
}
|
|
867
|
+
/**
|
|
868
|
+
* Returns the number of milliseconds since January 1, 1970, 00:00:00 UTC
|
|
869
|
+
* for the given date components. Accepts between two and seven parameters.
|
|
870
|
+
*
|
|
871
|
+
* @param {number} year - The full year (e.g., 2023).
|
|
872
|
+
* @param {number} month - The month (0 = January, 11 = December).
|
|
873
|
+
* @param {number} [date] - Optional day of the month (1--31).
|
|
874
|
+
* @param {number} [hours] - Optional hours (0--23).
|
|
875
|
+
* @param {number} [minutes] - Optional minutes (0--59).
|
|
876
|
+
* @param {number} [seconds] - Optional seconds (0--59).
|
|
877
|
+
* @param {number} [ms] - Optional milliseconds (0--999).
|
|
878
|
+
* @returns {number} Milliseconds since the Unix epoch for the given UTC date components.
|
|
879
|
+
* @example
|
|
880
|
+
* ```yaml
|
|
881
|
+
* milliseconds_since_epoch:
|
|
882
|
+
* "@pipe":
|
|
883
|
+
* - ["{a.output.data.year}", "{a.output.data.month}", "{a.output.data.day}"]
|
|
884
|
+
* - ["{@date.UTC}"]
|
|
885
|
+
* ```
|
|
886
|
+
*/
|
|
164
887
|
UTC(year, month, date, hours, minutes, seconds, ms) {
|
|
165
888
|
return Date.UTC(year, month, date, hours, minutes, seconds, ms);
|
|
166
889
|
}
|
|
890
|
+
/**
|
|
891
|
+
* Returns the numeric value of the specified date object as the number of
|
|
892
|
+
* milliseconds since January 1, 1970, 00:00:00 UTC.
|
|
893
|
+
*
|
|
894
|
+
* @param {DateInput} date - A date value (ISO string, milliseconds, or Date).
|
|
895
|
+
* @returns {number} Milliseconds since the Unix epoch.
|
|
896
|
+
* @example
|
|
897
|
+
* ```yaml
|
|
898
|
+
* milliseconds_since_epoch:
|
|
899
|
+
* "@pipe":
|
|
900
|
+
* - ["{a.output.data.date}"]
|
|
901
|
+
* - ["{@date.valueOf}"]
|
|
902
|
+
* ```
|
|
903
|
+
*/
|
|
167
904
|
valueOf(date) {
|
|
168
905
|
return DateHandler.getDateInstance(date).valueOf();
|
|
169
906
|
}
|