@trackunit/date-and-time-utils 1.6.5 → 1.6.10
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/index.cjs.js +33 -29
- package/index.esm.js +33 -29
- package/package.json +2 -2
- package/src/DateAndTimeUtils.d.ts +34 -29
package/index.cjs.js
CHANGED
|
@@ -149,7 +149,7 @@ const formatRangeUtil = (range, locale, format) => Intl.DateTimeFormat(locale, f
|
|
|
149
149
|
* @param {TemporalDate} date - The temporal date from which to subtract minutes.
|
|
150
150
|
* @param {number} amount - The number of minutes to subtract.
|
|
151
151
|
* @param {string} [timeZone] - The time zone to use for the subtraction. If not provided, the system's default time zone will be used.
|
|
152
|
-
* @returns {
|
|
152
|
+
* @returns {TemporalZonedDateTime} The resulting temporal date after subtracting the specified number of minutes.
|
|
153
153
|
* @example
|
|
154
154
|
* const dateString = "2023-05-10T10:30:00.000Z"
|
|
155
155
|
* const date = new Date(dateString);
|
|
@@ -166,7 +166,7 @@ const subtractMinutesUtil = (date, amount, timeZone) => {
|
|
|
166
166
|
* @param {TemporalDate} date - The temporal date from which to subtract hours.
|
|
167
167
|
* @param {number} amount - The number of hours to subtract.
|
|
168
168
|
* @param {string} [timeZone] - The time zone to use for the subtraction. If not provided, the system's default time zone will be used.
|
|
169
|
-
* @returns {
|
|
169
|
+
* @returns {TemporalZonedDateTime} The resulting temporal date after subtracting the specified number of hours.
|
|
170
170
|
* @example
|
|
171
171
|
* const dateString = "2023-05-10T10:30:00.000Z"
|
|
172
172
|
* const date = new Date(dateString);
|
|
@@ -183,7 +183,7 @@ const subtractHoursUtil = (date, amount, timeZone) => {
|
|
|
183
183
|
* @param {TemporalDate} date - The temporal date from which to subtract days.
|
|
184
184
|
* @param {number} amount - The number of days to subtract.
|
|
185
185
|
* @param {string} [timeZone] - The time zone to use for the subtraction. If not provided, the system's default time zone will be used.
|
|
186
|
-
* @returns {
|
|
186
|
+
* @returns {TemporalZonedDateTime} The resulting temporal date after subtracting the specified number of days.
|
|
187
187
|
* @example
|
|
188
188
|
* const dateString = "2023-05-10"
|
|
189
189
|
* const date = new Date(dateString);
|
|
@@ -200,7 +200,7 @@ const subtractDaysUtil = (date, amount, timeZone) => {
|
|
|
200
200
|
* @param {TemporalDate} date - The temporal date from which to subtract weeks.
|
|
201
201
|
* @param {number} amount - The number of weeks to subtract.
|
|
202
202
|
* @param {string} [timeZone] - The time zone to use for the subtraction. If not provided, the system's default time zone will be used.
|
|
203
|
-
* @returns {
|
|
203
|
+
* @returns {TemporalZonedDateTime} The resulting temporal date after subtracting the specified number of weeks.
|
|
204
204
|
* @example
|
|
205
205
|
* const dateString = "2023-05-10"
|
|
206
206
|
* const date = new Date(dateString);
|
|
@@ -217,7 +217,7 @@ const subtractWeeksUtil = (date, amount, timeZone) => {
|
|
|
217
217
|
* @param {TemporalDate} date - The temporal date from which to subtract months.
|
|
218
218
|
* @param {number} amount - The number of months to subtract.
|
|
219
219
|
* @param {string} [timeZone] - The time zone to use for the subtraction. If not provided, the system's default time zone will be used.
|
|
220
|
-
* @returns {
|
|
220
|
+
* @returns {TemporalZonedDateTime} The resulting temporal date after subtracting the specified number of months.
|
|
221
221
|
* @example
|
|
222
222
|
* const dateString = "2023-05-10"
|
|
223
223
|
* const date = new Date(dateString);
|
|
@@ -234,7 +234,7 @@ const subtractMonthsUtil = (date, amount, timeZone) => {
|
|
|
234
234
|
* @param {TemporalDate} date - The temporal date from which to subtract years.
|
|
235
235
|
* @param {number} amount - The number of years to subtract.
|
|
236
236
|
* @param {string} [timeZone] - The time zone to use for the subtraction. If not provided, the system's default time zone will be used.
|
|
237
|
-
* @returns {
|
|
237
|
+
* @returns {TemporalZonedDateTime} The resulting temporal date after subtracting the specified number of years.
|
|
238
238
|
* @example
|
|
239
239
|
* const dateString = "2023-05-10"
|
|
240
240
|
* const date = new Date(dateString);
|
|
@@ -251,7 +251,7 @@ const subtractYearsUtil = (date, amount, timeZone) => {
|
|
|
251
251
|
* @param {TemporalDate} date - The temporal date to which minutes will be added.
|
|
252
252
|
* @param {number} amount - The number of minutes to add.
|
|
253
253
|
* @param {string} [timeZone] - The time zone to use for the addition. If not provided, the system's default time zone will be used.
|
|
254
|
-
* @returns {
|
|
254
|
+
* @returns {TemporalZonedDateTime} The resulting temporal date after adding the specified number of minutes.
|
|
255
255
|
* @example
|
|
256
256
|
* const dateString = "2023-05-10"
|
|
257
257
|
* const date = new Date(dateString);
|
|
@@ -268,7 +268,7 @@ const addMinutesUtil = (date, amount, timeZone) => {
|
|
|
268
268
|
* @param {TemporalDate} date - The temporal date to which hours will be added.
|
|
269
269
|
* @param {number} amount - The number of hours to add.
|
|
270
270
|
* @param {string} [timeZone] - The time zone to use for the addition. If not provided, the system's default time zone will be used.
|
|
271
|
-
* @returns {
|
|
271
|
+
* @returns {TemporalZonedDateTime} The resulting temporal date after adding the specified number of hours.
|
|
272
272
|
* @example
|
|
273
273
|
* const dateString = "2023-05-10"
|
|
274
274
|
* const date = new Date(dateString);
|
|
@@ -285,7 +285,7 @@ const addHoursUtil = (date, amount, timeZone) => {
|
|
|
285
285
|
* @param {TemporalDate} date - The temporal date to which days will be added.
|
|
286
286
|
* @param {number} amount - The number of days to add.
|
|
287
287
|
* @param {string} [timeZone] - The time zone to use for the addition. If not provided, the system's default time zone will be used.
|
|
288
|
-
* @returns {
|
|
288
|
+
* @returns {TemporalZonedDateTime} The resulting temporal date after adding the specified number of days.
|
|
289
289
|
* @example
|
|
290
290
|
* const dateString = "2023-05-10"
|
|
291
291
|
* const date = new Date(dateString);
|
|
@@ -302,7 +302,7 @@ const addDaysUtil = (date, amount, timeZone) => {
|
|
|
302
302
|
* @param {TemporalDate} date - The temporal date to which weeks will be added.
|
|
303
303
|
* @param {number} amount - The number of weeks to add.
|
|
304
304
|
* @param {string} [timeZone] - The time zone to use for the addition. If not provided, the system's default time zone will be used.
|
|
305
|
-
* @returns {
|
|
305
|
+
* @returns {TemporalZonedDateTime} The resulting temporal date after adding the specified number of weeks.
|
|
306
306
|
* @example
|
|
307
307
|
* const dateString = "2023-05-10"
|
|
308
308
|
* const date = new Date(dateString);
|
|
@@ -319,7 +319,7 @@ const addWeeksUtil = (date, amount, timeZone) => {
|
|
|
319
319
|
* @param {TemporalDate} date - The temporal date to which months will be added.
|
|
320
320
|
* @param {number} amount - The number of months to add.
|
|
321
321
|
* @param {string} [timeZone] - The time zone to use for the addition. If not provided, the system's default time zone will be used.
|
|
322
|
-
* @returns {
|
|
322
|
+
* @returns {TemporalZonedDateTime} The resulting temporal date after adding the specified number of months.
|
|
323
323
|
* @example
|
|
324
324
|
* const dateString = "2023-05-10"
|
|
325
325
|
* const date = new Date(dateString);
|
|
@@ -336,7 +336,7 @@ const addMonthsUtil = (date, amount, timeZone) => {
|
|
|
336
336
|
* @param {TemporalDate} date - The temporal date to which years will be added.
|
|
337
337
|
* @param {number} amount - The number of years to add.
|
|
338
338
|
* @param {string} [timeZone] - The time zone to use for the addition. If not provided, the system's default time zone will be used.
|
|
339
|
-
* @returns {
|
|
339
|
+
* @returns {TemporalZonedDateTime} The resulting temporal date after adding the specified number of years.
|
|
340
340
|
* @example
|
|
341
341
|
* const dateString = "2023-05-10"
|
|
342
342
|
* const date = new Date(dateString);
|
|
@@ -352,7 +352,7 @@ const addYearsUtil = (date, amount, timeZone) => {
|
|
|
352
352
|
*
|
|
353
353
|
* @param {TemporalDate} date - The temporal date for which to determine the start of the minute.
|
|
354
354
|
* @param {string} [timeZone] - The time zone to use for determining the start of the minute. If not provided, the system's default time zone will be used.
|
|
355
|
-
* @returns {
|
|
355
|
+
* @returns {TemporalZonedDateTime} The temporal date representing the start of the minute.
|
|
356
356
|
* @example
|
|
357
357
|
* const dateString = "2023-05-10T10:30:10.000Z"
|
|
358
358
|
* const date = new Date(dateString);
|
|
@@ -367,7 +367,7 @@ const startOfMinuteUtil = (date, timeZone) => {
|
|
|
367
367
|
*
|
|
368
368
|
* @param {TemporalDate} date - The temporal date for which to determine the end of the minute.
|
|
369
369
|
* @param {string} [timeZone] - The time zone to use for determining the end of the minute. If not provided, the system's default time zone will be used.
|
|
370
|
-
* @returns {
|
|
370
|
+
* @returns {TemporalZonedDateTime} The temporal date representing the end of the minute.
|
|
371
371
|
* @example
|
|
372
372
|
* const dateString = "2023-05-10T10:30:10.000Z"
|
|
373
373
|
* const date = new Date(dateString);
|
|
@@ -385,7 +385,7 @@ const endOfMinuteUtil = (date, timeZone) => {
|
|
|
385
385
|
*
|
|
386
386
|
* @param {TemporalDate} date - The temporal date for which to determine the start of the hour.
|
|
387
387
|
* @param {string} [timeZone] - The time zone to use for determining the start of the hour. If not provided, the system's default time zone will be used.
|
|
388
|
-
* @returns {
|
|
388
|
+
* @returns {TemporalZonedDateTime} The temporal date representing the start of the hour.
|
|
389
389
|
* @example
|
|
390
390
|
* const dateString = "2023-05-10T10:30:30.000Z"
|
|
391
391
|
* const date = new Date(dateString);
|
|
@@ -400,7 +400,7 @@ const startOfHourUtil = (date, timeZone) => {
|
|
|
400
400
|
*
|
|
401
401
|
* @param {TemporalDate} date - The temporal date for which to determine the end of the hour.
|
|
402
402
|
* @param {string} [timeZone] - The time zone to use for determining the end of the hour. If not provided, the system's default time zone will be used.
|
|
403
|
-
* @returns {
|
|
403
|
+
* @returns {TemporalZonedDateTime} The temporal date representing the end of the hour.
|
|
404
404
|
* @example
|
|
405
405
|
* const dateString = "2023-05-10T10:30:00.000Z"
|
|
406
406
|
* const date = new Date(dateString);
|
|
@@ -418,7 +418,7 @@ const endOfHourUtil = (date, timeZone) => {
|
|
|
418
418
|
*
|
|
419
419
|
* @param {TemporalDate} date - The temporal date for which to determine the start of the day.
|
|
420
420
|
* @param {string} [timeZone] - The time zone to use for determining the start of the day. If not provided, the system's default time zone will be used.
|
|
421
|
-
* @returns {
|
|
421
|
+
* @returns {TemporalZonedDateTime} The temporal date representing the start of the day.
|
|
422
422
|
* @example
|
|
423
423
|
* const dateString = "2023-05-10T10:30:00.000Z"
|
|
424
424
|
* const date = new Date(dateString);
|
|
@@ -433,7 +433,7 @@ const startOfDayUtil = (date, timeZone) => {
|
|
|
433
433
|
*
|
|
434
434
|
* @param {TemporalDate} date - The temporal date for which to determine the end of the day.
|
|
435
435
|
* @param {string} [timeZone] - The time zone to use for determining the end of the day. If not provided, the system's default time zone will be used.
|
|
436
|
-
* @returns {
|
|
436
|
+
* @returns {TemporalZonedDateTime} The temporal date representing the end of the day.
|
|
437
437
|
* @example
|
|
438
438
|
* const dateString = "2023-05-10T10:30:00.000Z"
|
|
439
439
|
* const date = new Date(dateString);
|
|
@@ -449,7 +449,7 @@ const endOfDayUtil = (date, timeZone) => {
|
|
|
449
449
|
*
|
|
450
450
|
* @param {TemporalDate} date - The temporal date for which to determine the start of the week.
|
|
451
451
|
* @param {string} [timeZone] - The time zone to use for determining the start of the week. If not provided, the system's default time zone will be used.
|
|
452
|
-
* @returns {
|
|
452
|
+
* @returns {TemporalZonedDateTime} The temporal date representing the start of the week.
|
|
453
453
|
* @example
|
|
454
454
|
* const dateString = "2023-05-10T10:30:00.000Z"
|
|
455
455
|
* const date = new Date(dateString);
|
|
@@ -466,7 +466,7 @@ const startOfWeekUtil = (date, timeZone) => {
|
|
|
466
466
|
*
|
|
467
467
|
* @param {TemporalDate} date - The temporal date for which to determine the end of the week.
|
|
468
468
|
* @param {string} [timeZone] - The time zone to use for determining the end of the week. If not provided, the system's default time zone will be used.
|
|
469
|
-
* @returns {
|
|
469
|
+
* @returns {TemporalZonedDateTime} The temporal date representing the end of the week.
|
|
470
470
|
* @example
|
|
471
471
|
* const dateString = "2023-05-10T10:30:00.000Z"
|
|
472
472
|
* const date = new Date(dateString);
|
|
@@ -484,7 +484,7 @@ const endOfWeekUtil = (date, timeZone) => {
|
|
|
484
484
|
*
|
|
485
485
|
* @param {TemporalDate} date - The temporal date for which to determine the start of the month.
|
|
486
486
|
* @param {string} [timeZone] - The time zone to use for determining the start of the month. If not provided, the system's default time zone will be used.
|
|
487
|
-
* @returns {
|
|
487
|
+
* @returns {TemporalZonedDateTime} The temporal date representing the start of the month.
|
|
488
488
|
* @example
|
|
489
489
|
* const dateString = "2023-05-10T10:30:00.000Z"
|
|
490
490
|
* const date = new Date(dateString);
|
|
@@ -501,7 +501,7 @@ const startOfMonthUtil = (date, timeZone) => {
|
|
|
501
501
|
*
|
|
502
502
|
* @param {TemporalDate} date - The temporal date for which to determine the end of the month.
|
|
503
503
|
* @param {string} [timeZone] - The time zone to use for determining the end of the month. If not provided, the system's default time zone will be used.
|
|
504
|
-
* @returns {
|
|
504
|
+
* @returns {TemporalZonedDateTime} The temporal date representing the end of the month.
|
|
505
505
|
* @example
|
|
506
506
|
* const dateString = "2023-05-10"
|
|
507
507
|
* const date = new Date(dateString);
|
|
@@ -1161,7 +1161,7 @@ const getDurationFormat = (duration, locale, format) => {
|
|
|
1161
1161
|
*
|
|
1162
1162
|
* @param {number} number - 230.45
|
|
1163
1163
|
* @param {TemporalTimeTypes} unit - "days | "hours" | "minutes" | "seconds"
|
|
1164
|
-
* @param {
|
|
1164
|
+
* @param {TemporalTimeUnit} roundAt - smallest unit to show
|
|
1165
1165
|
*/
|
|
1166
1166
|
const toDuration = (number, unit, roundAt) => {
|
|
1167
1167
|
switch (unit) {
|
|
@@ -1296,7 +1296,7 @@ const convertToMinutes = (number) => {
|
|
|
1296
1296
|
* Converts a JavaScript Date object to a Temporal Instant.
|
|
1297
1297
|
*
|
|
1298
1298
|
* @param {Date} date - The JavaScript Date object to convert.
|
|
1299
|
-
* @returns {
|
|
1299
|
+
* @returns {TemporalInstant} The equivalent Temporal Instant.
|
|
1300
1300
|
* @example
|
|
1301
1301
|
* const jsDate = new Date();
|
|
1302
1302
|
* const result = toTemporalUtil(jsDate);
|
|
@@ -1311,7 +1311,7 @@ const toTemporalUtil = (date) => {
|
|
|
1311
1311
|
/**
|
|
1312
1312
|
* Converts a Temporal Instant or Temporal ZonedDateTime to a JavaScript Date object.
|
|
1313
1313
|
*
|
|
1314
|
-
* @param {
|
|
1314
|
+
* @param {TemporalInstant|TemporalZonedDateTime} date - The Temporal date object to convert.
|
|
1315
1315
|
* @returns {Date} The equivalent JavaScript Date object.
|
|
1316
1316
|
* @example
|
|
1317
1317
|
* const temporalInstant = Temporal.now.instant();
|
|
@@ -1338,8 +1338,8 @@ const toDateUtil = (date) => {
|
|
|
1338
1338
|
/**
|
|
1339
1339
|
* Converts a Temporal ZonedDateTime to a Temporal Instant.
|
|
1340
1340
|
*
|
|
1341
|
-
* @param {
|
|
1342
|
-
* @returns {
|
|
1341
|
+
* @param {TemporalZonedDateTime} zonedDateTime - The Temporal ZonedDateTime to convert.
|
|
1342
|
+
* @returns {TemporalInstant} The equivalent Temporal Instant.
|
|
1343
1343
|
* @example
|
|
1344
1344
|
* const zonedDateTime = Temporal.now.zonedDateTime();
|
|
1345
1345
|
* const result = toInstantUtil(zonedDateTime);
|
|
@@ -1360,7 +1360,7 @@ const toInstantUtil = (zonedDateTime) => {
|
|
|
1360
1360
|
* @param {TemporalDate | Date} date - The temporal or JavaScript Date object to convert.
|
|
1361
1361
|
* @param {string} [timeZoneId] - The time zone identifier to use for the conversion. If not provided, the system's default time zone will be used.
|
|
1362
1362
|
* @param {string} [calendar] - The calendar identifier to use for the conversion. If not provided, the ISO 8601 calendar will be used.
|
|
1363
|
-
* @returns {
|
|
1363
|
+
* @returns {TemporalZonedDateTime} The temporal zoned date-time representation of the input date.
|
|
1364
1364
|
* @example
|
|
1365
1365
|
* const dateString = "2023-05-10T10:30:00.000Z"
|
|
1366
1366
|
* const date = new Date(dateString);
|
|
@@ -1485,7 +1485,7 @@ const getUTCFromTimeZonedUtil = (from, timeZoneId) => {
|
|
|
1485
1485
|
* Get the local week index of the given date using Temporal.
|
|
1486
1486
|
* The exact calculation depends on the values of `weekStartsOn` (the index of the first day of the week)
|
|
1487
1487
|
* and `firstWeekContainsDate` (the day in January, which is always in the first week of the week-numbering year).
|
|
1488
|
-
* @param {
|
|
1488
|
+
* @param {TemporalPlainDate | Date | string} date - The given date (can be either Temporal.PlainDate, a native Date, or an ISO date string).
|
|
1489
1489
|
* @param {GetWeekUtilOptions} [options] - Optional settings for the week calculation.
|
|
1490
1490
|
* @returns {number} - The week number of the year.
|
|
1491
1491
|
* @example
|
|
@@ -1519,6 +1519,7 @@ const getWeekUtil = (date, options) => {
|
|
|
1519
1519
|
* @description
|
|
1520
1520
|
* Convert milliseconds to the specified unit using Temporal.
|
|
1521
1521
|
* @param {number} milliseconds - The number of milliseconds to convert.
|
|
1522
|
+
* @param unit - The unit to convert to.
|
|
1522
1523
|
* @returns {number} - The converted value.
|
|
1523
1524
|
* @example
|
|
1524
1525
|
* const result = convertMillisecondsUtil(60000, "minute")
|
|
@@ -1539,6 +1540,7 @@ const convertMillisecondsUtil = (milliseconds, unit) => {
|
|
|
1539
1540
|
* @description
|
|
1540
1541
|
* Convert seconds to the specified unit using Temporal.
|
|
1541
1542
|
* @param {number} seconds - The number of seconds to convert.
|
|
1543
|
+
* @param unit - The unit to convert to.
|
|
1542
1544
|
* @returns {number} - The converted value.
|
|
1543
1545
|
* @example
|
|
1544
1546
|
* const result = convertSecondsUtil(60, "minute")
|
|
@@ -1556,6 +1558,7 @@ const convertSecondsUtil = (seconds, unit) => {
|
|
|
1556
1558
|
* @description
|
|
1557
1559
|
* Convert minutes to the specified unit using Temporal.
|
|
1558
1560
|
* @param {number} minutes - The number of minutes to convert.
|
|
1561
|
+
* @param unit - The unit to convert to.
|
|
1559
1562
|
* @returns {number} - The converted value.
|
|
1560
1563
|
* @example
|
|
1561
1564
|
* const result = convertMinutesUtil(60, "minute")
|
|
@@ -1573,6 +1576,7 @@ const convertMinutesUtil = (minutes, unit) => {
|
|
|
1573
1576
|
* @description
|
|
1574
1577
|
* Convert hours to the specified unit using Temporal.
|
|
1575
1578
|
* @param {number} hours - The number of hours to convert.
|
|
1579
|
+
* @param unit - The unit to convert to.
|
|
1576
1580
|
* @returns {number} - The converted value.
|
|
1577
1581
|
* @example
|
|
1578
1582
|
* const result = convertHoursUtil(24, "day")
|
package/index.esm.js
CHANGED
|
@@ -147,7 +147,7 @@ const formatRangeUtil = (range, locale, format) => Intl.DateTimeFormat(locale, f
|
|
|
147
147
|
* @param {TemporalDate} date - The temporal date from which to subtract minutes.
|
|
148
148
|
* @param {number} amount - The number of minutes to subtract.
|
|
149
149
|
* @param {string} [timeZone] - The time zone to use for the subtraction. If not provided, the system's default time zone will be used.
|
|
150
|
-
* @returns {
|
|
150
|
+
* @returns {TemporalZonedDateTime} The resulting temporal date after subtracting the specified number of minutes.
|
|
151
151
|
* @example
|
|
152
152
|
* const dateString = "2023-05-10T10:30:00.000Z"
|
|
153
153
|
* const date = new Date(dateString);
|
|
@@ -164,7 +164,7 @@ const subtractMinutesUtil = (date, amount, timeZone) => {
|
|
|
164
164
|
* @param {TemporalDate} date - The temporal date from which to subtract hours.
|
|
165
165
|
* @param {number} amount - The number of hours to subtract.
|
|
166
166
|
* @param {string} [timeZone] - The time zone to use for the subtraction. If not provided, the system's default time zone will be used.
|
|
167
|
-
* @returns {
|
|
167
|
+
* @returns {TemporalZonedDateTime} The resulting temporal date after subtracting the specified number of hours.
|
|
168
168
|
* @example
|
|
169
169
|
* const dateString = "2023-05-10T10:30:00.000Z"
|
|
170
170
|
* const date = new Date(dateString);
|
|
@@ -181,7 +181,7 @@ const subtractHoursUtil = (date, amount, timeZone) => {
|
|
|
181
181
|
* @param {TemporalDate} date - The temporal date from which to subtract days.
|
|
182
182
|
* @param {number} amount - The number of days to subtract.
|
|
183
183
|
* @param {string} [timeZone] - The time zone to use for the subtraction. If not provided, the system's default time zone will be used.
|
|
184
|
-
* @returns {
|
|
184
|
+
* @returns {TemporalZonedDateTime} The resulting temporal date after subtracting the specified number of days.
|
|
185
185
|
* @example
|
|
186
186
|
* const dateString = "2023-05-10"
|
|
187
187
|
* const date = new Date(dateString);
|
|
@@ -198,7 +198,7 @@ const subtractDaysUtil = (date, amount, timeZone) => {
|
|
|
198
198
|
* @param {TemporalDate} date - The temporal date from which to subtract weeks.
|
|
199
199
|
* @param {number} amount - The number of weeks to subtract.
|
|
200
200
|
* @param {string} [timeZone] - The time zone to use for the subtraction. If not provided, the system's default time zone will be used.
|
|
201
|
-
* @returns {
|
|
201
|
+
* @returns {TemporalZonedDateTime} The resulting temporal date after subtracting the specified number of weeks.
|
|
202
202
|
* @example
|
|
203
203
|
* const dateString = "2023-05-10"
|
|
204
204
|
* const date = new Date(dateString);
|
|
@@ -215,7 +215,7 @@ const subtractWeeksUtil = (date, amount, timeZone) => {
|
|
|
215
215
|
* @param {TemporalDate} date - The temporal date from which to subtract months.
|
|
216
216
|
* @param {number} amount - The number of months to subtract.
|
|
217
217
|
* @param {string} [timeZone] - The time zone to use for the subtraction. If not provided, the system's default time zone will be used.
|
|
218
|
-
* @returns {
|
|
218
|
+
* @returns {TemporalZonedDateTime} The resulting temporal date after subtracting the specified number of months.
|
|
219
219
|
* @example
|
|
220
220
|
* const dateString = "2023-05-10"
|
|
221
221
|
* const date = new Date(dateString);
|
|
@@ -232,7 +232,7 @@ const subtractMonthsUtil = (date, amount, timeZone) => {
|
|
|
232
232
|
* @param {TemporalDate} date - The temporal date from which to subtract years.
|
|
233
233
|
* @param {number} amount - The number of years to subtract.
|
|
234
234
|
* @param {string} [timeZone] - The time zone to use for the subtraction. If not provided, the system's default time zone will be used.
|
|
235
|
-
* @returns {
|
|
235
|
+
* @returns {TemporalZonedDateTime} The resulting temporal date after subtracting the specified number of years.
|
|
236
236
|
* @example
|
|
237
237
|
* const dateString = "2023-05-10"
|
|
238
238
|
* const date = new Date(dateString);
|
|
@@ -249,7 +249,7 @@ const subtractYearsUtil = (date, amount, timeZone) => {
|
|
|
249
249
|
* @param {TemporalDate} date - The temporal date to which minutes will be added.
|
|
250
250
|
* @param {number} amount - The number of minutes to add.
|
|
251
251
|
* @param {string} [timeZone] - The time zone to use for the addition. If not provided, the system's default time zone will be used.
|
|
252
|
-
* @returns {
|
|
252
|
+
* @returns {TemporalZonedDateTime} The resulting temporal date after adding the specified number of minutes.
|
|
253
253
|
* @example
|
|
254
254
|
* const dateString = "2023-05-10"
|
|
255
255
|
* const date = new Date(dateString);
|
|
@@ -266,7 +266,7 @@ const addMinutesUtil = (date, amount, timeZone) => {
|
|
|
266
266
|
* @param {TemporalDate} date - The temporal date to which hours will be added.
|
|
267
267
|
* @param {number} amount - The number of hours to add.
|
|
268
268
|
* @param {string} [timeZone] - The time zone to use for the addition. If not provided, the system's default time zone will be used.
|
|
269
|
-
* @returns {
|
|
269
|
+
* @returns {TemporalZonedDateTime} The resulting temporal date after adding the specified number of hours.
|
|
270
270
|
* @example
|
|
271
271
|
* const dateString = "2023-05-10"
|
|
272
272
|
* const date = new Date(dateString);
|
|
@@ -283,7 +283,7 @@ const addHoursUtil = (date, amount, timeZone) => {
|
|
|
283
283
|
* @param {TemporalDate} date - The temporal date to which days will be added.
|
|
284
284
|
* @param {number} amount - The number of days to add.
|
|
285
285
|
* @param {string} [timeZone] - The time zone to use for the addition. If not provided, the system's default time zone will be used.
|
|
286
|
-
* @returns {
|
|
286
|
+
* @returns {TemporalZonedDateTime} The resulting temporal date after adding the specified number of days.
|
|
287
287
|
* @example
|
|
288
288
|
* const dateString = "2023-05-10"
|
|
289
289
|
* const date = new Date(dateString);
|
|
@@ -300,7 +300,7 @@ const addDaysUtil = (date, amount, timeZone) => {
|
|
|
300
300
|
* @param {TemporalDate} date - The temporal date to which weeks will be added.
|
|
301
301
|
* @param {number} amount - The number of weeks to add.
|
|
302
302
|
* @param {string} [timeZone] - The time zone to use for the addition. If not provided, the system's default time zone will be used.
|
|
303
|
-
* @returns {
|
|
303
|
+
* @returns {TemporalZonedDateTime} The resulting temporal date after adding the specified number of weeks.
|
|
304
304
|
* @example
|
|
305
305
|
* const dateString = "2023-05-10"
|
|
306
306
|
* const date = new Date(dateString);
|
|
@@ -317,7 +317,7 @@ const addWeeksUtil = (date, amount, timeZone) => {
|
|
|
317
317
|
* @param {TemporalDate} date - The temporal date to which months will be added.
|
|
318
318
|
* @param {number} amount - The number of months to add.
|
|
319
319
|
* @param {string} [timeZone] - The time zone to use for the addition. If not provided, the system's default time zone will be used.
|
|
320
|
-
* @returns {
|
|
320
|
+
* @returns {TemporalZonedDateTime} The resulting temporal date after adding the specified number of months.
|
|
321
321
|
* @example
|
|
322
322
|
* const dateString = "2023-05-10"
|
|
323
323
|
* const date = new Date(dateString);
|
|
@@ -334,7 +334,7 @@ const addMonthsUtil = (date, amount, timeZone) => {
|
|
|
334
334
|
* @param {TemporalDate} date - The temporal date to which years will be added.
|
|
335
335
|
* @param {number} amount - The number of years to add.
|
|
336
336
|
* @param {string} [timeZone] - The time zone to use for the addition. If not provided, the system's default time zone will be used.
|
|
337
|
-
* @returns {
|
|
337
|
+
* @returns {TemporalZonedDateTime} The resulting temporal date after adding the specified number of years.
|
|
338
338
|
* @example
|
|
339
339
|
* const dateString = "2023-05-10"
|
|
340
340
|
* const date = new Date(dateString);
|
|
@@ -350,7 +350,7 @@ const addYearsUtil = (date, amount, timeZone) => {
|
|
|
350
350
|
*
|
|
351
351
|
* @param {TemporalDate} date - The temporal date for which to determine the start of the minute.
|
|
352
352
|
* @param {string} [timeZone] - The time zone to use for determining the start of the minute. If not provided, the system's default time zone will be used.
|
|
353
|
-
* @returns {
|
|
353
|
+
* @returns {TemporalZonedDateTime} The temporal date representing the start of the minute.
|
|
354
354
|
* @example
|
|
355
355
|
* const dateString = "2023-05-10T10:30:10.000Z"
|
|
356
356
|
* const date = new Date(dateString);
|
|
@@ -365,7 +365,7 @@ const startOfMinuteUtil = (date, timeZone) => {
|
|
|
365
365
|
*
|
|
366
366
|
* @param {TemporalDate} date - The temporal date for which to determine the end of the minute.
|
|
367
367
|
* @param {string} [timeZone] - The time zone to use for determining the end of the minute. If not provided, the system's default time zone will be used.
|
|
368
|
-
* @returns {
|
|
368
|
+
* @returns {TemporalZonedDateTime} The temporal date representing the end of the minute.
|
|
369
369
|
* @example
|
|
370
370
|
* const dateString = "2023-05-10T10:30:10.000Z"
|
|
371
371
|
* const date = new Date(dateString);
|
|
@@ -383,7 +383,7 @@ const endOfMinuteUtil = (date, timeZone) => {
|
|
|
383
383
|
*
|
|
384
384
|
* @param {TemporalDate} date - The temporal date for which to determine the start of the hour.
|
|
385
385
|
* @param {string} [timeZone] - The time zone to use for determining the start of the hour. If not provided, the system's default time zone will be used.
|
|
386
|
-
* @returns {
|
|
386
|
+
* @returns {TemporalZonedDateTime} The temporal date representing the start of the hour.
|
|
387
387
|
* @example
|
|
388
388
|
* const dateString = "2023-05-10T10:30:30.000Z"
|
|
389
389
|
* const date = new Date(dateString);
|
|
@@ -398,7 +398,7 @@ const startOfHourUtil = (date, timeZone) => {
|
|
|
398
398
|
*
|
|
399
399
|
* @param {TemporalDate} date - The temporal date for which to determine the end of the hour.
|
|
400
400
|
* @param {string} [timeZone] - The time zone to use for determining the end of the hour. If not provided, the system's default time zone will be used.
|
|
401
|
-
* @returns {
|
|
401
|
+
* @returns {TemporalZonedDateTime} The temporal date representing the end of the hour.
|
|
402
402
|
* @example
|
|
403
403
|
* const dateString = "2023-05-10T10:30:00.000Z"
|
|
404
404
|
* const date = new Date(dateString);
|
|
@@ -416,7 +416,7 @@ const endOfHourUtil = (date, timeZone) => {
|
|
|
416
416
|
*
|
|
417
417
|
* @param {TemporalDate} date - The temporal date for which to determine the start of the day.
|
|
418
418
|
* @param {string} [timeZone] - The time zone to use for determining the start of the day. If not provided, the system's default time zone will be used.
|
|
419
|
-
* @returns {
|
|
419
|
+
* @returns {TemporalZonedDateTime} The temporal date representing the start of the day.
|
|
420
420
|
* @example
|
|
421
421
|
* const dateString = "2023-05-10T10:30:00.000Z"
|
|
422
422
|
* const date = new Date(dateString);
|
|
@@ -431,7 +431,7 @@ const startOfDayUtil = (date, timeZone) => {
|
|
|
431
431
|
*
|
|
432
432
|
* @param {TemporalDate} date - The temporal date for which to determine the end of the day.
|
|
433
433
|
* @param {string} [timeZone] - The time zone to use for determining the end of the day. If not provided, the system's default time zone will be used.
|
|
434
|
-
* @returns {
|
|
434
|
+
* @returns {TemporalZonedDateTime} The temporal date representing the end of the day.
|
|
435
435
|
* @example
|
|
436
436
|
* const dateString = "2023-05-10T10:30:00.000Z"
|
|
437
437
|
* const date = new Date(dateString);
|
|
@@ -447,7 +447,7 @@ const endOfDayUtil = (date, timeZone) => {
|
|
|
447
447
|
*
|
|
448
448
|
* @param {TemporalDate} date - The temporal date for which to determine the start of the week.
|
|
449
449
|
* @param {string} [timeZone] - The time zone to use for determining the start of the week. If not provided, the system's default time zone will be used.
|
|
450
|
-
* @returns {
|
|
450
|
+
* @returns {TemporalZonedDateTime} The temporal date representing the start of the week.
|
|
451
451
|
* @example
|
|
452
452
|
* const dateString = "2023-05-10T10:30:00.000Z"
|
|
453
453
|
* const date = new Date(dateString);
|
|
@@ -464,7 +464,7 @@ const startOfWeekUtil = (date, timeZone) => {
|
|
|
464
464
|
*
|
|
465
465
|
* @param {TemporalDate} date - The temporal date for which to determine the end of the week.
|
|
466
466
|
* @param {string} [timeZone] - The time zone to use for determining the end of the week. If not provided, the system's default time zone will be used.
|
|
467
|
-
* @returns {
|
|
467
|
+
* @returns {TemporalZonedDateTime} The temporal date representing the end of the week.
|
|
468
468
|
* @example
|
|
469
469
|
* const dateString = "2023-05-10T10:30:00.000Z"
|
|
470
470
|
* const date = new Date(dateString);
|
|
@@ -482,7 +482,7 @@ const endOfWeekUtil = (date, timeZone) => {
|
|
|
482
482
|
*
|
|
483
483
|
* @param {TemporalDate} date - The temporal date for which to determine the start of the month.
|
|
484
484
|
* @param {string} [timeZone] - The time zone to use for determining the start of the month. If not provided, the system's default time zone will be used.
|
|
485
|
-
* @returns {
|
|
485
|
+
* @returns {TemporalZonedDateTime} The temporal date representing the start of the month.
|
|
486
486
|
* @example
|
|
487
487
|
* const dateString = "2023-05-10T10:30:00.000Z"
|
|
488
488
|
* const date = new Date(dateString);
|
|
@@ -499,7 +499,7 @@ const startOfMonthUtil = (date, timeZone) => {
|
|
|
499
499
|
*
|
|
500
500
|
* @param {TemporalDate} date - The temporal date for which to determine the end of the month.
|
|
501
501
|
* @param {string} [timeZone] - The time zone to use for determining the end of the month. If not provided, the system's default time zone will be used.
|
|
502
|
-
* @returns {
|
|
502
|
+
* @returns {TemporalZonedDateTime} The temporal date representing the end of the month.
|
|
503
503
|
* @example
|
|
504
504
|
* const dateString = "2023-05-10"
|
|
505
505
|
* const date = new Date(dateString);
|
|
@@ -1159,7 +1159,7 @@ const getDurationFormat = (duration, locale, format) => {
|
|
|
1159
1159
|
*
|
|
1160
1160
|
* @param {number} number - 230.45
|
|
1161
1161
|
* @param {TemporalTimeTypes} unit - "days | "hours" | "minutes" | "seconds"
|
|
1162
|
-
* @param {
|
|
1162
|
+
* @param {TemporalTimeUnit} roundAt - smallest unit to show
|
|
1163
1163
|
*/
|
|
1164
1164
|
const toDuration = (number, unit, roundAt) => {
|
|
1165
1165
|
switch (unit) {
|
|
@@ -1294,7 +1294,7 @@ const convertToMinutes = (number) => {
|
|
|
1294
1294
|
* Converts a JavaScript Date object to a Temporal Instant.
|
|
1295
1295
|
*
|
|
1296
1296
|
* @param {Date} date - The JavaScript Date object to convert.
|
|
1297
|
-
* @returns {
|
|
1297
|
+
* @returns {TemporalInstant} The equivalent Temporal Instant.
|
|
1298
1298
|
* @example
|
|
1299
1299
|
* const jsDate = new Date();
|
|
1300
1300
|
* const result = toTemporalUtil(jsDate);
|
|
@@ -1309,7 +1309,7 @@ const toTemporalUtil = (date) => {
|
|
|
1309
1309
|
/**
|
|
1310
1310
|
* Converts a Temporal Instant or Temporal ZonedDateTime to a JavaScript Date object.
|
|
1311
1311
|
*
|
|
1312
|
-
* @param {
|
|
1312
|
+
* @param {TemporalInstant|TemporalZonedDateTime} date - The Temporal date object to convert.
|
|
1313
1313
|
* @returns {Date} The equivalent JavaScript Date object.
|
|
1314
1314
|
* @example
|
|
1315
1315
|
* const temporalInstant = Temporal.now.instant();
|
|
@@ -1336,8 +1336,8 @@ const toDateUtil = (date) => {
|
|
|
1336
1336
|
/**
|
|
1337
1337
|
* Converts a Temporal ZonedDateTime to a Temporal Instant.
|
|
1338
1338
|
*
|
|
1339
|
-
* @param {
|
|
1340
|
-
* @returns {
|
|
1339
|
+
* @param {TemporalZonedDateTime} zonedDateTime - The Temporal ZonedDateTime to convert.
|
|
1340
|
+
* @returns {TemporalInstant} The equivalent Temporal Instant.
|
|
1341
1341
|
* @example
|
|
1342
1342
|
* const zonedDateTime = Temporal.now.zonedDateTime();
|
|
1343
1343
|
* const result = toInstantUtil(zonedDateTime);
|
|
@@ -1358,7 +1358,7 @@ const toInstantUtil = (zonedDateTime) => {
|
|
|
1358
1358
|
* @param {TemporalDate | Date} date - The temporal or JavaScript Date object to convert.
|
|
1359
1359
|
* @param {string} [timeZoneId] - The time zone identifier to use for the conversion. If not provided, the system's default time zone will be used.
|
|
1360
1360
|
* @param {string} [calendar] - The calendar identifier to use for the conversion. If not provided, the ISO 8601 calendar will be used.
|
|
1361
|
-
* @returns {
|
|
1361
|
+
* @returns {TemporalZonedDateTime} The temporal zoned date-time representation of the input date.
|
|
1362
1362
|
* @example
|
|
1363
1363
|
* const dateString = "2023-05-10T10:30:00.000Z"
|
|
1364
1364
|
* const date = new Date(dateString);
|
|
@@ -1483,7 +1483,7 @@ const getUTCFromTimeZonedUtil = (from, timeZoneId) => {
|
|
|
1483
1483
|
* Get the local week index of the given date using Temporal.
|
|
1484
1484
|
* The exact calculation depends on the values of `weekStartsOn` (the index of the first day of the week)
|
|
1485
1485
|
* and `firstWeekContainsDate` (the day in January, which is always in the first week of the week-numbering year).
|
|
1486
|
-
* @param {
|
|
1486
|
+
* @param {TemporalPlainDate | Date | string} date - The given date (can be either Temporal.PlainDate, a native Date, or an ISO date string).
|
|
1487
1487
|
* @param {GetWeekUtilOptions} [options] - Optional settings for the week calculation.
|
|
1488
1488
|
* @returns {number} - The week number of the year.
|
|
1489
1489
|
* @example
|
|
@@ -1517,6 +1517,7 @@ const getWeekUtil = (date, options) => {
|
|
|
1517
1517
|
* @description
|
|
1518
1518
|
* Convert milliseconds to the specified unit using Temporal.
|
|
1519
1519
|
* @param {number} milliseconds - The number of milliseconds to convert.
|
|
1520
|
+
* @param unit - The unit to convert to.
|
|
1520
1521
|
* @returns {number} - The converted value.
|
|
1521
1522
|
* @example
|
|
1522
1523
|
* const result = convertMillisecondsUtil(60000, "minute")
|
|
@@ -1537,6 +1538,7 @@ const convertMillisecondsUtil = (milliseconds, unit) => {
|
|
|
1537
1538
|
* @description
|
|
1538
1539
|
* Convert seconds to the specified unit using Temporal.
|
|
1539
1540
|
* @param {number} seconds - The number of seconds to convert.
|
|
1541
|
+
* @param unit - The unit to convert to.
|
|
1540
1542
|
* @returns {number} - The converted value.
|
|
1541
1543
|
* @example
|
|
1542
1544
|
* const result = convertSecondsUtil(60, "minute")
|
|
@@ -1554,6 +1556,7 @@ const convertSecondsUtil = (seconds, unit) => {
|
|
|
1554
1556
|
* @description
|
|
1555
1557
|
* Convert minutes to the specified unit using Temporal.
|
|
1556
1558
|
* @param {number} minutes - The number of minutes to convert.
|
|
1559
|
+
* @param unit - The unit to convert to.
|
|
1557
1560
|
* @returns {number} - The converted value.
|
|
1558
1561
|
* @example
|
|
1559
1562
|
* const result = convertMinutesUtil(60, "minute")
|
|
@@ -1571,6 +1574,7 @@ const convertMinutesUtil = (minutes, unit) => {
|
|
|
1571
1574
|
* @description
|
|
1572
1575
|
* Convert hours to the specified unit using Temporal.
|
|
1573
1576
|
* @param {number} hours - The number of hours to convert.
|
|
1577
|
+
* @param unit - The unit to convert to.
|
|
1574
1578
|
* @returns {number} - The converted value.
|
|
1575
1579
|
* @example
|
|
1576
1580
|
* const result = convertHoursUtil(24, "day")
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trackunit/date-and-time-utils",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.10",
|
|
4
4
|
"repository": "https://github.com/Trackunit/manager",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"engines": {
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"@formatjs/intl-enumerator": "^1.8.1",
|
|
11
11
|
"@js-temporal/polyfill": "^0.4.4",
|
|
12
12
|
"@formatjs/intl-durationformat": "^0.6.1",
|
|
13
|
-
"@trackunit/react-test-setup": "1.3.
|
|
13
|
+
"@trackunit/react-test-setup": "1.3.10"
|
|
14
14
|
},
|
|
15
15
|
"module": "./index.esm.js",
|
|
16
16
|
"main": "./index.cjs.js",
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import "@formatjs/intl-durationformat/polyfill";
|
|
2
2
|
import { Temporal } from "@js-temporal/polyfill";
|
|
3
|
+
export type TemporalTimeUnit = Temporal.TimeUnit;
|
|
3
4
|
export type TemporalDate = Temporal.Instant | Temporal.ZonedDateTime | Date;
|
|
4
5
|
type TemporalFormatTypes = Intl.DateTimeFormatOptions;
|
|
5
6
|
type TemporalTimeTypes = Extract<Intl.RelativeTimeFormatUnit, "days" | "hours" | "minutes" | "seconds">;
|
|
@@ -98,7 +99,7 @@ export declare const formatRangeUtil: (range: DateRange, locale: string, format?
|
|
|
98
99
|
* @param {TemporalDate} date - The temporal date from which to subtract minutes.
|
|
99
100
|
* @param {number} amount - The number of minutes to subtract.
|
|
100
101
|
* @param {string} [timeZone] - The time zone to use for the subtraction. If not provided, the system's default time zone will be used.
|
|
101
|
-
* @returns {
|
|
102
|
+
* @returns {TemporalZonedDateTime} The resulting temporal date after subtracting the specified number of minutes.
|
|
102
103
|
* @example
|
|
103
104
|
* const dateString = "2023-05-10T10:30:00.000Z"
|
|
104
105
|
* const date = new Date(dateString);
|
|
@@ -113,7 +114,7 @@ export declare const subtractMinutesUtil: (date: TemporalDate, amount: number, t
|
|
|
113
114
|
* @param {TemporalDate} date - The temporal date from which to subtract hours.
|
|
114
115
|
* @param {number} amount - The number of hours to subtract.
|
|
115
116
|
* @param {string} [timeZone] - The time zone to use for the subtraction. If not provided, the system's default time zone will be used.
|
|
116
|
-
* @returns {
|
|
117
|
+
* @returns {TemporalZonedDateTime} The resulting temporal date after subtracting the specified number of hours.
|
|
117
118
|
* @example
|
|
118
119
|
* const dateString = "2023-05-10T10:30:00.000Z"
|
|
119
120
|
* const date = new Date(dateString);
|
|
@@ -128,7 +129,7 @@ export declare const subtractHoursUtil: (date: TemporalDate, amount: number, tim
|
|
|
128
129
|
* @param {TemporalDate} date - The temporal date from which to subtract days.
|
|
129
130
|
* @param {number} amount - The number of days to subtract.
|
|
130
131
|
* @param {string} [timeZone] - The time zone to use for the subtraction. If not provided, the system's default time zone will be used.
|
|
131
|
-
* @returns {
|
|
132
|
+
* @returns {TemporalZonedDateTime} The resulting temporal date after subtracting the specified number of days.
|
|
132
133
|
* @example
|
|
133
134
|
* const dateString = "2023-05-10"
|
|
134
135
|
* const date = new Date(dateString);
|
|
@@ -143,7 +144,7 @@ export declare const subtractDaysUtil: (date: TemporalDate, amount: number, time
|
|
|
143
144
|
* @param {TemporalDate} date - The temporal date from which to subtract weeks.
|
|
144
145
|
* @param {number} amount - The number of weeks to subtract.
|
|
145
146
|
* @param {string} [timeZone] - The time zone to use for the subtraction. If not provided, the system's default time zone will be used.
|
|
146
|
-
* @returns {
|
|
147
|
+
* @returns {TemporalZonedDateTime} The resulting temporal date after subtracting the specified number of weeks.
|
|
147
148
|
* @example
|
|
148
149
|
* const dateString = "2023-05-10"
|
|
149
150
|
* const date = new Date(dateString);
|
|
@@ -158,7 +159,7 @@ export declare const subtractWeeksUtil: (date: TemporalDate, amount: number, tim
|
|
|
158
159
|
* @param {TemporalDate} date - The temporal date from which to subtract months.
|
|
159
160
|
* @param {number} amount - The number of months to subtract.
|
|
160
161
|
* @param {string} [timeZone] - The time zone to use for the subtraction. If not provided, the system's default time zone will be used.
|
|
161
|
-
* @returns {
|
|
162
|
+
* @returns {TemporalZonedDateTime} The resulting temporal date after subtracting the specified number of months.
|
|
162
163
|
* @example
|
|
163
164
|
* const dateString = "2023-05-10"
|
|
164
165
|
* const date = new Date(dateString);
|
|
@@ -173,7 +174,7 @@ export declare const subtractMonthsUtil: (date: TemporalDate, amount: number, ti
|
|
|
173
174
|
* @param {TemporalDate} date - The temporal date from which to subtract years.
|
|
174
175
|
* @param {number} amount - The number of years to subtract.
|
|
175
176
|
* @param {string} [timeZone] - The time zone to use for the subtraction. If not provided, the system's default time zone will be used.
|
|
176
|
-
* @returns {
|
|
177
|
+
* @returns {TemporalZonedDateTime} The resulting temporal date after subtracting the specified number of years.
|
|
177
178
|
* @example
|
|
178
179
|
* const dateString = "2023-05-10"
|
|
179
180
|
* const date = new Date(dateString);
|
|
@@ -188,7 +189,7 @@ export declare const subtractYearsUtil: (date: TemporalDate, amount: number, tim
|
|
|
188
189
|
* @param {TemporalDate} date - The temporal date to which minutes will be added.
|
|
189
190
|
* @param {number} amount - The number of minutes to add.
|
|
190
191
|
* @param {string} [timeZone] - The time zone to use for the addition. If not provided, the system's default time zone will be used.
|
|
191
|
-
* @returns {
|
|
192
|
+
* @returns {TemporalZonedDateTime} The resulting temporal date after adding the specified number of minutes.
|
|
192
193
|
* @example
|
|
193
194
|
* const dateString = "2023-05-10"
|
|
194
195
|
* const date = new Date(dateString);
|
|
@@ -203,7 +204,7 @@ export declare const addMinutesUtil: (date: TemporalDate, amount: number, timeZo
|
|
|
203
204
|
* @param {TemporalDate} date - The temporal date to which hours will be added.
|
|
204
205
|
* @param {number} amount - The number of hours to add.
|
|
205
206
|
* @param {string} [timeZone] - The time zone to use for the addition. If not provided, the system's default time zone will be used.
|
|
206
|
-
* @returns {
|
|
207
|
+
* @returns {TemporalZonedDateTime} The resulting temporal date after adding the specified number of hours.
|
|
207
208
|
* @example
|
|
208
209
|
* const dateString = "2023-05-10"
|
|
209
210
|
* const date = new Date(dateString);
|
|
@@ -218,7 +219,7 @@ export declare const addHoursUtil: (date: TemporalDate, amount: number, timeZone
|
|
|
218
219
|
* @param {TemporalDate} date - The temporal date to which days will be added.
|
|
219
220
|
* @param {number} amount - The number of days to add.
|
|
220
221
|
* @param {string} [timeZone] - The time zone to use for the addition. If not provided, the system's default time zone will be used.
|
|
221
|
-
* @returns {
|
|
222
|
+
* @returns {TemporalZonedDateTime} The resulting temporal date after adding the specified number of days.
|
|
222
223
|
* @example
|
|
223
224
|
* const dateString = "2023-05-10"
|
|
224
225
|
* const date = new Date(dateString);
|
|
@@ -233,7 +234,7 @@ export declare const addDaysUtil: (date: TemporalDate, amount: number, timeZone?
|
|
|
233
234
|
* @param {TemporalDate} date - The temporal date to which weeks will be added.
|
|
234
235
|
* @param {number} amount - The number of weeks to add.
|
|
235
236
|
* @param {string} [timeZone] - The time zone to use for the addition. If not provided, the system's default time zone will be used.
|
|
236
|
-
* @returns {
|
|
237
|
+
* @returns {TemporalZonedDateTime} The resulting temporal date after adding the specified number of weeks.
|
|
237
238
|
* @example
|
|
238
239
|
* const dateString = "2023-05-10"
|
|
239
240
|
* const date = new Date(dateString);
|
|
@@ -248,7 +249,7 @@ export declare const addWeeksUtil: (date: TemporalDate, amount: number, timeZone
|
|
|
248
249
|
* @param {TemporalDate} date - The temporal date to which months will be added.
|
|
249
250
|
* @param {number} amount - The number of months to add.
|
|
250
251
|
* @param {string} [timeZone] - The time zone to use for the addition. If not provided, the system's default time zone will be used.
|
|
251
|
-
* @returns {
|
|
252
|
+
* @returns {TemporalZonedDateTime} The resulting temporal date after adding the specified number of months.
|
|
252
253
|
* @example
|
|
253
254
|
* const dateString = "2023-05-10"
|
|
254
255
|
* const date = new Date(dateString);
|
|
@@ -263,7 +264,7 @@ export declare const addMonthsUtil: (date: TemporalDate, amount: number, timeZon
|
|
|
263
264
|
* @param {TemporalDate} date - The temporal date to which years will be added.
|
|
264
265
|
* @param {number} amount - The number of years to add.
|
|
265
266
|
* @param {string} [timeZone] - The time zone to use for the addition. If not provided, the system's default time zone will be used.
|
|
266
|
-
* @returns {
|
|
267
|
+
* @returns {TemporalZonedDateTime} The resulting temporal date after adding the specified number of years.
|
|
267
268
|
* @example
|
|
268
269
|
* const dateString = "2023-05-10"
|
|
269
270
|
* const date = new Date(dateString);
|
|
@@ -277,7 +278,7 @@ export declare const addYearsUtil: (date: TemporalDate, amount: number, timeZone
|
|
|
277
278
|
*
|
|
278
279
|
* @param {TemporalDate} date - The temporal date for which to determine the start of the minute.
|
|
279
280
|
* @param {string} [timeZone] - The time zone to use for determining the start of the minute. If not provided, the system's default time zone will be used.
|
|
280
|
-
* @returns {
|
|
281
|
+
* @returns {TemporalZonedDateTime} The temporal date representing the start of the minute.
|
|
281
282
|
* @example
|
|
282
283
|
* const dateString = "2023-05-10T10:30:10.000Z"
|
|
283
284
|
* const date = new Date(dateString);
|
|
@@ -290,7 +291,7 @@ export declare const startOfMinuteUtil: (date: TemporalDate, timeZone?: string)
|
|
|
290
291
|
*
|
|
291
292
|
* @param {TemporalDate} date - The temporal date for which to determine the end of the minute.
|
|
292
293
|
* @param {string} [timeZone] - The time zone to use for determining the end of the minute. If not provided, the system's default time zone will be used.
|
|
293
|
-
* @returns {
|
|
294
|
+
* @returns {TemporalZonedDateTime} The temporal date representing the end of the minute.
|
|
294
295
|
* @example
|
|
295
296
|
* const dateString = "2023-05-10T10:30:10.000Z"
|
|
296
297
|
* const date = new Date(dateString);
|
|
@@ -303,7 +304,7 @@ export declare const endOfMinuteUtil: (date: TemporalDate, timeZone?: string) =>
|
|
|
303
304
|
*
|
|
304
305
|
* @param {TemporalDate} date - The temporal date for which to determine the start of the hour.
|
|
305
306
|
* @param {string} [timeZone] - The time zone to use for determining the start of the hour. If not provided, the system's default time zone will be used.
|
|
306
|
-
* @returns {
|
|
307
|
+
* @returns {TemporalZonedDateTime} The temporal date representing the start of the hour.
|
|
307
308
|
* @example
|
|
308
309
|
* const dateString = "2023-05-10T10:30:30.000Z"
|
|
309
310
|
* const date = new Date(dateString);
|
|
@@ -316,7 +317,7 @@ export declare const startOfHourUtil: (date: TemporalDate, timeZone?: string) =>
|
|
|
316
317
|
*
|
|
317
318
|
* @param {TemporalDate} date - The temporal date for which to determine the end of the hour.
|
|
318
319
|
* @param {string} [timeZone] - The time zone to use for determining the end of the hour. If not provided, the system's default time zone will be used.
|
|
319
|
-
* @returns {
|
|
320
|
+
* @returns {TemporalZonedDateTime} The temporal date representing the end of the hour.
|
|
320
321
|
* @example
|
|
321
322
|
* const dateString = "2023-05-10T10:30:00.000Z"
|
|
322
323
|
* const date = new Date(dateString);
|
|
@@ -329,7 +330,7 @@ export declare const endOfHourUtil: (date: TemporalDate, timeZone?: string) => T
|
|
|
329
330
|
*
|
|
330
331
|
* @param {TemporalDate} date - The temporal date for which to determine the start of the day.
|
|
331
332
|
* @param {string} [timeZone] - The time zone to use for determining the start of the day. If not provided, the system's default time zone will be used.
|
|
332
|
-
* @returns {
|
|
333
|
+
* @returns {TemporalZonedDateTime} The temporal date representing the start of the day.
|
|
333
334
|
* @example
|
|
334
335
|
* const dateString = "2023-05-10T10:30:00.000Z"
|
|
335
336
|
* const date = new Date(dateString);
|
|
@@ -342,7 +343,7 @@ export declare const startOfDayUtil: (date: TemporalDate, timeZone?: string) =>
|
|
|
342
343
|
*
|
|
343
344
|
* @param {TemporalDate} date - The temporal date for which to determine the end of the day.
|
|
344
345
|
* @param {string} [timeZone] - The time zone to use for determining the end of the day. If not provided, the system's default time zone will be used.
|
|
345
|
-
* @returns {
|
|
346
|
+
* @returns {TemporalZonedDateTime} The temporal date representing the end of the day.
|
|
346
347
|
* @example
|
|
347
348
|
* const dateString = "2023-05-10T10:30:00.000Z"
|
|
348
349
|
* const date = new Date(dateString);
|
|
@@ -355,7 +356,7 @@ export declare const endOfDayUtil: (date: TemporalDate, timeZone?: string) => Te
|
|
|
355
356
|
*
|
|
356
357
|
* @param {TemporalDate} date - The temporal date for which to determine the start of the week.
|
|
357
358
|
* @param {string} [timeZone] - The time zone to use for determining the start of the week. If not provided, the system's default time zone will be used.
|
|
358
|
-
* @returns {
|
|
359
|
+
* @returns {TemporalZonedDateTime} The temporal date representing the start of the week.
|
|
359
360
|
* @example
|
|
360
361
|
* const dateString = "2023-05-10T10:30:00.000Z"
|
|
361
362
|
* const date = new Date(dateString);
|
|
@@ -368,7 +369,7 @@ export declare const startOfWeekUtil: (date: TemporalDate, timeZone?: string) =>
|
|
|
368
369
|
*
|
|
369
370
|
* @param {TemporalDate} date - The temporal date for which to determine the end of the week.
|
|
370
371
|
* @param {string} [timeZone] - The time zone to use for determining the end of the week. If not provided, the system's default time zone will be used.
|
|
371
|
-
* @returns {
|
|
372
|
+
* @returns {TemporalZonedDateTime} The temporal date representing the end of the week.
|
|
372
373
|
* @example
|
|
373
374
|
* const dateString = "2023-05-10T10:30:00.000Z"
|
|
374
375
|
* const date = new Date(dateString);
|
|
@@ -381,7 +382,7 @@ export declare const endOfWeekUtil: (date: TemporalDate, timeZone?: string) => T
|
|
|
381
382
|
*
|
|
382
383
|
* @param {TemporalDate} date - The temporal date for which to determine the start of the month.
|
|
383
384
|
* @param {string} [timeZone] - The time zone to use for determining the start of the month. If not provided, the system's default time zone will be used.
|
|
384
|
-
* @returns {
|
|
385
|
+
* @returns {TemporalZonedDateTime} The temporal date representing the start of the month.
|
|
385
386
|
* @example
|
|
386
387
|
* const dateString = "2023-05-10T10:30:00.000Z"
|
|
387
388
|
* const date = new Date(dateString);
|
|
@@ -394,7 +395,7 @@ export declare const startOfMonthUtil: (date: TemporalDate, timeZone?: string) =
|
|
|
394
395
|
*
|
|
395
396
|
* @param {TemporalDate} date - The temporal date for which to determine the end of the month.
|
|
396
397
|
* @param {string} [timeZone] - The time zone to use for determining the end of the month. If not provided, the system's default time zone will be used.
|
|
397
|
-
* @returns {
|
|
398
|
+
* @returns {TemporalZonedDateTime} The temporal date representing the end of the month.
|
|
398
399
|
* @example
|
|
399
400
|
* const dateString = "2023-05-10"
|
|
400
401
|
* const date = new Date(dateString);
|
|
@@ -803,14 +804,14 @@ export declare const getDurationFormat: (duration: Intl.Duration, locale?: strin
|
|
|
803
804
|
*
|
|
804
805
|
* @param {number} number - 230.45
|
|
805
806
|
* @param {TemporalTimeTypes} unit - "days | "hours" | "minutes" | "seconds"
|
|
806
|
-
* @param {
|
|
807
|
+
* @param {TemporalTimeUnit} roundAt - smallest unit to show
|
|
807
808
|
*/
|
|
808
809
|
export declare const toDuration: (number: number, unit: TemporalTimeTypes, roundAt?: Extract<Temporal.TimeUnit, "hour" | "minute" | "second">) => Intl.Duration;
|
|
809
810
|
/**
|
|
810
811
|
* Converts a JavaScript Date object to a Temporal Instant.
|
|
811
812
|
*
|
|
812
813
|
* @param {Date} date - The JavaScript Date object to convert.
|
|
813
|
-
* @returns {
|
|
814
|
+
* @returns {TemporalInstant} The equivalent Temporal Instant.
|
|
814
815
|
* @example
|
|
815
816
|
* const jsDate = new Date();
|
|
816
817
|
* const result = toTemporalUtil(jsDate);
|
|
@@ -820,7 +821,7 @@ export declare const toTemporalUtil: (date: Date | string) => Temporal.Instant;
|
|
|
820
821
|
/**
|
|
821
822
|
* Converts a Temporal Instant or Temporal ZonedDateTime to a JavaScript Date object.
|
|
822
823
|
*
|
|
823
|
-
* @param {
|
|
824
|
+
* @param {TemporalInstant|TemporalZonedDateTime} date - The Temporal date object to convert.
|
|
824
825
|
* @returns {Date} The equivalent JavaScript Date object.
|
|
825
826
|
* @example
|
|
826
827
|
* const temporalInstant = Temporal.now.instant();
|
|
@@ -836,8 +837,8 @@ export declare const toDateUtil: (date: Temporal.Instant | Temporal.ZonedDateTim
|
|
|
836
837
|
/**
|
|
837
838
|
* Converts a Temporal ZonedDateTime to a Temporal Instant.
|
|
838
839
|
*
|
|
839
|
-
* @param {
|
|
840
|
-
* @returns {
|
|
840
|
+
* @param {TemporalZonedDateTime} zonedDateTime - The Temporal ZonedDateTime to convert.
|
|
841
|
+
* @returns {TemporalInstant} The equivalent Temporal Instant.
|
|
841
842
|
* @example
|
|
842
843
|
* const zonedDateTime = Temporal.now.zonedDateTime();
|
|
843
844
|
* const result = toInstantUtil(zonedDateTime);
|
|
@@ -850,7 +851,7 @@ export declare const toInstantUtil: (zonedDateTime: Temporal.ZonedDateTime | Dat
|
|
|
850
851
|
* @param {TemporalDate | Date} date - The temporal or JavaScript Date object to convert.
|
|
851
852
|
* @param {string} [timeZoneId] - The time zone identifier to use for the conversion. If not provided, the system's default time zone will be used.
|
|
852
853
|
* @param {string} [calendar] - The calendar identifier to use for the conversion. If not provided, the ISO 8601 calendar will be used.
|
|
853
|
-
* @returns {
|
|
854
|
+
* @returns {TemporalZonedDateTime} The temporal zoned date-time representation of the input date.
|
|
854
855
|
* @example
|
|
855
856
|
* const dateString = "2023-05-10T10:30:00.000Z"
|
|
856
857
|
* const date = new Date(dateString);
|
|
@@ -940,7 +941,7 @@ interface GetWeekUtilOptions {
|
|
|
940
941
|
* Get the local week index of the given date using Temporal.
|
|
941
942
|
* The exact calculation depends on the values of `weekStartsOn` (the index of the first day of the week)
|
|
942
943
|
* and `firstWeekContainsDate` (the day in January, which is always in the first week of the week-numbering year).
|
|
943
|
-
* @param {
|
|
944
|
+
* @param {TemporalPlainDate | Date | string} date - The given date (can be either Temporal.PlainDate, a native Date, or an ISO date string).
|
|
944
945
|
* @param {GetWeekUtilOptions} [options] - Optional settings for the week calculation.
|
|
945
946
|
* @returns {number} - The week number of the year.
|
|
946
947
|
* @example
|
|
@@ -963,6 +964,7 @@ export declare const getWeekUtil: (date: Temporal.PlainDate | Date | string, opt
|
|
|
963
964
|
* @description
|
|
964
965
|
* Convert milliseconds to the specified unit using Temporal.
|
|
965
966
|
* @param {number} milliseconds - The number of milliseconds to convert.
|
|
967
|
+
* @param unit - The unit to convert to.
|
|
966
968
|
* @returns {number} - The converted value.
|
|
967
969
|
* @example
|
|
968
970
|
* const result = convertMillisecondsUtil(60000, "minute")
|
|
@@ -981,6 +983,7 @@ export declare const convertMillisecondsUtil: (milliseconds: number, unit: Extra
|
|
|
981
983
|
* @description
|
|
982
984
|
* Convert seconds to the specified unit using Temporal.
|
|
983
985
|
* @param {number} seconds - The number of seconds to convert.
|
|
986
|
+
* @param unit - The unit to convert to.
|
|
984
987
|
* @returns {number} - The converted value.
|
|
985
988
|
* @example
|
|
986
989
|
* const result = convertSecondsUtil(60, "minute")
|
|
@@ -996,6 +999,7 @@ export declare const convertSecondsUtil: (seconds: number, unit: Extract<Tempora
|
|
|
996
999
|
* @description
|
|
997
1000
|
* Convert minutes to the specified unit using Temporal.
|
|
998
1001
|
* @param {number} minutes - The number of minutes to convert.
|
|
1002
|
+
* @param unit - The unit to convert to.
|
|
999
1003
|
* @returns {number} - The converted value.
|
|
1000
1004
|
* @example
|
|
1001
1005
|
* const result = convertMinutesUtil(60, "minute")
|
|
@@ -1011,6 +1015,7 @@ export declare const convertMinutesUtil: (minutes: number, unit: Extract<Tempora
|
|
|
1011
1015
|
* @description
|
|
1012
1016
|
* Convert hours to the specified unit using Temporal.
|
|
1013
1017
|
* @param {number} hours - The number of hours to convert.
|
|
1018
|
+
* @param unit - The unit to convert to.
|
|
1014
1019
|
* @returns {number} - The converted value.
|
|
1015
1020
|
* @example
|
|
1016
1021
|
* const result = convertHoursUtil(24, "day")
|