@sbb-esta/lyne-elements-experimental 5.0.2 → 5.2.0
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/autocomplete-grid.js +1 -10
- package/autocomplete-grid.pure.js +12 -7
- package/core.js +31 -5
- package/development/autocomplete-grid/autocomplete-grid/autocomplete-grid.component.d.ts +0 -1
- package/development/autocomplete-grid/autocomplete-grid-button/autocomplete-grid-button.component.d.ts +4 -5
- package/development/autocomplete-grid/autocomplete-grid-cell/autocomplete-grid-cell.component.d.ts +1 -2
- package/development/autocomplete-grid/autocomplete-grid-optgroup/autocomplete-grid-optgroup.component.d.ts +2 -3
- package/development/autocomplete-grid/autocomplete-grid-option/autocomplete-grid-option.component.d.ts +1 -2
- package/development/autocomplete-grid/autocomplete-grid-row/autocomplete-grid-row.component.d.ts +1 -2
- package/development/autocomplete-grid.d.ts +0 -1
- package/development/autocomplete-grid.js +5 -10
- package/development/autocomplete-grid.pure.d.ts +0 -1
- package/development/autocomplete-grid.pure.js +328 -7
- package/development/core/datetime/date-helper.d.ts +0 -1
- package/development/core/timetable/access-leg-helper.d.ts +3 -3
- package/development/core/timetable/timetable-helper.d.ts +1 -2
- package/development/core/timetable/timetable-properties.d.ts +2 -1
- package/development/core.d.ts +0 -1
- package/development/core.js +1195 -5
- package/development/journey-summary/journey-summary.component.d.ts +3 -4
- package/development/journey-summary.d.ts +0 -1
- package/development/journey-summary.js +5 -5
- package/development/journey-summary.pure.d.ts +0 -1
- package/development/journey-summary.pure.js +2605 -2
- package/development/pearl-chain/pearl-chain.component.d.ts +2 -3
- package/development/pearl-chain-time/pearl-chain-time.component.d.ts +3 -4
- package/development/pearl-chain-time.d.ts +0 -1
- package/development/pearl-chain-time.js +5 -5
- package/development/pearl-chain-time.pure.d.ts +0 -1
- package/development/pearl-chain-time.pure.js +2582 -2
- package/development/pearl-chain-vertical/pearl-chain-vertical.component.d.ts +1 -2
- package/development/pearl-chain-vertical-item/pearl-chain-vertical-item.component.d.ts +1 -2
- package/development/pearl-chain-vertical-item.d.ts +0 -1
- package/development/pearl-chain-vertical-item.js +5 -5
- package/development/pearl-chain-vertical-item.pure.d.ts +0 -1
- package/development/pearl-chain-vertical-item.pure.js +132 -2
- package/development/pearl-chain-vertical.d.ts +0 -1
- package/development/pearl-chain-vertical.js +5 -5
- package/development/pearl-chain-vertical.pure.d.ts +0 -1
- package/development/pearl-chain-vertical.pure.js +31 -2
- package/development/pearl-chain.d.ts +0 -1
- package/development/pearl-chain.js +5 -5
- package/development/pearl-chain.pure.d.ts +0 -1
- package/development/pearl-chain.pure.js +619 -2
- package/development/seat-reservation/common/mapper/icon-mapper.d.ts +0 -1
- package/development/seat-reservation/common/mapper/mapper.d.ts +1 -2
- package/development/seat-reservation/common/mapper/sample-data/seat-reservation-sample-data-bus.private.d.ts +68 -0
- package/development/seat-reservation/common/mapper/sample-data/seat-reservation-sample-data-decks.private.d.ts +122 -0
- package/development/seat-reservation/common/mapper/sample-data/seat-reservation-sample-data-train.private.d.ts +68 -0
- package/development/seat-reservation/common/mapper.d.ts +0 -1
- package/development/seat-reservation/common/svgs.d.ts +20 -21
- package/development/seat-reservation/common/translations/i18n.d.ts +0 -1
- package/development/seat-reservation/common/translations.d.ts +0 -1
- package/development/seat-reservation/common/types.d.ts +0 -1
- package/development/seat-reservation/seat-reservation/seat-reservation-base-element.d.ts +2 -3
- package/development/seat-reservation/seat-reservation/seat-reservation.component.d.ts +2 -3
- package/development/seat-reservation/seat-reservation-area/seat-reservation-area.component.d.ts +1 -2
- package/development/seat-reservation/seat-reservation-graphic/seat-reservation-graphic.component.d.ts +2 -3
- package/development/seat-reservation/seat-reservation-navigation-coach/seat-reservation-navigation-coach.component.d.ts +3 -4
- package/development/seat-reservation/seat-reservation-navigation-services/seat-reservation-navigation-services.component.d.ts +2 -3
- package/development/seat-reservation/seat-reservation-place-control/seat-reservation-place-control.component.d.ts +3 -4
- package/development/seat-reservation/seat-reservation-scoped/seat-reservation-scoped.component.d.ts +1 -2
- package/development/seat-reservation.d.ts +0 -1
- package/development/seat-reservation.js +5 -16
- package/development/seat-reservation.pure.d.ts +0 -1
- package/development/seat-reservation.pure.js +16019 -14
- package/development/timetable-duration/timetable-duration.component.d.ts +1 -2
- package/development/timetable-duration.d.ts +0 -1
- package/development/timetable-duration.js +5 -5
- package/development/timetable-duration.pure.d.ts +0 -1
- package/development/timetable-duration.pure.js +97 -2
- package/development/timetable-row/timetable-row.component.d.ts +3 -4
- package/development/timetable-row.d.ts +0 -1
- package/development/timetable-row.js +5 -5
- package/development/timetable-row.pure.d.ts +0 -1
- package/development/timetable-row.pure.js +3005 -2
- package/journey-summary.js +1 -6
- package/journey-summary.pure.js +55 -2
- package/package.json +3 -4
- package/pearl-chain-time.js +1 -6
- package/pearl-chain-time.pure.js +28 -2
- package/pearl-chain-vertical-item.js +1 -6
- package/pearl-chain-vertical-item.pure.js +26 -2
- package/pearl-chain-vertical.js +1 -6
- package/pearl-chain-vertical.pure.js +6 -2
- package/pearl-chain.js +1 -6
- package/pearl-chain.pure.js +27 -2
- package/seat-reservation.js +1 -16
- package/seat-reservation.pure.js +468 -14
- package/timetable-duration.js +1 -6
- package/timetable-duration.pure.js +9 -2
- package/timetable-row.js +1 -6
- package/timetable-row.pure.js +113 -2
- package/autocomplete-grid/autocomplete-grid/autocomplete-grid.component.js +0 -65
- package/autocomplete-grid/autocomplete-grid-button/autocomplete-grid-button.component.js +0 -44
- package/autocomplete-grid/autocomplete-grid-cell/autocomplete-grid-cell.component.js +0 -2
- package/autocomplete-grid/autocomplete-grid-optgroup/autocomplete-grid-optgroup.component.js +0 -21
- package/autocomplete-grid/autocomplete-grid-option/autocomplete-grid-option.component.js +0 -2
- package/autocomplete-grid/autocomplete-grid-row/autocomplete-grid-row.component.js +0 -2
- package/autocomplete-grid-cell.component-79IjA__I.js +0 -23
- package/autocomplete-grid-option.component-DUFBhQwI.js +0 -35
- package/autocomplete-grid-row.component-B3U15Rwa.js +0 -26
- package/core/datetime/date-helper.js +0 -2
- package/core/timetable/access-leg-helper.js +0 -96
- package/core/timetable/timetable-helper.js +0 -10
- package/core/timetable/timetable-properties.js +0 -0
- package/date-helper-DNzMLcyb.js +0 -185
- package/development/autocomplete-grid/autocomplete-grid/autocomplete-grid.component.d.ts.map +0 -1
- package/development/autocomplete-grid/autocomplete-grid/autocomplete-grid.component.js +0 -118
- package/development/autocomplete-grid/autocomplete-grid-button/autocomplete-grid-button.component.d.ts.map +0 -1
- package/development/autocomplete-grid/autocomplete-grid-button/autocomplete-grid-button.component.js +0 -69
- package/development/autocomplete-grid/autocomplete-grid-cell/autocomplete-grid-cell.component.d.ts.map +0 -1
- package/development/autocomplete-grid/autocomplete-grid-cell/autocomplete-grid-cell.component.js +0 -2
- package/development/autocomplete-grid/autocomplete-grid-optgroup/autocomplete-grid-optgroup.component.d.ts.map +0 -1
- package/development/autocomplete-grid/autocomplete-grid-optgroup/autocomplete-grid-optgroup.component.js +0 -30
- package/development/autocomplete-grid/autocomplete-grid-option/autocomplete-grid-option.component.d.ts.map +0 -1
- package/development/autocomplete-grid/autocomplete-grid-option/autocomplete-grid-option.component.js +0 -2
- package/development/autocomplete-grid/autocomplete-grid-row/autocomplete-grid-row.component.d.ts.map +0 -1
- package/development/autocomplete-grid/autocomplete-grid-row/autocomplete-grid-row.component.js +0 -2
- package/development/autocomplete-grid-cell.component-BbdELDro.js +0 -33
- package/development/autocomplete-grid-option.component-C7WuqRit.js +0 -57
- package/development/autocomplete-grid-row.component-DoXbOsQM.js +0 -38
- package/development/autocomplete-grid.d.ts.map +0 -1
- package/development/autocomplete-grid.pure.d.ts.map +0 -1
- package/development/core/datetime/date-helper.d.ts.map +0 -1
- package/development/core/datetime/date-helper.js +0 -2
- package/development/core/timetable/access-leg-helper.d.ts.map +0 -1
- package/development/core/timetable/access-leg-helper.js +0 -147
- package/development/core/timetable/timetable-helper.d.ts.map +0 -1
- package/development/core/timetable/timetable-helper.js +0 -19
- package/development/core/timetable/timetable-properties.d.ts.map +0 -1
- package/development/core/timetable/timetable-properties.js +0 -0
- package/development/core.d.ts.map +0 -1
- package/development/date-helper-BcTDWVeP.js +0 -539
- package/development/differenceInMinutes-CxAbGYQ3.js +0 -110
- package/development/format-Cx3zmmaF.js +0 -1848
- package/development/isValid-40Olgzo1.js +0 -178
- package/development/journey-summary/journey-summary.component.d.ts.map +0 -1
- package/development/journey-summary/journey-summary.component.js +0 -2
- package/development/journey-summary.component-BsC7wBIn.js +0 -341
- package/development/journey-summary.d.ts.map +0 -1
- package/development/journey-summary.pure.d.ts.map +0 -1
- package/development/mapper-BrZOqqfe.js +0 -11454
- package/development/pearl-chain/pearl-chain.component.d.ts.map +0 -1
- package/development/pearl-chain/pearl-chain.component.js +0 -2
- package/development/pearl-chain-time/pearl-chain-time.component.d.ts.map +0 -1
- package/development/pearl-chain-time/pearl-chain-time.component.js +0 -2
- package/development/pearl-chain-time.component-C-CuC1ke.js +0 -317
- package/development/pearl-chain-time.d.ts.map +0 -1
- package/development/pearl-chain-time.pure.d.ts.map +0 -1
- package/development/pearl-chain-vertical/pearl-chain-vertical.component.d.ts.map +0 -1
- package/development/pearl-chain-vertical/pearl-chain-vertical.component.js +0 -2
- package/development/pearl-chain-vertical-item/pearl-chain-vertical-item.component.d.ts.map +0 -1
- package/development/pearl-chain-vertical-item/pearl-chain-vertical-item.component.js +0 -2
- package/development/pearl-chain-vertical-item.component-CLu9QrqJ.js +0 -131
- package/development/pearl-chain-vertical-item.d.ts.map +0 -1
- package/development/pearl-chain-vertical-item.pure.d.ts.map +0 -1
- package/development/pearl-chain-vertical.component-DbPz5k_R.js +0 -30
- package/development/pearl-chain-vertical.d.ts.map +0 -1
- package/development/pearl-chain-vertical.pure.d.ts.map +0 -1
- package/development/pearl-chain.component-10OsJZIX.js +0 -318
- package/development/pearl-chain.d.ts.map +0 -1
- package/development/pearl-chain.pure.d.ts.map +0 -1
- package/development/seat-reservation/common/mapper/icon-mapper.d.ts.map +0 -1
- package/development/seat-reservation/common/mapper/icon-mapper.js +0 -170
- package/development/seat-reservation/common/mapper/mapper.d.ts.map +0 -1
- package/development/seat-reservation/common/mapper/mapper.js +0 -2
- package/development/seat-reservation/common/mapper.d.ts.map +0 -1
- package/development/seat-reservation/common/mapper.js +0 -3
- package/development/seat-reservation/common/svgs.d.ts.map +0 -1
- package/development/seat-reservation/common/svgs.js +0 -2
- package/development/seat-reservation/common/translations/i18n.d.ts.map +0 -1
- package/development/seat-reservation/common/translations/i18n.js +0 -1120
- package/development/seat-reservation/common/translations.d.ts.map +0 -1
- package/development/seat-reservation/common/translations.js +0 -2
- package/development/seat-reservation/common/types.d.ts.map +0 -1
- package/development/seat-reservation/common/types.js +0 -0
- package/development/seat-reservation/seat-reservation/seat-reservation-base-element.d.ts.map +0 -1
- package/development/seat-reservation/seat-reservation/seat-reservation-base-element.js +0 -1476
- package/development/seat-reservation/seat-reservation/seat-reservation.component.d.ts.map +0 -1
- package/development/seat-reservation/seat-reservation/seat-reservation.component.js +0 -2
- package/development/seat-reservation/seat-reservation-area/seat-reservation-area.component.d.ts.map +0 -1
- package/development/seat-reservation/seat-reservation-area/seat-reservation-area.component.js +0 -2
- package/development/seat-reservation/seat-reservation-graphic/seat-reservation-graphic.component.d.ts.map +0 -1
- package/development/seat-reservation/seat-reservation-graphic/seat-reservation-graphic.component.js +0 -2
- package/development/seat-reservation/seat-reservation-navigation-coach/seat-reservation-navigation-coach.component.d.ts.map +0 -1
- package/development/seat-reservation/seat-reservation-navigation-coach/seat-reservation-navigation-coach.component.js +0 -2
- package/development/seat-reservation/seat-reservation-navigation-services/seat-reservation-navigation-services.component.d.ts.map +0 -1
- package/development/seat-reservation/seat-reservation-navigation-services/seat-reservation-navigation-services.component.js +0 -2
- package/development/seat-reservation/seat-reservation-place-control/seat-reservation-place-control.component.d.ts.map +0 -1
- package/development/seat-reservation/seat-reservation-place-control/seat-reservation-place-control.component.js +0 -2
- package/development/seat-reservation/seat-reservation-scoped/seat-reservation-scoped.component.d.ts.map +0 -1
- package/development/seat-reservation/seat-reservation-scoped/seat-reservation-scoped.component.js +0 -2
- package/development/seat-reservation-area.component-DPhQJFid.js +0 -94
- package/development/seat-reservation-graphic.component-0LYsmerm.js +0 -129
- package/development/seat-reservation-navigation-coach.component-B97jKD7Y.js +0 -438
- package/development/seat-reservation-navigation-services.component-Cx0Is97w.js +0 -159
- package/development/seat-reservation-place-control.component-DaL1g8WH.js +0 -431
- package/development/seat-reservation-scoped.component-BHbORVsR.js +0 -24
- package/development/seat-reservation.component-DI9pSlzt.js +0 -473
- package/development/seat-reservation.d.ts.map +0 -1
- package/development/seat-reservation.pure.d.ts.map +0 -1
- package/development/svgs-Dj-RKmRs.js +0 -28
- package/development/timetable-duration/timetable-duration.component.d.ts.map +0 -1
- package/development/timetable-duration/timetable-duration.component.js +0 -2
- package/development/timetable-duration.component-Chk5D4Is.js +0 -96
- package/development/timetable-duration.d.ts.map +0 -1
- package/development/timetable-duration.pure.d.ts.map +0 -1
- package/development/timetable-row/timetable-row.component.d.ts.map +0 -1
- package/development/timetable-row/timetable-row.component.js +0 -2
- package/development/timetable-row.component-nzrQzxL6.js +0 -736
- package/development/timetable-row.d.ts.map +0 -1
- package/development/timetable-row.pure.d.ts.map +0 -1
- package/development/toDate-CDWut5fS.js +0 -150
- package/differenceInMinutes-BAZ-Fham.js +0 -27
- package/format-DjgG1QPc.js +0 -1103
- package/isValid-CXnsFZVu.js +0 -36
- package/journey-summary/journey-summary.component.js +0 -2
- package/journey-summary.component-DNoO3OCf.js +0 -265
- package/mapper-Dcou8VEf.js +0 -11382
- package/pearl-chain/pearl-chain.component.js +0 -2
- package/pearl-chain-time/pearl-chain-time.component.js +0 -2
- package/pearl-chain-time.component-BuvA6IE1.js +0 -237
- package/pearl-chain-vertical/pearl-chain-vertical.component.js +0 -2
- package/pearl-chain-vertical-item/pearl-chain-vertical-item.component.js +0 -2
- package/pearl-chain-vertical-item.component-QZ4s8Jbv.js +0 -106
- package/pearl-chain-vertical.component-Dc3vaHsQ.js +0 -20
- package/pearl-chain.component-DtGXXkY6.js +0 -190
- package/seat-reservation/common/mapper/icon-mapper.js +0 -72
- package/seat-reservation/common/mapper/mapper.js +0 -2
- package/seat-reservation/common/mapper.js +0 -3
- package/seat-reservation/common/svgs.js +0 -2
- package/seat-reservation/common/translations/i18n.js +0 -1085
- package/seat-reservation/common/translations.js +0 -2
- package/seat-reservation/common/types.js +0 -0
- package/seat-reservation/seat-reservation/seat-reservation-base-element.js +0 -926
- package/seat-reservation/seat-reservation/seat-reservation.component.js +0 -2
- package/seat-reservation/seat-reservation-area/seat-reservation-area.component.js +0 -2
- package/seat-reservation/seat-reservation-graphic/seat-reservation-graphic.component.js +0 -2
- package/seat-reservation/seat-reservation-navigation-coach/seat-reservation-navigation-coach.component.js +0 -2
- package/seat-reservation/seat-reservation-navigation-services/seat-reservation-navigation-services.component.js +0 -2
- package/seat-reservation/seat-reservation-place-control/seat-reservation-place-control.component.js +0 -2
- package/seat-reservation/seat-reservation-scoped/seat-reservation-scoped.component.js +0 -2
- package/seat-reservation-area.component-G9lHb7S8.js +0 -73
- package/seat-reservation-graphic.component-BXFcQDxY.js +0 -102
- package/seat-reservation-navigation-coach.component-BXy8EkJe.js +0 -338
- package/seat-reservation-navigation-services.component-49XmV9rv.js +0 -124
- package/seat-reservation-place-control.component-DToIW328.js +0 -317
- package/seat-reservation-scoped.component-D8dAmrP7.js +0 -16
- package/seat-reservation.component--0XnrCkk.js +0 -372
- package/svgs-D4fuYTHV.js +0 -26
- package/timetable-duration/timetable-duration.component.js +0 -2
- package/timetable-duration.component-iMCvh1zr.js +0 -61
- package/timetable-row/timetable-row.component.js +0 -2
- package/timetable-row.component-mNKmhRmP.js +0 -566
- package/toDate-BhNUyM4s.js +0 -16
package/development/core.js
CHANGED
|
@@ -1,5 +1,1195 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { i18nDurationDay, i18nDurationHour, i18nDurationMinute, i18nWalkingDistanceArrival, i18nWalkingDistanceDeparture } from "@sbb-esta/lyne-elements/core.js";
|
|
2
|
+
import { html, nothing } from "lit";
|
|
3
|
+
import "@sbb-esta/lyne-elements/icon.pure.js";
|
|
4
|
+
|
|
5
|
+
//#region node_modules/date-fns/constants.js
|
|
6
|
+
/**
|
|
7
|
+
* @constant
|
|
8
|
+
* @name daysInYear
|
|
9
|
+
* @summary Days in 1 year.
|
|
10
|
+
*
|
|
11
|
+
* @description
|
|
12
|
+
* How many days in a year.
|
|
13
|
+
*
|
|
14
|
+
* One years equals 365.2425 days according to the formula:
|
|
15
|
+
*
|
|
16
|
+
* > Leap year occurs every 4 years, except for years that are divisible by 100 and not divisible by 400.
|
|
17
|
+
* > 1 mean year = (365+1/4-1/100+1/400) days = 365.2425 days
|
|
18
|
+
*/
|
|
19
|
+
const daysInYear = 365.2425;
|
|
20
|
+
/**
|
|
21
|
+
* @constant
|
|
22
|
+
* @name maxTime
|
|
23
|
+
* @summary Maximum allowed time.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* import { maxTime } from "./constants/date-fns/constants";
|
|
27
|
+
*
|
|
28
|
+
* const isValid = 8640000000000001 <= maxTime;
|
|
29
|
+
* //=> false
|
|
30
|
+
*
|
|
31
|
+
* new Date(8640000000000001);
|
|
32
|
+
* //=> Invalid Date
|
|
33
|
+
*/
|
|
34
|
+
const maxTime = Math.pow(10, 8) * 24 * 60 * 60 * 1e3;
|
|
35
|
+
/**
|
|
36
|
+
* @constant
|
|
37
|
+
* @name minTime
|
|
38
|
+
* @summary Minimum allowed time.
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* import { minTime } from "./constants/date-fns/constants";
|
|
42
|
+
*
|
|
43
|
+
* const isValid = -8640000000000001 >= minTime;
|
|
44
|
+
* //=> false
|
|
45
|
+
*
|
|
46
|
+
* new Date(-8640000000000001)
|
|
47
|
+
* //=> Invalid Date
|
|
48
|
+
*/
|
|
49
|
+
const minTime = -maxTime;
|
|
50
|
+
/**
|
|
51
|
+
* @constant
|
|
52
|
+
* @name millisecondsInDay
|
|
53
|
+
* @summary Milliseconds in 1 day.
|
|
54
|
+
*/
|
|
55
|
+
const millisecondsInDay = 864e5;
|
|
56
|
+
/**
|
|
57
|
+
* @constant
|
|
58
|
+
* @name millisecondsInMinute
|
|
59
|
+
* @summary Milliseconds in 1 minute
|
|
60
|
+
*/
|
|
61
|
+
const millisecondsInMinute = 6e4;
|
|
62
|
+
/**
|
|
63
|
+
* @constant
|
|
64
|
+
* @name millisecondsInHour
|
|
65
|
+
* @summary Milliseconds in 1 hour
|
|
66
|
+
*/
|
|
67
|
+
const millisecondsInHour = 36e5;
|
|
68
|
+
/**
|
|
69
|
+
* @constant
|
|
70
|
+
* @name secondsInHour
|
|
71
|
+
* @summary Seconds in 1 hour.
|
|
72
|
+
*/
|
|
73
|
+
const secondsInHour = 3600;
|
|
74
|
+
/**
|
|
75
|
+
* @constant
|
|
76
|
+
* @name secondsInDay
|
|
77
|
+
* @summary Seconds in 1 day.
|
|
78
|
+
*/
|
|
79
|
+
const secondsInDay = secondsInHour * 24;
|
|
80
|
+
/**
|
|
81
|
+
* @constant
|
|
82
|
+
* @name secondsInWeek
|
|
83
|
+
* @summary Seconds in 1 week.
|
|
84
|
+
*/
|
|
85
|
+
const secondsInWeek = secondsInDay * 7;
|
|
86
|
+
/**
|
|
87
|
+
* @constant
|
|
88
|
+
* @name secondsInYear
|
|
89
|
+
* @summary Seconds in 1 year.
|
|
90
|
+
*/
|
|
91
|
+
const secondsInYear = secondsInDay * daysInYear;
|
|
92
|
+
/**
|
|
93
|
+
* @constant
|
|
94
|
+
* @name secondsInMonth
|
|
95
|
+
* @summary Seconds in 1 month
|
|
96
|
+
*/
|
|
97
|
+
const secondsInMonth = secondsInYear / 12;
|
|
98
|
+
/**
|
|
99
|
+
* @constant
|
|
100
|
+
* @name secondsInQuarter
|
|
101
|
+
* @summary Seconds in 1 quarter.
|
|
102
|
+
*/
|
|
103
|
+
const secondsInQuarter = secondsInMonth * 3;
|
|
104
|
+
/**
|
|
105
|
+
* @constant
|
|
106
|
+
* @name constructFromSymbol
|
|
107
|
+
* @summary Symbol enabling Date extensions to inherit properties from the reference date.
|
|
108
|
+
*
|
|
109
|
+
* The symbol is used to enable the `constructFrom` function to construct a date
|
|
110
|
+
* using a reference date and a value. It allows to transfer extra properties
|
|
111
|
+
* from the reference date to the new date. It's useful for extensions like
|
|
112
|
+
* [`TZDate`](https://github.com/date-fns/tz) that accept a time zone as
|
|
113
|
+
* a constructor argument.
|
|
114
|
+
*/
|
|
115
|
+
const constructFromSymbol = Symbol.for("constructDateFrom");
|
|
116
|
+
|
|
117
|
+
//#endregion
|
|
118
|
+
//#region node_modules/date-fns/constructFrom.js
|
|
119
|
+
/**
|
|
120
|
+
* @name constructFrom
|
|
121
|
+
* @category Generic Helpers
|
|
122
|
+
* @summary Constructs a date using the reference date and the value
|
|
123
|
+
*
|
|
124
|
+
* @description
|
|
125
|
+
* The function constructs a new date using the constructor from the reference
|
|
126
|
+
* date and the given value. It helps to build generic functions that accept
|
|
127
|
+
* date extensions.
|
|
128
|
+
*
|
|
129
|
+
* It defaults to `Date` if the passed reference date is a number or a string.
|
|
130
|
+
*
|
|
131
|
+
* Starting from v3.7.0, it allows to construct a date using `[Symbol.for("constructDateFrom")]`
|
|
132
|
+
* enabling to transfer extra properties from the reference date to the new date.
|
|
133
|
+
* It's useful for extensions like [`TZDate`](https://github.com/date-fns/tz)
|
|
134
|
+
* that accept a time zone as a constructor argument.
|
|
135
|
+
*
|
|
136
|
+
* @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
|
|
137
|
+
*
|
|
138
|
+
* @param date - The reference date to take constructor from
|
|
139
|
+
* @param value - The value to create the date
|
|
140
|
+
*
|
|
141
|
+
* @returns Date initialized using the given date and value
|
|
142
|
+
*
|
|
143
|
+
* @example
|
|
144
|
+
* import { constructFrom } from "./constructFrom/date-fns";
|
|
145
|
+
*
|
|
146
|
+
* // A function that clones a date preserving the original type
|
|
147
|
+
* function cloneDate<DateType extends Date>(date: DateType): DateType {
|
|
148
|
+
* return constructFrom(
|
|
149
|
+
* date, // Use constructor from the given date
|
|
150
|
+
* date.getTime() // Use the date value to create a new date
|
|
151
|
+
* );
|
|
152
|
+
* }
|
|
153
|
+
*/
|
|
154
|
+
function constructFrom(date, value) {
|
|
155
|
+
if (typeof date === "function") return date(value);
|
|
156
|
+
if (date && typeof date === "object" && constructFromSymbol in date) return date[constructFromSymbol](value);
|
|
157
|
+
if (date instanceof Date) return new date.constructor(value);
|
|
158
|
+
return new Date(value);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
//#endregion
|
|
162
|
+
//#region node_modules/date-fns/toDate.js
|
|
163
|
+
/**
|
|
164
|
+
* @name toDate
|
|
165
|
+
* @category Common Helpers
|
|
166
|
+
* @summary Convert the given argument to an instance of Date.
|
|
167
|
+
*
|
|
168
|
+
* @description
|
|
169
|
+
* Convert the given argument to an instance of Date.
|
|
170
|
+
*
|
|
171
|
+
* If the argument is an instance of Date, the function returns its clone.
|
|
172
|
+
*
|
|
173
|
+
* If the argument is a number, it is treated as a timestamp.
|
|
174
|
+
*
|
|
175
|
+
* If the argument is none of the above, the function returns Invalid Date.
|
|
176
|
+
*
|
|
177
|
+
* Starting from v3.7.0, it clones a date using `[Symbol.for("constructDateFrom")]`
|
|
178
|
+
* enabling to transfer extra properties from the reference date to the new date.
|
|
179
|
+
* It's useful for extensions like [`TZDate`](https://github.com/date-fns/tz)
|
|
180
|
+
* that accept a time zone as a constructor argument.
|
|
181
|
+
*
|
|
182
|
+
* **Note**: *all* Date arguments passed to any *date-fns* function is processed by `toDate`.
|
|
183
|
+
*
|
|
184
|
+
* @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
|
|
185
|
+
* @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments.
|
|
186
|
+
*
|
|
187
|
+
* @param argument - The value to convert
|
|
188
|
+
*
|
|
189
|
+
* @returns The parsed date in the local time zone
|
|
190
|
+
*
|
|
191
|
+
* @example
|
|
192
|
+
* // Clone the date:
|
|
193
|
+
* const result = toDate(new Date(2014, 1, 11, 11, 30, 30))
|
|
194
|
+
* //=> Tue Feb 11 2014 11:30:30
|
|
195
|
+
*
|
|
196
|
+
* @example
|
|
197
|
+
* // Convert the timestamp to date:
|
|
198
|
+
* const result = toDate(1392098430000)
|
|
199
|
+
* //=> Tue Feb 11 2014 11:30:30
|
|
200
|
+
*/
|
|
201
|
+
function toDate(argument, context) {
|
|
202
|
+
return constructFrom(context || argument, argument);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
//#endregion
|
|
206
|
+
//#region node_modules/date-fns/addDays.js
|
|
207
|
+
/**
|
|
208
|
+
* The {@link addDays} function options.
|
|
209
|
+
*/
|
|
210
|
+
/**
|
|
211
|
+
* @name addDays
|
|
212
|
+
* @category Day Helpers
|
|
213
|
+
* @summary Add the specified number of days to the given date.
|
|
214
|
+
*
|
|
215
|
+
* @description
|
|
216
|
+
* Add the specified number of days to the given date.
|
|
217
|
+
*
|
|
218
|
+
* **You don't need date-fns\***:
|
|
219
|
+
*
|
|
220
|
+
* Temporal has a built-in `add` method on all its classes:
|
|
221
|
+
*
|
|
222
|
+
* - [`Temporal.Instant.prototype.add()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Temporal/Instant/add)
|
|
223
|
+
* - [`Temporal.PlainDate.prototype.add()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Temporal/PlainDate/add)
|
|
224
|
+
* - [`Temporal.PlainDateTime.prototype.add()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Temporal/PlainDateTime/add)
|
|
225
|
+
* - [`Temporal.PlainTime.prototype.add()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Temporal/PlainTime/add)
|
|
226
|
+
* - [`Temporal.PlainYearMonth.prototype.add()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Temporal/PlainYearMonth/add)
|
|
227
|
+
* - [`Temporal.ZonedDateTime.prototype.add()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Temporal/ZonedDateTime/add)
|
|
228
|
+
*
|
|
229
|
+
* \* **Not really**, see: https://date-fns.org/you-dont-need-date-fns
|
|
230
|
+
*
|
|
231
|
+
* @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
|
|
232
|
+
* @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments.
|
|
233
|
+
*
|
|
234
|
+
* @param date - The date to be changed
|
|
235
|
+
* @param amount - The amount of days to be added.
|
|
236
|
+
* @param options - An object with options
|
|
237
|
+
*
|
|
238
|
+
* @returns The new date with the days added
|
|
239
|
+
*
|
|
240
|
+
* @example
|
|
241
|
+
* // Add 10 days to 1 September 2014:
|
|
242
|
+
* const result = addDays(new Date(2014, 8, 1), 10)
|
|
243
|
+
* //=> Thu Sep 11 2014 00:00:00
|
|
244
|
+
*
|
|
245
|
+
* @example
|
|
246
|
+
* // Using Temporal:
|
|
247
|
+
* // Add 10 days to 1 September 2014:
|
|
248
|
+
* Temporal.PlainDate.from("2014-09-01").add({ days: 10 }).toString();
|
|
249
|
+
* //=> "2014-09-11"
|
|
250
|
+
*/
|
|
251
|
+
function addDays(date, amount, options) {
|
|
252
|
+
const _date = toDate(date, options?.in);
|
|
253
|
+
if (isNaN(amount)) return constructFrom(options?.in || date, NaN);
|
|
254
|
+
if (!amount) return _date;
|
|
255
|
+
_date.setDate(_date.getDate() + amount);
|
|
256
|
+
return _date;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
//#endregion
|
|
260
|
+
//#region node_modules/date-fns/addMilliseconds.js
|
|
261
|
+
/**
|
|
262
|
+
* The {@link addMilliseconds} function options.
|
|
263
|
+
*/
|
|
264
|
+
/**
|
|
265
|
+
* @name addMilliseconds
|
|
266
|
+
* @category Millisecond Helpers
|
|
267
|
+
* @summary Add the specified number of milliseconds to the given date.
|
|
268
|
+
*
|
|
269
|
+
* @description
|
|
270
|
+
* Add the specified number of milliseconds to the given date.
|
|
271
|
+
*
|
|
272
|
+
* @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
|
|
273
|
+
* @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments.
|
|
274
|
+
*
|
|
275
|
+
* @param date - The date to be changed
|
|
276
|
+
* @param amount - The amount of milliseconds to be added.
|
|
277
|
+
* @param options - The options object
|
|
278
|
+
*
|
|
279
|
+
* @returns The new date with the milliseconds added
|
|
280
|
+
*
|
|
281
|
+
* @example
|
|
282
|
+
* // Add 750 milliseconds to 10 July 2014 12:45:30.000:
|
|
283
|
+
* const result = addMilliseconds(new Date(2014, 6, 10, 12, 45, 30, 0), 750)
|
|
284
|
+
* //=> Thu Jul 10 2014 12:45:30.750
|
|
285
|
+
*/
|
|
286
|
+
function addMilliseconds(date, amount, options) {
|
|
287
|
+
return constructFrom(options?.in || date, +toDate(date) + amount);
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
//#endregion
|
|
291
|
+
//#region node_modules/date-fns/addHours.js
|
|
292
|
+
/**
|
|
293
|
+
* The {@link addHours} function options.
|
|
294
|
+
*/
|
|
295
|
+
/**
|
|
296
|
+
* @name addHours
|
|
297
|
+
* @category Hour Helpers
|
|
298
|
+
* @summary Add the specified number of hours to the given date.
|
|
299
|
+
*
|
|
300
|
+
* @description
|
|
301
|
+
* Add the specified number of hours to the given date.
|
|
302
|
+
*
|
|
303
|
+
* @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
|
|
304
|
+
* @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments.
|
|
305
|
+
*
|
|
306
|
+
* @param date - The date to be changed
|
|
307
|
+
* @param amount - The amount of hours to be added
|
|
308
|
+
* @param options - An object with options
|
|
309
|
+
*
|
|
310
|
+
* @returns The new date with the hours added
|
|
311
|
+
*
|
|
312
|
+
* @example
|
|
313
|
+
* // Add 2 hours to 10 July 2014 23:00:00:
|
|
314
|
+
* const result = addHours(new Date(2014, 6, 10, 23, 0), 2)
|
|
315
|
+
* //=> Fri Jul 11 2014 01:00:00
|
|
316
|
+
*/
|
|
317
|
+
function addHours(date, amount, options) {
|
|
318
|
+
return addMilliseconds(date, amount * millisecondsInHour, options);
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
//#endregion
|
|
322
|
+
//#region node_modules/date-fns/_lib/getTimezoneOffsetInMilliseconds.js
|
|
323
|
+
/**
|
|
324
|
+
* Google Chrome as of 67.0.3396.87 introduced timezones with offset that includes seconds.
|
|
325
|
+
* They usually appear for dates that denote time before the timezones were introduced
|
|
326
|
+
* (e.g. for 'Europe/Prague' timezone the offset is GMT+00:57:44 before 1 October 1891
|
|
327
|
+
* and GMT+01:00:00 after that date)
|
|
328
|
+
*
|
|
329
|
+
* Date#getTimezoneOffset returns the offset in minutes and would return 57 for the example above,
|
|
330
|
+
* which would lead to incorrect calculations.
|
|
331
|
+
*
|
|
332
|
+
* This function returns the timezone offset in milliseconds that takes seconds in account.
|
|
333
|
+
*/
|
|
334
|
+
function getTimezoneOffsetInMilliseconds(date) {
|
|
335
|
+
const _date = toDate(date);
|
|
336
|
+
const utcDate = new Date(Date.UTC(_date.getFullYear(), _date.getMonth(), _date.getDate(), _date.getHours(), _date.getMinutes(), _date.getSeconds(), _date.getMilliseconds()));
|
|
337
|
+
utcDate.setUTCFullYear(_date.getFullYear());
|
|
338
|
+
return +date - +utcDate;
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
//#endregion
|
|
342
|
+
//#region node_modules/date-fns/_lib/normalizeDates.js
|
|
343
|
+
function normalizeDates(context, ...dates) {
|
|
344
|
+
const normalize = constructFrom.bind(null, context || dates.find((date) => typeof date === "object"));
|
|
345
|
+
return dates.map(normalize);
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
//#endregion
|
|
349
|
+
//#region node_modules/date-fns/startOfDay.js
|
|
350
|
+
/**
|
|
351
|
+
* The {@link startOfDay} function options.
|
|
352
|
+
*/
|
|
353
|
+
/**
|
|
354
|
+
* @name startOfDay
|
|
355
|
+
* @category Day Helpers
|
|
356
|
+
* @summary Return the start of a day for the given date.
|
|
357
|
+
*
|
|
358
|
+
* @description
|
|
359
|
+
* Return the start of a day for the given date.
|
|
360
|
+
* The result will be in the local timezone.
|
|
361
|
+
*
|
|
362
|
+
* @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
|
|
363
|
+
* @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments.
|
|
364
|
+
*
|
|
365
|
+
* @param date - The original date
|
|
366
|
+
* @param options - The options
|
|
367
|
+
*
|
|
368
|
+
* @returns The start of a day
|
|
369
|
+
*
|
|
370
|
+
* @example
|
|
371
|
+
* // The start of a day for 2 September 2014 11:55:00:
|
|
372
|
+
* const result = startOfDay(new Date(2014, 8, 2, 11, 55, 0))
|
|
373
|
+
* //=> Tue Sep 02 2014 00:00:00
|
|
374
|
+
*/
|
|
375
|
+
function startOfDay(date, options) {
|
|
376
|
+
const _date = toDate(date, options?.in);
|
|
377
|
+
_date.setHours(0, 0, 0, 0);
|
|
378
|
+
return _date;
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
//#endregion
|
|
382
|
+
//#region node_modules/date-fns/differenceInCalendarDays.js
|
|
383
|
+
/**
|
|
384
|
+
* The {@link differenceInCalendarDays} function options.
|
|
385
|
+
*/
|
|
386
|
+
/**
|
|
387
|
+
* @name differenceInCalendarDays
|
|
388
|
+
* @category Day Helpers
|
|
389
|
+
* @summary Get the number of calendar days between the given dates.
|
|
390
|
+
*
|
|
391
|
+
* @description
|
|
392
|
+
* Get the number of calendar days between the given dates. This means that the times are removed
|
|
393
|
+
* from the dates and then the difference in days is calculated.
|
|
394
|
+
*
|
|
395
|
+
* @param laterDate - The later date
|
|
396
|
+
* @param earlierDate - The earlier date
|
|
397
|
+
* @param options - The options object
|
|
398
|
+
*
|
|
399
|
+
* @returns The number of calendar days
|
|
400
|
+
*
|
|
401
|
+
* @example
|
|
402
|
+
* // How many calendar days are between
|
|
403
|
+
* // 2 July 2011 23:00:00 and 2 July 2012 00:00:00?
|
|
404
|
+
* const result = differenceInCalendarDays(
|
|
405
|
+
* new Date(2012, 6, 2, 0, 0),
|
|
406
|
+
* new Date(2011, 6, 2, 23, 0)
|
|
407
|
+
* )
|
|
408
|
+
* //=> 366
|
|
409
|
+
* // How many calendar days are between
|
|
410
|
+
* // 2 July 2011 23:59:00 and 3 July 2011 00:01:00?
|
|
411
|
+
* const result = differenceInCalendarDays(
|
|
412
|
+
* new Date(2011, 6, 3, 0, 1),
|
|
413
|
+
* new Date(2011, 6, 2, 23, 59)
|
|
414
|
+
* )
|
|
415
|
+
* //=> 1
|
|
416
|
+
*/
|
|
417
|
+
function differenceInCalendarDays(laterDate, earlierDate, options) {
|
|
418
|
+
const [laterDate_, earlierDate_] = normalizeDates(options?.in, laterDate, earlierDate);
|
|
419
|
+
const laterStartOfDay = startOfDay(laterDate_);
|
|
420
|
+
const earlierStartOfDay = startOfDay(earlierDate_);
|
|
421
|
+
const laterTimestamp = +laterStartOfDay - getTimezoneOffsetInMilliseconds(laterStartOfDay);
|
|
422
|
+
const earlierTimestamp = +earlierStartOfDay - getTimezoneOffsetInMilliseconds(earlierStartOfDay);
|
|
423
|
+
return Math.round((laterTimestamp - earlierTimestamp) / millisecondsInDay);
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
//#endregion
|
|
427
|
+
//#region node_modules/date-fns/addMinutes.js
|
|
428
|
+
/**
|
|
429
|
+
* The {@link addMinutes} function options.
|
|
430
|
+
*/
|
|
431
|
+
/**
|
|
432
|
+
* @name addMinutes
|
|
433
|
+
* @category Minute Helpers
|
|
434
|
+
* @summary Add the specified number of minutes to the given date.
|
|
435
|
+
*
|
|
436
|
+
* @description
|
|
437
|
+
* Add the specified number of minutes to the given date.
|
|
438
|
+
*
|
|
439
|
+
* @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
|
|
440
|
+
* @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments.
|
|
441
|
+
*
|
|
442
|
+
* @param date - The date to be changed
|
|
443
|
+
* @param amount - The amount of minutes to be added.
|
|
444
|
+
* @param options - An object with options
|
|
445
|
+
*
|
|
446
|
+
* @returns The new date with the minutes added
|
|
447
|
+
*
|
|
448
|
+
* @example
|
|
449
|
+
* // Add 30 minutes to 10 July 2014 12:00:00:
|
|
450
|
+
* const result = addMinutes(new Date(2014, 6, 10, 12, 0), 30)
|
|
451
|
+
* //=> Thu Jul 10 2014 12:30:00
|
|
452
|
+
*/
|
|
453
|
+
function addMinutes(date, amount, options) {
|
|
454
|
+
const _date = toDate(date, options?.in);
|
|
455
|
+
_date.setTime(_date.getTime() + amount * millisecondsInMinute);
|
|
456
|
+
return _date;
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
//#endregion
|
|
460
|
+
//#region node_modules/date-fns/isDate.js
|
|
461
|
+
/**
|
|
462
|
+
* @name isDate
|
|
463
|
+
* @category Common Helpers
|
|
464
|
+
* @summary Is the given value a date?
|
|
465
|
+
*
|
|
466
|
+
* @description
|
|
467
|
+
* Returns true if the given value is an instance of Date. The function works for dates transferred across iframes.
|
|
468
|
+
*
|
|
469
|
+
* @param value - The value to check
|
|
470
|
+
*
|
|
471
|
+
* @returns True if the given value is a date
|
|
472
|
+
*
|
|
473
|
+
* @example
|
|
474
|
+
* // For a valid date:
|
|
475
|
+
* const result = isDate(new Date())
|
|
476
|
+
* //=> true
|
|
477
|
+
*
|
|
478
|
+
* @example
|
|
479
|
+
* // For an invalid date:
|
|
480
|
+
* const result = isDate(new Date(NaN))
|
|
481
|
+
* //=> true
|
|
482
|
+
*
|
|
483
|
+
* @example
|
|
484
|
+
* // For some value:
|
|
485
|
+
* const result = isDate('2014-02-31')
|
|
486
|
+
* //=> false
|
|
487
|
+
*
|
|
488
|
+
* @example
|
|
489
|
+
* // For an object:
|
|
490
|
+
* const result = isDate({})
|
|
491
|
+
* //=> false
|
|
492
|
+
*/
|
|
493
|
+
function isDate(value) {
|
|
494
|
+
return value instanceof Date || typeof value === "object" && Object.prototype.toString.call(value) === "[object Date]";
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
//#endregion
|
|
498
|
+
//#region node_modules/date-fns/isValid.js
|
|
499
|
+
/**
|
|
500
|
+
* @name isValid
|
|
501
|
+
* @category Common Helpers
|
|
502
|
+
* @summary Is the given date valid?
|
|
503
|
+
*
|
|
504
|
+
* @description
|
|
505
|
+
* Returns false if argument is Invalid Date and true otherwise.
|
|
506
|
+
* Argument is converted to Date using `toDate`. See [toDate](https://date-fns.org/docs/toDate)
|
|
507
|
+
* Invalid Date is a Date, whose time value is NaN.
|
|
508
|
+
*
|
|
509
|
+
* Time value of Date: http://es5.github.io/#x15.9.1.1
|
|
510
|
+
*
|
|
511
|
+
* @param date - The date to check
|
|
512
|
+
*
|
|
513
|
+
* @returns The date is valid
|
|
514
|
+
*
|
|
515
|
+
* @example
|
|
516
|
+
* // For the valid date:
|
|
517
|
+
* const result = isValid(new Date(2014, 1, 31))
|
|
518
|
+
* //=> true
|
|
519
|
+
*
|
|
520
|
+
* @example
|
|
521
|
+
* // For the value, convertible into a date:
|
|
522
|
+
* const result = isValid(1393804800000)
|
|
523
|
+
* //=> true
|
|
524
|
+
*
|
|
525
|
+
* @example
|
|
526
|
+
* // For the invalid date:
|
|
527
|
+
* const result = isValid(new Date(''))
|
|
528
|
+
* //=> false
|
|
529
|
+
*/
|
|
530
|
+
function isValid(date) {
|
|
531
|
+
return !(!isDate(date) && typeof date !== "number" || isNaN(+toDate(date)));
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
//#endregion
|
|
535
|
+
//#region node_modules/date-fns/differenceInDays.js
|
|
536
|
+
/**
|
|
537
|
+
* The {@link differenceInDays} function options.
|
|
538
|
+
*/
|
|
539
|
+
/**
|
|
540
|
+
* @name differenceInDays
|
|
541
|
+
* @category Day Helpers
|
|
542
|
+
* @summary Get the number of full days between the given dates.
|
|
543
|
+
*
|
|
544
|
+
* @description
|
|
545
|
+
* Get the number of full day periods between two dates. Fractional days are
|
|
546
|
+
* truncated towards zero.
|
|
547
|
+
*
|
|
548
|
+
* One "full day" is the distance between a local time in one day to the same
|
|
549
|
+
* local time on the next or previous day. A full day can sometimes be less than
|
|
550
|
+
* or more than 24 hours if a daylight savings change happens between two dates.
|
|
551
|
+
*
|
|
552
|
+
* To ignore DST and only measure exact 24-hour periods, use this instead:
|
|
553
|
+
* `Math.trunc(differenceInHours(dateLeft, dateRight)/24)|0`.
|
|
554
|
+
*
|
|
555
|
+
* @param laterDate - The later date
|
|
556
|
+
* @param earlierDate - The earlier date
|
|
557
|
+
* @param options - An object with options
|
|
558
|
+
*
|
|
559
|
+
* @returns The number of full days according to the local timezone
|
|
560
|
+
*
|
|
561
|
+
* @example
|
|
562
|
+
* // How many full days are between
|
|
563
|
+
* // 2 July 2011 23:00:00 and 2 July 2012 00:00:00?
|
|
564
|
+
* const result = differenceInDays(
|
|
565
|
+
* new Date(2012, 6, 2, 0, 0),
|
|
566
|
+
* new Date(2011, 6, 2, 23, 0)
|
|
567
|
+
* )
|
|
568
|
+
* //=> 365
|
|
569
|
+
*
|
|
570
|
+
* @example
|
|
571
|
+
* // How many full days are between
|
|
572
|
+
* // 2 July 2011 23:59:00 and 3 July 2011 00:01:00?
|
|
573
|
+
* const result = differenceInDays(
|
|
574
|
+
* new Date(2011, 6, 3, 0, 1),
|
|
575
|
+
* new Date(2011, 6, 2, 23, 59)
|
|
576
|
+
* )
|
|
577
|
+
* //=> 0
|
|
578
|
+
*
|
|
579
|
+
* @example
|
|
580
|
+
* // How many full days are between
|
|
581
|
+
* // 1 March 2020 0:00 and 1 June 2020 0:00 ?
|
|
582
|
+
* // Note: because local time is used, the
|
|
583
|
+
* // result will always be 92 days, even in
|
|
584
|
+
* // time zones where DST starts and the
|
|
585
|
+
* // period has only 92*24-1 hours.
|
|
586
|
+
* const result = differenceInDays(
|
|
587
|
+
* new Date(2020, 5, 1),
|
|
588
|
+
* new Date(2020, 2, 1)
|
|
589
|
+
* )
|
|
590
|
+
* //=> 92
|
|
591
|
+
*/
|
|
592
|
+
function differenceInDays(laterDate, earlierDate, options) {
|
|
593
|
+
const [laterDate_, earlierDate_] = normalizeDates(options?.in, laterDate, earlierDate);
|
|
594
|
+
const sign = compareLocalAsc(laterDate_, earlierDate_);
|
|
595
|
+
const difference = Math.abs(differenceInCalendarDays(laterDate_, earlierDate_));
|
|
596
|
+
laterDate_.setDate(laterDate_.getDate() - sign * difference);
|
|
597
|
+
const result = sign * (difference - Number(compareLocalAsc(laterDate_, earlierDate_) === -sign));
|
|
598
|
+
return result === 0 ? 0 : result;
|
|
599
|
+
}
|
|
600
|
+
function compareLocalAsc(laterDate, earlierDate) {
|
|
601
|
+
const diff = laterDate.getFullYear() - earlierDate.getFullYear() || laterDate.getMonth() - earlierDate.getMonth() || laterDate.getDate() - earlierDate.getDate() || laterDate.getHours() - earlierDate.getHours() || laterDate.getMinutes() - earlierDate.getMinutes() || laterDate.getSeconds() - earlierDate.getSeconds() || laterDate.getMilliseconds() - earlierDate.getMilliseconds();
|
|
602
|
+
if (diff < 0) return -1;
|
|
603
|
+
if (diff > 0) return 1;
|
|
604
|
+
return diff;
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
//#endregion
|
|
608
|
+
//#region node_modules/date-fns/_lib/getRoundingMethod.js
|
|
609
|
+
function getRoundingMethod(method) {
|
|
610
|
+
return (number) => {
|
|
611
|
+
const result = (method ? Math[method] : Math.trunc)(number);
|
|
612
|
+
return result === 0 ? 0 : result;
|
|
613
|
+
};
|
|
614
|
+
}
|
|
615
|
+
|
|
616
|
+
//#endregion
|
|
617
|
+
//#region node_modules/date-fns/differenceInHours.js
|
|
618
|
+
/**
|
|
619
|
+
* The {@link differenceInHours} function options.
|
|
620
|
+
*/
|
|
621
|
+
/**
|
|
622
|
+
* @name differenceInHours
|
|
623
|
+
* @category Hour Helpers
|
|
624
|
+
* @summary Get the number of hours between the given dates.
|
|
625
|
+
*
|
|
626
|
+
* @description
|
|
627
|
+
* Get the number of hours between the given dates.
|
|
628
|
+
*
|
|
629
|
+
* @param laterDate - The later date
|
|
630
|
+
* @param earlierDate - The earlier date
|
|
631
|
+
* @param options - An object with options.
|
|
632
|
+
*
|
|
633
|
+
* @returns The number of hours
|
|
634
|
+
*
|
|
635
|
+
* @example
|
|
636
|
+
* // How many hours are between 2 July 2014 06:50:00 and 2 July 2014 19:00:00?
|
|
637
|
+
* const result = differenceInHours(
|
|
638
|
+
* new Date(2014, 6, 2, 19, 0),
|
|
639
|
+
* new Date(2014, 6, 2, 6, 50)
|
|
640
|
+
* )
|
|
641
|
+
* //=> 12
|
|
642
|
+
*/
|
|
643
|
+
function differenceInHours(laterDate, earlierDate, options) {
|
|
644
|
+
const [laterDate_, earlierDate_] = normalizeDates(options?.in, laterDate, earlierDate);
|
|
645
|
+
const diff = (+laterDate_ - +earlierDate_) / millisecondsInHour;
|
|
646
|
+
return getRoundingMethod(options?.roundingMethod)(diff);
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
//#endregion
|
|
650
|
+
//#region node_modules/date-fns/differenceInMilliseconds.js
|
|
651
|
+
/**
|
|
652
|
+
* @name differenceInMilliseconds
|
|
653
|
+
* @category Millisecond Helpers
|
|
654
|
+
* @summary Get the number of milliseconds between the given dates.
|
|
655
|
+
*
|
|
656
|
+
* @description
|
|
657
|
+
* Get the number of milliseconds between the given dates.
|
|
658
|
+
*
|
|
659
|
+
* @param laterDate - The later date
|
|
660
|
+
* @param earlierDate - The earlier date
|
|
661
|
+
*
|
|
662
|
+
* @returns The number of milliseconds
|
|
663
|
+
*
|
|
664
|
+
* @example
|
|
665
|
+
* // How many milliseconds are between
|
|
666
|
+
* // 2 July 2014 12:30:20.600 and 2 July 2014 12:30:21.700?
|
|
667
|
+
* const result = differenceInMilliseconds(
|
|
668
|
+
* new Date(2014, 6, 2, 12, 30, 21, 700),
|
|
669
|
+
* new Date(2014, 6, 2, 12, 30, 20, 600)
|
|
670
|
+
* )
|
|
671
|
+
* //=> 1100
|
|
672
|
+
*/
|
|
673
|
+
function differenceInMilliseconds(laterDate, earlierDate) {
|
|
674
|
+
return +toDate(laterDate) - +toDate(earlierDate);
|
|
675
|
+
}
|
|
676
|
+
|
|
677
|
+
//#endregion
|
|
678
|
+
//#region node_modules/date-fns/differenceInMinutes.js
|
|
679
|
+
/**
|
|
680
|
+
* The {@link differenceInMinutes} function options.
|
|
681
|
+
*/
|
|
682
|
+
/**
|
|
683
|
+
* @name differenceInMinutes
|
|
684
|
+
* @category Minute Helpers
|
|
685
|
+
* @summary Get the number of minutes between the given dates.
|
|
686
|
+
*
|
|
687
|
+
* @description
|
|
688
|
+
* Get the signed number of full (rounded towards 0) minutes between the given dates.
|
|
689
|
+
*
|
|
690
|
+
* @param dateLeft - The later date
|
|
691
|
+
* @param dateRight - The earlier date
|
|
692
|
+
* @param options - An object with options.
|
|
693
|
+
*
|
|
694
|
+
* @returns The number of minutes
|
|
695
|
+
*
|
|
696
|
+
* @example
|
|
697
|
+
* // How many minutes are between 2 July 2014 12:07:59 and 2 July 2014 12:20:00?
|
|
698
|
+
* const result = differenceInMinutes(
|
|
699
|
+
* new Date(2014, 6, 2, 12, 20, 0),
|
|
700
|
+
* new Date(2014, 6, 2, 12, 7, 59)
|
|
701
|
+
* )
|
|
702
|
+
* //=> 12
|
|
703
|
+
*
|
|
704
|
+
* @example
|
|
705
|
+
* // How many minutes are between 10:01:59 and 10:00:00
|
|
706
|
+
* const result = differenceInMinutes(
|
|
707
|
+
* new Date(2000, 0, 1, 10, 0, 0),
|
|
708
|
+
* new Date(2000, 0, 1, 10, 1, 59)
|
|
709
|
+
* )
|
|
710
|
+
* //=> -1
|
|
711
|
+
*/
|
|
712
|
+
function differenceInMinutes(dateLeft, dateRight, options) {
|
|
713
|
+
const diff = differenceInMilliseconds(dateLeft, dateRight) / millisecondsInMinute;
|
|
714
|
+
return getRoundingMethod(options?.roundingMethod)(diff);
|
|
715
|
+
}
|
|
716
|
+
|
|
717
|
+
//#endregion
|
|
718
|
+
//#region node_modules/date-fns/subDays.js
|
|
719
|
+
/**
|
|
720
|
+
* The {@link subDays} function options.
|
|
721
|
+
*/
|
|
722
|
+
/**
|
|
723
|
+
* @name subDays
|
|
724
|
+
* @category Day Helpers
|
|
725
|
+
* @summary Subtract the specified number of days from the given date.
|
|
726
|
+
*
|
|
727
|
+
* @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
|
|
728
|
+
* @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments.
|
|
729
|
+
*
|
|
730
|
+
* @param date - The date to be changed
|
|
731
|
+
* @param amount - The amount of days to be subtracted.
|
|
732
|
+
* @param options - An object with options
|
|
733
|
+
*
|
|
734
|
+
* @returns The new date with the days subtracted
|
|
735
|
+
*
|
|
736
|
+
* @example
|
|
737
|
+
* // Subtract 10 days from 1 September 2014:
|
|
738
|
+
* const result = subDays(new Date(2014, 8, 1), 10)
|
|
739
|
+
* //=> Fri Aug 22 2014 00:00:00
|
|
740
|
+
*/
|
|
741
|
+
function subDays(date, amount, options) {
|
|
742
|
+
return addDays(date, -amount, options);
|
|
743
|
+
}
|
|
744
|
+
|
|
745
|
+
//#endregion
|
|
746
|
+
//#region node_modules/date-fns/parseISO.js
|
|
747
|
+
/**
|
|
748
|
+
* The {@link parseISO} function options.
|
|
749
|
+
*/
|
|
750
|
+
/**
|
|
751
|
+
* @name parseISO
|
|
752
|
+
* @category Common Helpers
|
|
753
|
+
* @summary Parse ISO string
|
|
754
|
+
*
|
|
755
|
+
* @description
|
|
756
|
+
* Parse the given string in ISO 8601 format and return an instance of Date.
|
|
757
|
+
*
|
|
758
|
+
* Function accepts complete ISO 8601 formats as well as partial implementations.
|
|
759
|
+
* ISO 8601: http://en.wikipedia.org/wiki/ISO_8601
|
|
760
|
+
*
|
|
761
|
+
* If the argument isn't a string, the function cannot parse the string or
|
|
762
|
+
* the values are invalid, it returns Invalid Date.
|
|
763
|
+
*
|
|
764
|
+
* @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
|
|
765
|
+
* @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments.
|
|
766
|
+
*
|
|
767
|
+
* @param argument - The value to convert
|
|
768
|
+
* @param options - An object with options
|
|
769
|
+
*
|
|
770
|
+
* @returns The parsed date in the local time zone
|
|
771
|
+
*
|
|
772
|
+
* @example
|
|
773
|
+
* // Convert string '2014-02-11T11:30:30' to date:
|
|
774
|
+
* const result = parseISO('2014-02-11T11:30:30')
|
|
775
|
+
* //=> Tue Feb 11 2014 11:30:30
|
|
776
|
+
*
|
|
777
|
+
* @example
|
|
778
|
+
* // Convert string '+02014101' to date,
|
|
779
|
+
* // if the additional number of digits in the extended year format is 1:
|
|
780
|
+
* const result = parseISO('+02014101', { additionalDigits: 1 })
|
|
781
|
+
* //=> Fri Apr 11 2014 00:00:00
|
|
782
|
+
*/
|
|
783
|
+
function parseISO(argument, options) {
|
|
784
|
+
const invalidDate = () => constructFrom(options?.in, NaN);
|
|
785
|
+
const additionalDigits = options?.additionalDigits ?? 2;
|
|
786
|
+
const dateStrings = splitDateString(argument);
|
|
787
|
+
let date;
|
|
788
|
+
if (dateStrings.date) {
|
|
789
|
+
const parseYearResult = parseYear(dateStrings.date, additionalDigits);
|
|
790
|
+
date = parseDate(parseYearResult.restDateString, parseYearResult.year);
|
|
791
|
+
}
|
|
792
|
+
if (!date || isNaN(+date)) return invalidDate();
|
|
793
|
+
const timestamp = +date;
|
|
794
|
+
let time = 0;
|
|
795
|
+
let offset;
|
|
796
|
+
if (dateStrings.time) {
|
|
797
|
+
time = parseTime(dateStrings.time);
|
|
798
|
+
if (isNaN(time)) return invalidDate();
|
|
799
|
+
}
|
|
800
|
+
if (dateStrings.timezone) {
|
|
801
|
+
offset = parseTimezone(dateStrings.timezone);
|
|
802
|
+
if (isNaN(offset)) return invalidDate();
|
|
803
|
+
} else {
|
|
804
|
+
const tmpDate = new Date(timestamp + time);
|
|
805
|
+
const result = toDate(0, options?.in);
|
|
806
|
+
result.setFullYear(tmpDate.getUTCFullYear(), tmpDate.getUTCMonth(), tmpDate.getUTCDate());
|
|
807
|
+
result.setHours(tmpDate.getUTCHours(), tmpDate.getUTCMinutes(), tmpDate.getUTCSeconds(), tmpDate.getUTCMilliseconds());
|
|
808
|
+
return result;
|
|
809
|
+
}
|
|
810
|
+
return toDate(timestamp + time + offset, options?.in);
|
|
811
|
+
}
|
|
812
|
+
const patterns = {
|
|
813
|
+
dateTimeDelimiter: /[T ]/,
|
|
814
|
+
timeZoneDelimiter: /[Z ]/i,
|
|
815
|
+
timezone: /([Z+-].*)$/
|
|
816
|
+
};
|
|
817
|
+
const dateRegex = /^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/;
|
|
818
|
+
const timeRegex = /^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/;
|
|
819
|
+
const timezoneRegex = /^([+-])(\d{2})(?::?(\d{2}))?$/;
|
|
820
|
+
function splitDateString(dateString) {
|
|
821
|
+
const dateStrings = {};
|
|
822
|
+
const array = dateString.split(patterns.dateTimeDelimiter);
|
|
823
|
+
let timeString;
|
|
824
|
+
if (array.length > 2) return dateStrings;
|
|
825
|
+
if (/:/.test(array[0])) timeString = array[0];
|
|
826
|
+
else {
|
|
827
|
+
dateStrings.date = array[0];
|
|
828
|
+
timeString = array[1];
|
|
829
|
+
if (patterns.timeZoneDelimiter.test(dateStrings.date)) {
|
|
830
|
+
dateStrings.date = dateString.split(patterns.timeZoneDelimiter)[0];
|
|
831
|
+
timeString = dateString.substr(dateStrings.date.length, dateString.length);
|
|
832
|
+
}
|
|
833
|
+
}
|
|
834
|
+
if (timeString) {
|
|
835
|
+
const token = patterns.timezone.exec(timeString);
|
|
836
|
+
if (token) {
|
|
837
|
+
dateStrings.time = timeString.replace(token[1], "");
|
|
838
|
+
dateStrings.timezone = token[1];
|
|
839
|
+
} else dateStrings.time = timeString;
|
|
840
|
+
}
|
|
841
|
+
return dateStrings;
|
|
842
|
+
}
|
|
843
|
+
function parseYear(dateString, additionalDigits) {
|
|
844
|
+
const regex = new RegExp("^(?:(\\d{4}|[+-]\\d{" + (4 + additionalDigits) + "})|(\\d{2}|[+-]\\d{" + (2 + additionalDigits) + "})$)");
|
|
845
|
+
const captures = dateString.match(regex);
|
|
846
|
+
if (!captures) return {
|
|
847
|
+
year: NaN,
|
|
848
|
+
restDateString: ""
|
|
849
|
+
};
|
|
850
|
+
const year = captures[1] ? parseInt(captures[1]) : null;
|
|
851
|
+
const century = captures[2] ? parseInt(captures[2]) : null;
|
|
852
|
+
return {
|
|
853
|
+
year: century === null ? year : century * 100,
|
|
854
|
+
restDateString: dateString.slice((captures[1] || captures[2]).length)
|
|
855
|
+
};
|
|
856
|
+
}
|
|
857
|
+
function parseDate(dateString, year) {
|
|
858
|
+
if (year === null) return /* @__PURE__ */ new Date(NaN);
|
|
859
|
+
const captures = dateString.match(dateRegex);
|
|
860
|
+
if (!captures) return /* @__PURE__ */ new Date(NaN);
|
|
861
|
+
const isWeekDate = !!captures[4];
|
|
862
|
+
const dayOfYear = parseDateUnit(captures[1]);
|
|
863
|
+
const month = parseDateUnit(captures[2]) - 1;
|
|
864
|
+
const day = parseDateUnit(captures[3]);
|
|
865
|
+
const week = parseDateUnit(captures[4]);
|
|
866
|
+
const dayOfWeek = parseDateUnit(captures[5]) - 1;
|
|
867
|
+
if (isWeekDate) {
|
|
868
|
+
if (!validateWeekDate(year, week, dayOfWeek)) return /* @__PURE__ */ new Date(NaN);
|
|
869
|
+
return dayOfISOWeekYear(year, week, dayOfWeek);
|
|
870
|
+
} else {
|
|
871
|
+
const date = /* @__PURE__ */ new Date(0);
|
|
872
|
+
if (!validateDate(year, month, day) || !validateDayOfYearDate(year, dayOfYear)) return /* @__PURE__ */ new Date(NaN);
|
|
873
|
+
date.setUTCFullYear(year, month, Math.max(dayOfYear, day));
|
|
874
|
+
return date;
|
|
875
|
+
}
|
|
876
|
+
}
|
|
877
|
+
function parseDateUnit(value) {
|
|
878
|
+
return value ? parseInt(value) : 1;
|
|
879
|
+
}
|
|
880
|
+
function parseTime(timeString) {
|
|
881
|
+
const captures = timeString.match(timeRegex);
|
|
882
|
+
if (!captures) return NaN;
|
|
883
|
+
const hours = parseTimeUnit(captures[1]);
|
|
884
|
+
const minutes = parseTimeUnit(captures[2]);
|
|
885
|
+
const seconds = parseTimeUnit(captures[3]);
|
|
886
|
+
if (!validateTime(hours, minutes, seconds)) return NaN;
|
|
887
|
+
return hours * millisecondsInHour + minutes * millisecondsInMinute + seconds * 1e3;
|
|
888
|
+
}
|
|
889
|
+
function parseTimeUnit(value) {
|
|
890
|
+
return value && parseFloat(value.replace(",", ".")) || 0;
|
|
891
|
+
}
|
|
892
|
+
function parseTimezone(timezoneString) {
|
|
893
|
+
if (timezoneString === "Z") return 0;
|
|
894
|
+
const captures = timezoneString.match(timezoneRegex);
|
|
895
|
+
if (!captures) return 0;
|
|
896
|
+
const sign = captures[1] === "+" ? -1 : 1;
|
|
897
|
+
const hours = parseInt(captures[2]);
|
|
898
|
+
const minutes = captures[3] && parseInt(captures[3]) || 0;
|
|
899
|
+
if (!validateTimezone(hours, minutes)) return NaN;
|
|
900
|
+
return sign * (hours * millisecondsInHour + minutes * millisecondsInMinute);
|
|
901
|
+
}
|
|
902
|
+
function dayOfISOWeekYear(isoWeekYear, week, day) {
|
|
903
|
+
const date = /* @__PURE__ */ new Date(0);
|
|
904
|
+
date.setUTCFullYear(isoWeekYear, 0, 4);
|
|
905
|
+
const fourthOfJanuaryDay = date.getUTCDay() || 7;
|
|
906
|
+
const diff = (week - 1) * 7 + day + 1 - fourthOfJanuaryDay;
|
|
907
|
+
date.setUTCDate(date.getUTCDate() + diff);
|
|
908
|
+
return date;
|
|
909
|
+
}
|
|
910
|
+
const daysInMonths = [
|
|
911
|
+
31,
|
|
912
|
+
null,
|
|
913
|
+
31,
|
|
914
|
+
30,
|
|
915
|
+
31,
|
|
916
|
+
30,
|
|
917
|
+
31,
|
|
918
|
+
31,
|
|
919
|
+
30,
|
|
920
|
+
31,
|
|
921
|
+
30,
|
|
922
|
+
31
|
|
923
|
+
];
|
|
924
|
+
function isLeapYearIndex(year) {
|
|
925
|
+
return year % 400 === 0 || year % 4 === 0 && year % 100 !== 0;
|
|
926
|
+
}
|
|
927
|
+
function validateDate(year, month, date) {
|
|
928
|
+
return month >= 0 && month <= 11 && date >= 1 && date <= (daysInMonths[month] || (isLeapYearIndex(year) ? 29 : 28));
|
|
929
|
+
}
|
|
930
|
+
function validateDayOfYearDate(year, dayOfYear) {
|
|
931
|
+
return dayOfYear >= 1 && dayOfYear <= (isLeapYearIndex(year) ? 366 : 365);
|
|
932
|
+
}
|
|
933
|
+
function validateWeekDate(_year, week, day) {
|
|
934
|
+
return week >= 1 && week <= 53 && day >= 0 && day <= 6;
|
|
935
|
+
}
|
|
936
|
+
function validateTime(hours, minutes, seconds) {
|
|
937
|
+
if (hours === 24) return minutes === 0 && seconds === 0;
|
|
938
|
+
return seconds >= 0 && seconds < 60 && minutes >= 0 && minutes < 60 && hours >= 0 && hours < 25;
|
|
939
|
+
}
|
|
940
|
+
function validateTimezone(_hours, minutes) {
|
|
941
|
+
return minutes >= 0 && minutes <= 59;
|
|
942
|
+
}
|
|
943
|
+
|
|
944
|
+
//#endregion
|
|
945
|
+
//#region node_modules/date-fns/subHours.js
|
|
946
|
+
/**
|
|
947
|
+
* The {@link subHours} function options.
|
|
948
|
+
*/
|
|
949
|
+
/**
|
|
950
|
+
* @name subHours
|
|
951
|
+
* @category Hour Helpers
|
|
952
|
+
* @summary Subtract the specified number of hours from the given date.
|
|
953
|
+
*
|
|
954
|
+
* @description
|
|
955
|
+
* Subtract the specified number of hours from the given date.
|
|
956
|
+
*
|
|
957
|
+
* @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
|
|
958
|
+
* @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments.
|
|
959
|
+
*
|
|
960
|
+
* @param date - The date to be changed
|
|
961
|
+
* @param amount - The amount of hours to be subtracted.
|
|
962
|
+
* @param options - The options
|
|
963
|
+
*
|
|
964
|
+
* @returns The new date with the hours subtracted
|
|
965
|
+
*
|
|
966
|
+
* @example
|
|
967
|
+
* // Subtract 2 hours from 11 July 2014 01:00:00:
|
|
968
|
+
* const result = subHours(new Date(2014, 6, 11, 1, 0), 2)
|
|
969
|
+
* //=> Thu Jul 10 2014 23:00:00
|
|
970
|
+
*/
|
|
971
|
+
function subHours(date, amount, options) {
|
|
972
|
+
return addHours(date, -amount, options);
|
|
973
|
+
}
|
|
974
|
+
|
|
975
|
+
//#endregion
|
|
976
|
+
//#region src/elements-experimental/core/datetime/date-helper.ts
|
|
977
|
+
/**
|
|
978
|
+
* This function removes the offset of a ISO date string. This needs to be done to make sure that the offset is ignored.
|
|
979
|
+
* If it is not removed the time would be converted to the browsers local time.
|
|
980
|
+
* Example: "2022-08-29T09:30:00+03:00" would be changed to "2022-08-29T08:30:00+02:00" --> not the desired outcome, as we want to use the time in the timezone and not the local time.
|
|
981
|
+
*
|
|
982
|
+
* After the offset is removed a new date is created in the browsers local time. This ensures that the time of the ISO date string is displayed and not a converted time.
|
|
983
|
+
* Example: "2022-08-29T09:30:00+03:00" would be changed to "2022-08-29T09:30:00+02:00" --> desired outcome
|
|
984
|
+
* Attention: This function does not convert the time to the correct time in the local timezone. It is a workaround to make sure, that the given time is displayed without being converted.
|
|
985
|
+
*
|
|
986
|
+
* Offset: Difference between the timezone and Coordinated Universal Time.
|
|
987
|
+
*
|
|
988
|
+
* @param isoTime - the iso time with the timezone offset
|
|
989
|
+
* @returns a new date with the local timezone with the local offset
|
|
990
|
+
*/
|
|
991
|
+
function removeTimezoneFromISOTimeString(isoTime) {
|
|
992
|
+
if (!isoTime) return;
|
|
993
|
+
if (!isValid(parseISO(isoTime))) return;
|
|
994
|
+
if (isoTime.includes("Z")) return new Date(isoTime.replace("Z", ""));
|
|
995
|
+
if (isoTime.includes("T")) {
|
|
996
|
+
const dateTime = isoTime.split("T");
|
|
997
|
+
if (dateTime[1] && (dateTime[1].includes("+") || dateTime[1].includes("-"))) return /* @__PURE__ */ new Date(`${dateTime[0]}T${dateTime[1].split(/[+-]/)[0]}`);
|
|
998
|
+
}
|
|
999
|
+
return new Date(isoTime);
|
|
1000
|
+
}
|
|
1001
|
+
/**
|
|
1002
|
+
* This function converts a duration number to date string with specific format
|
|
1003
|
+
*
|
|
1004
|
+
* @param duration - duration in minutes
|
|
1005
|
+
* @param currentLanguage - currentLanguage
|
|
1006
|
+
* @returns an Object with two strings in the format "dd hh mm" (short) an "x Day(s) x Hour(s) x Minute(s) (long)"
|
|
1007
|
+
* */
|
|
1008
|
+
const durationToTime = (duration, currentLanguage) => {
|
|
1009
|
+
const short = [];
|
|
1010
|
+
const long = [];
|
|
1011
|
+
const now = 0;
|
|
1012
|
+
let future = addMinutes(now, duration);
|
|
1013
|
+
const days = differenceInDays(future, now);
|
|
1014
|
+
if (days > 0) {
|
|
1015
|
+
short.push(`${days} d`);
|
|
1016
|
+
if (currentLanguage) long.push(`${days} ${days > 1 ? i18nDurationDay.multiple.long[currentLanguage] : i18nDurationDay.single.long[currentLanguage]}`);
|
|
1017
|
+
future = subDays(future, days);
|
|
1018
|
+
}
|
|
1019
|
+
const hours = differenceInHours(future, now);
|
|
1020
|
+
if (hours > 0) {
|
|
1021
|
+
short.push(`${hours} h`);
|
|
1022
|
+
if (currentLanguage) long.push(`${hours} ${hours > 1 ? i18nDurationHour.multiple.long[currentLanguage] : i18nDurationHour.single.long[currentLanguage]}`);
|
|
1023
|
+
future = subHours(future, hours);
|
|
1024
|
+
}
|
|
1025
|
+
const minutes = differenceInMinutes(future, now);
|
|
1026
|
+
if (minutes > 0) {
|
|
1027
|
+
short.push(`${minutes} min`);
|
|
1028
|
+
if (currentLanguage) long.push(`${minutes} ${minutes > 1 ? i18nDurationMinute.multiple.long[currentLanguage] : i18nDurationMinute.single.long[currentLanguage]}`);
|
|
1029
|
+
}
|
|
1030
|
+
return {
|
|
1031
|
+
short: short.join(" "),
|
|
1032
|
+
long: long.join(" ")
|
|
1033
|
+
};
|
|
1034
|
+
};
|
|
1035
|
+
|
|
1036
|
+
//#endregion
|
|
1037
|
+
//#region src/elements-experimental/core/timetable/timetable-helper.ts
|
|
1038
|
+
const isRideLeg = (leg) => {
|
|
1039
|
+
return leg?.__typename === "PTRideLeg";
|
|
1040
|
+
};
|
|
1041
|
+
const isConnectionLeg = (leg) => {
|
|
1042
|
+
return leg?.__typename === "PTConnectionLeg";
|
|
1043
|
+
};
|
|
1044
|
+
const extractTimeAndStringFromNoticeText = (notice) => {
|
|
1045
|
+
const firstIndex = notice?.text?.template && notice.text.template.indexOf("(") + 1;
|
|
1046
|
+
const noticeDuration = notice?.text?.template?.substring(firstIndex || 0, notice?.text?.template.indexOf(")"));
|
|
1047
|
+
return {
|
|
1048
|
+
duration: noticeDuration && +noticeDuration.substring(0, noticeDuration.length - 1) || 0,
|
|
1049
|
+
text: notice?.text?.template?.split("(")[0] || ""
|
|
1050
|
+
};
|
|
1051
|
+
};
|
|
1052
|
+
|
|
1053
|
+
//#endregion
|
|
1054
|
+
//#region src/elements-experimental/core/timetable/access-leg-helper.ts
|
|
1055
|
+
/**
|
|
1056
|
+
* @returns the attribute of a ConnectionLeg
|
|
1057
|
+
*/
|
|
1058
|
+
function getPTConnectionAttribute(leg, connectionLegNotice) {
|
|
1059
|
+
const connectionFirstLeg = isConnectionLeg(leg) ? leg : null;
|
|
1060
|
+
const connectionFirstLegNotice = connectionFirstLeg ? connectionFirstLeg?.notices?.filter((notice) => connectionLegNotice.includes(notice.name))[0] : null;
|
|
1061
|
+
return connectionFirstLegNotice ? {
|
|
1062
|
+
duration: connectionFirstLeg?.duration || 0,
|
|
1063
|
+
text: connectionFirstLegNotice?.text?.template || "",
|
|
1064
|
+
icon: "walk-small"
|
|
1065
|
+
} : null;
|
|
1066
|
+
}
|
|
1067
|
+
/**
|
|
1068
|
+
* @returns the extended enter attribute of the PTRideLeg
|
|
1069
|
+
*/
|
|
1070
|
+
function getFirstExtendedLegAttribute(leg, departureWalk, a11yFootpath, currentLanguage) {
|
|
1071
|
+
const extendedFirstLeg = isRideLeg(leg) ? leg?.serviceJourney?.notices?.filter((notice) => ["CI"].includes(notice.name))[0] : null;
|
|
1072
|
+
const extractTimeAndString = extendedFirstLeg && extractTimeAndStringFromNoticeText(extendedFirstLeg);
|
|
1073
|
+
return extendedFirstLeg ? {
|
|
1074
|
+
duration: (extractTimeAndString?.duration || 0) + (departureWalk || 0),
|
|
1075
|
+
text: a11yFootpath ? i18nWalkingDistanceDeparture[currentLanguage] : extractTimeAndString?.text || "",
|
|
1076
|
+
icon: a11yFootpath ? "wheelchair-small" : `sa-${extendedFirstLeg?.name?.toLowerCase()}`
|
|
1077
|
+
} : null;
|
|
1078
|
+
}
|
|
1079
|
+
/**
|
|
1080
|
+
* @returns the extended exit attribute of the PTRideLeg
|
|
1081
|
+
*/
|
|
1082
|
+
function getLastExtendedLegAttribute(leg, arrivalWalk, a11yFootpath, currentLanguage) {
|
|
1083
|
+
const extendedLastLeg = isRideLeg(leg) ? leg?.serviceJourney?.notices?.filter((notice) => ["CO"].includes(notice.name))[0] : null;
|
|
1084
|
+
const extractTimeAndString = extendedLastLeg && extractTimeAndStringFromNoticeText(extendedLastLeg);
|
|
1085
|
+
return extendedLastLeg ? {
|
|
1086
|
+
duration: (extractTimeAndString?.duration || 0) + (arrivalWalk || 0),
|
|
1087
|
+
text: a11yFootpath ? i18nWalkingDistanceArrival[currentLanguage] : extractTimeAndString?.text || "",
|
|
1088
|
+
icon: a11yFootpath ? "wheelchair-small" : `sa-${extendedLastLeg?.name?.toLowerCase()}`
|
|
1089
|
+
} : null;
|
|
1090
|
+
}
|
|
1091
|
+
/**
|
|
1092
|
+
* renders the extended exit/enter icon with the duration
|
|
1093
|
+
*/
|
|
1094
|
+
function renderTransferTime(duration, icon, currentLanguage, label, type) {
|
|
1095
|
+
return html`
|
|
1096
|
+
<span class="sbb-pearl-chain__time-transfer sbb-pearl-chain__time-transfer--${icon}-${type}">
|
|
1097
|
+
<sbb-icon name=${icon}></sbb-icon>
|
|
1098
|
+
<time datetime=${duration + "M"}>
|
|
1099
|
+
<span class="sbb-screen-reader-only">
|
|
1100
|
+
${!label && type ? type === "departure" ? i18nWalkingDistanceDeparture[currentLanguage] : i18nWalkingDistanceArrival[currentLanguage] : nothing}
|
|
1101
|
+
${label ? html`<span>${label}</span>` : nothing}
|
|
1102
|
+
</span>
|
|
1103
|
+
${duration}
|
|
1104
|
+
<span class="sbb-pearl-chain__time-walktime-prime-symbol" aria-hidden="true">'</span>
|
|
1105
|
+
<span class="sbb-screen-reader-only">min</span>
|
|
1106
|
+
</time>
|
|
1107
|
+
</span>
|
|
1108
|
+
`;
|
|
1109
|
+
}
|
|
1110
|
+
/**
|
|
1111
|
+
* renders a walk-time icon with the walk duration
|
|
1112
|
+
*/
|
|
1113
|
+
function renderWalkTime(duration, label, variant, icon) {
|
|
1114
|
+
return html`
|
|
1115
|
+
<span class="sbb-pearl-chain__time-walktime sbb-pearl-chain__time-walktime--${icon}-${variant}">
|
|
1116
|
+
<sbb-icon name=${icon}></sbb-icon>
|
|
1117
|
+
<time datetime=${duration + "M"}>
|
|
1118
|
+
<span class="sbb-screen-reader-only">${label}</span>
|
|
1119
|
+
${duration}
|
|
1120
|
+
<span class="sbb-pearl-chain__time-walktime-prime-symbol" aria-hidden="true">'</span>
|
|
1121
|
+
</time>
|
|
1122
|
+
</span>
|
|
1123
|
+
`;
|
|
1124
|
+
}
|
|
1125
|
+
/**
|
|
1126
|
+
* @returns renderDepartureTimeAttribute: A function that renders the element for the departure time attribute.
|
|
1127
|
+
* @returns renderArrivalTimeAttribute: A function that renders the element for the arrival time attribute.
|
|
1128
|
+
* @returns arrivalTimeAttribute: The access attribute for the arrival time.
|
|
1129
|
+
* @returns departureTimeAttribute: The access attribute for the departure time.
|
|
1130
|
+
* @param legs An array of Leg objects representing the journey legs.
|
|
1131
|
+
* @param departureWalk The walking distance in minutes from the departure point to the first leg.
|
|
1132
|
+
* @param arrivalWalk The walking distance in minutes from the last leg to the arrival point.
|
|
1133
|
+
* @param currentLanguage The current language for localization.
|
|
1134
|
+
* @param a11yFootpath Whether the a11y-icon should be shown.
|
|
1135
|
+
*/
|
|
1136
|
+
function getDepartureArrivalTimeAttribute(legs, departureWalk, arrivalWalk, currentLanguage, a11yFootpath) {
|
|
1137
|
+
const connectionRideLeg = legs && legs.filter((leg) => isRideLeg(leg) || isConnectionLeg(leg))[0];
|
|
1138
|
+
const connectionLegNotice = [
|
|
1139
|
+
"YM",
|
|
1140
|
+
"YB",
|
|
1141
|
+
"Y",
|
|
1142
|
+
"YT"
|
|
1143
|
+
];
|
|
1144
|
+
const connectionFirstLeg = getPTConnectionAttribute(connectionRideLeg, connectionLegNotice);
|
|
1145
|
+
const extendedFirstLeg = getFirstExtendedLegAttribute(connectionRideLeg, departureWalk, a11yFootpath, currentLanguage);
|
|
1146
|
+
const departureWalkAttribute = departureWalk ? {
|
|
1147
|
+
text: i18nWalkingDistanceDeparture[currentLanguage],
|
|
1148
|
+
duration: departureWalk,
|
|
1149
|
+
icon: a11yFootpath ? "wheelchair-small" : "walk-small"
|
|
1150
|
+
} : null;
|
|
1151
|
+
const getDepartureType = () => {
|
|
1152
|
+
if (connectionFirstLeg) return connectionFirstLeg;
|
|
1153
|
+
else if (departureWalkAttribute && !extendedFirstLeg && !connectionFirstLeg) return departureWalkAttribute;
|
|
1154
|
+
else if (extendedFirstLeg) return extendedFirstLeg;
|
|
1155
|
+
else return null;
|
|
1156
|
+
};
|
|
1157
|
+
function renderDepartureTimeAttribute() {
|
|
1158
|
+
return html`
|
|
1159
|
+
${connectionFirstLeg ? renderWalkTime(connectionFirstLeg.duration, connectionFirstLeg.text, "left", connectionFirstLeg.icon) : nothing}
|
|
1160
|
+
${departureWalkAttribute && !extendedFirstLeg && !connectionFirstLeg ? renderWalkTime(departureWalkAttribute.duration, departureWalkAttribute.text, "left", departureWalkAttribute.icon) : nothing}
|
|
1161
|
+
${extendedFirstLeg ? a11yFootpath ? renderWalkTime(extendedFirstLeg.duration, extendedFirstLeg.text, "left", extendedFirstLeg.icon) : renderTransferTime(extendedFirstLeg.duration, extendedFirstLeg.icon, currentLanguage, extendedFirstLeg.text, "departure") : nothing}
|
|
1162
|
+
`;
|
|
1163
|
+
}
|
|
1164
|
+
const lastLeg = legs && legs[legs.length - 1];
|
|
1165
|
+
const lastConnectionRideLeg = (isConnectionLeg(lastLeg) || isRideLeg(lastLeg)) && lastLeg;
|
|
1166
|
+
const connectionLastLeg = lastConnectionRideLeg && getPTConnectionAttribute(lastConnectionRideLeg, connectionLegNotice);
|
|
1167
|
+
const extendedLastLeg = lastConnectionRideLeg && getLastExtendedLegAttribute(lastConnectionRideLeg, arrivalWalk, a11yFootpath, currentLanguage);
|
|
1168
|
+
const arrivalWalkAttribute = arrivalWalk ? {
|
|
1169
|
+
text: i18nWalkingDistanceArrival[currentLanguage],
|
|
1170
|
+
duration: arrivalWalk,
|
|
1171
|
+
icon: a11yFootpath ? "wheelchair-small" : "walk-small"
|
|
1172
|
+
} : null;
|
|
1173
|
+
const getArrivalType = () => {
|
|
1174
|
+
if (connectionLastLeg) return connectionLastLeg;
|
|
1175
|
+
else if (arrivalWalkAttribute && !extendedLastLeg && !connectionLastLeg) return arrivalWalkAttribute;
|
|
1176
|
+
else if (extendedLastLeg) return extendedLastLeg;
|
|
1177
|
+
else return null;
|
|
1178
|
+
};
|
|
1179
|
+
function renderArrivalTimeAttribute() {
|
|
1180
|
+
return html`
|
|
1181
|
+
${connectionLastLeg ? renderWalkTime(connectionLastLeg.duration, connectionLastLeg.text, "right", connectionLastLeg.icon) : nothing}
|
|
1182
|
+
${arrivalWalkAttribute && !extendedLastLeg && !connectionLastLeg ? renderWalkTime(arrivalWalkAttribute.duration, arrivalWalkAttribute.text, "right", arrivalWalkAttribute.icon) : nothing}
|
|
1183
|
+
${extendedLastLeg ? a11yFootpath ? renderWalkTime(extendedLastLeg.duration, extendedLastLeg.text, "right", extendedLastLeg.icon) : renderTransferTime(extendedLastLeg.duration, extendedLastLeg.icon, currentLanguage, extendedLastLeg.text, "arrival") : nothing}
|
|
1184
|
+
`;
|
|
1185
|
+
}
|
|
1186
|
+
return {
|
|
1187
|
+
renderDepartureTimeAttribute,
|
|
1188
|
+
renderArrivalTimeAttribute,
|
|
1189
|
+
departureTimeAttribute: getDepartureType(),
|
|
1190
|
+
arrivalTimeAttribute: getArrivalType()
|
|
1191
|
+
};
|
|
1192
|
+
}
|
|
1193
|
+
|
|
1194
|
+
//#endregion
|
|
1195
|
+
export { durationToTime, extractTimeAndStringFromNoticeText, getDepartureArrivalTimeAttribute, isConnectionLeg, isRideLeg, removeTimezoneFromISOTimeString };
|