@sbb-esta/lyne-elements-experimental 1.10.0 → 1.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/core/datetime.js +116 -105
- package/development/core/datetime.js +53 -51
- package/development/differenceInMinutes-Cmyza6nm.js +26 -0
- package/development/format-DTy5_IOt.js +1371 -0
- package/development/isValid-DO_pHwcW.js +53 -0
- package/development/journey-summary.js +2 -2
- package/development/pearl-chain-time.js +1 -1
- package/development/pearl-chain.js +5 -9
- package/development/timetable-row.js +1 -1
- package/development/toDate-B6IBgPYH.js +24 -0
- package/differenceInMinutes-BI2zjbtS.js +23 -0
- package/{format-fWxoS2xH.js → format-oBQcGL50.js} +343 -344
- package/isValid-mroh13Xp.js +45 -0
- package/journey-summary.js +2 -2
- package/package.json +3 -3
- package/pearl-chain-time.js +1 -1
- package/pearl-chain.js +48 -50
- package/timetable-row.js +1 -1
- package/toDate-DQg4ZFnf.js +15 -0
- package/constants-DSR8hPvP.js +0 -16
- package/development/constants-BMGwMkN3.js +0 -30
- package/development/differenceInMinutes-DHtPDiUE.js +0 -30
- package/development/format-DkbylFCM.js +0 -1373
- package/development/isValid-BVccOlli.js +0 -44
- package/differenceInMinutes-BhHyuJc4.js +0 -28
- package/isValid-DSjxf8eh.js +0 -36
package/core/datetime.js
CHANGED
|
@@ -1,156 +1,167 @@
|
|
|
1
|
-
import { i18nDurationDay as
|
|
2
|
-
import { t as
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
function x(t, e) {
|
|
6
|
-
const
|
|
7
|
-
return isNaN(e) ?
|
|
8
|
-
}
|
|
9
|
-
function
|
|
10
|
-
return
|
|
11
|
-
}
|
|
12
|
-
function
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
1
|
+
import { i18nDurationDay as h, i18nDurationHour as T, i18nDurationMinute as p } from "@sbb-esta/lyne-elements/core/i18n.js";
|
|
2
|
+
import { t as d, c as N, a as m, b as w } from "../toDate-DQg4ZFnf.js";
|
|
3
|
+
import { n as I, d as y, i as U } from "../isValid-mroh13Xp.js";
|
|
4
|
+
import { g as C, a as Y, d as F } from "../differenceInMinutes-BI2zjbtS.js";
|
|
5
|
+
function x(t, e, n) {
|
|
6
|
+
const r = d(t, n == null ? void 0 : n.in);
|
|
7
|
+
return isNaN(e) ? N(t, NaN) : (e && r.setDate(r.getDate() + e), r);
|
|
8
|
+
}
|
|
9
|
+
function z(t, e, n) {
|
|
10
|
+
return N(t, +d(t) + e);
|
|
11
|
+
}
|
|
12
|
+
function H(t, e, n) {
|
|
13
|
+
return z(t, e * m);
|
|
14
|
+
}
|
|
15
|
+
function S(t, e, n) {
|
|
16
|
+
const [r, i] = I(
|
|
17
|
+
n == null ? void 0 : n.in,
|
|
18
|
+
t,
|
|
19
|
+
e
|
|
20
|
+
), s = M(r, i), u = Math.abs(
|
|
21
|
+
y(r, i)
|
|
22
|
+
);
|
|
23
|
+
r.setDate(r.getDate() - s * u);
|
|
24
|
+
const a = +(M(r, i) === -s), c = s * (u - a);
|
|
25
|
+
return c === 0 ? 0 : c;
|
|
26
|
+
}
|
|
27
|
+
function M(t, e) {
|
|
19
28
|
const n = t.getFullYear() - e.getFullYear() || t.getMonth() - e.getMonth() || t.getDate() - e.getDate() || t.getHours() - e.getHours() || t.getMinutes() - e.getMinutes() || t.getSeconds() - e.getSeconds() || t.getMilliseconds() - e.getMilliseconds();
|
|
20
29
|
return n < 0 ? -1 : n > 0 ? 1 : n;
|
|
21
30
|
}
|
|
22
|
-
function
|
|
23
|
-
const
|
|
31
|
+
function Z(t, e, n) {
|
|
32
|
+
const [r, i] = I(
|
|
33
|
+
n == null ? void 0 : n.in,
|
|
34
|
+
t,
|
|
35
|
+
e
|
|
36
|
+
), s = (+r - +i) / m;
|
|
24
37
|
return C(n == null ? void 0 : n.roundingMethod)(s);
|
|
25
38
|
}
|
|
26
|
-
function
|
|
27
|
-
return x(t, -e);
|
|
39
|
+
function v(t, e, n) {
|
|
40
|
+
return x(t, -e, n);
|
|
28
41
|
}
|
|
29
|
-
function
|
|
30
|
-
const
|
|
31
|
-
let
|
|
32
|
-
if (
|
|
33
|
-
const o =
|
|
34
|
-
|
|
42
|
+
function O(t, e) {
|
|
43
|
+
const n = () => N(e == null ? void 0 : e.in, NaN), i = k(t);
|
|
44
|
+
let s;
|
|
45
|
+
if (i.date) {
|
|
46
|
+
const o = W(i.date, 2);
|
|
47
|
+
s = j(o.restDateString, o.year);
|
|
35
48
|
}
|
|
36
|
-
if (!
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
if (u = E(s.timezone), isNaN(u))
|
|
44
|
-
return /* @__PURE__ */ new Date(NaN);
|
|
49
|
+
if (!s || isNaN(+s)) return n();
|
|
50
|
+
const u = +s;
|
|
51
|
+
let a = 0, c;
|
|
52
|
+
if (i.time && (a = A(i.time), isNaN(a)))
|
|
53
|
+
return n();
|
|
54
|
+
if (i.timezone) {
|
|
55
|
+
if (c = E(i.timezone), isNaN(c)) return n();
|
|
45
56
|
} else {
|
|
46
|
-
const o = new Date(
|
|
47
|
-
return
|
|
57
|
+
const o = new Date(u + a), D = d(0, e == null ? void 0 : e.in);
|
|
58
|
+
return D.setFullYear(
|
|
48
59
|
o.getUTCFullYear(),
|
|
49
60
|
o.getUTCMonth(),
|
|
50
61
|
o.getUTCDate()
|
|
51
|
-
),
|
|
62
|
+
), D.setHours(
|
|
52
63
|
o.getUTCHours(),
|
|
53
64
|
o.getUTCMinutes(),
|
|
54
65
|
o.getUTCSeconds(),
|
|
55
66
|
o.getUTCMilliseconds()
|
|
56
|
-
),
|
|
67
|
+
), D;
|
|
57
68
|
}
|
|
58
|
-
return
|
|
69
|
+
return d(u + a + c, e == null ? void 0 : e.in);
|
|
59
70
|
}
|
|
60
|
-
const
|
|
71
|
+
const l = {
|
|
61
72
|
dateTimeDelimiter: /[T ]/,
|
|
62
73
|
timeZoneDelimiter: /[Z ]/i,
|
|
63
74
|
timezone: /([Z+-].*)$/
|
|
64
|
-
},
|
|
65
|
-
function
|
|
66
|
-
const e = {}, n = t.split(
|
|
67
|
-
let
|
|
75
|
+
}, _ = /^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/, b = /^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/, R = /^([+-])(\d{2})(?::?(\d{2}))?$/;
|
|
76
|
+
function k(t) {
|
|
77
|
+
const e = {}, n = t.split(l.dateTimeDelimiter);
|
|
78
|
+
let r;
|
|
68
79
|
if (n.length > 2)
|
|
69
80
|
return e;
|
|
70
|
-
if (/:/.test(n[0]) ?
|
|
81
|
+
if (/:/.test(n[0]) ? r = n[0] : (e.date = n[0], r = n[1], l.timeZoneDelimiter.test(e.date) && (e.date = t.split(l.timeZoneDelimiter)[0], r = t.substr(
|
|
71
82
|
e.date.length,
|
|
72
83
|
t.length
|
|
73
|
-
))),
|
|
74
|
-
const
|
|
75
|
-
|
|
84
|
+
))), r) {
|
|
85
|
+
const i = l.timezone.exec(r);
|
|
86
|
+
i ? (e.time = r.replace(i[1], ""), e.timezone = i[1]) : e.time = r;
|
|
76
87
|
}
|
|
77
88
|
return e;
|
|
78
89
|
}
|
|
79
|
-
function
|
|
90
|
+
function W(t, e) {
|
|
80
91
|
const n = new RegExp(
|
|
81
92
|
"^(?:(\\d{4}|[+-]\\d{" + (4 + e) + "})|(\\d{2}|[+-]\\d{" + (2 + e) + "})$)"
|
|
82
|
-
),
|
|
83
|
-
if (!
|
|
84
|
-
const
|
|
93
|
+
), r = t.match(n);
|
|
94
|
+
if (!r) return { year: NaN, restDateString: "" };
|
|
95
|
+
const i = r[1] ? parseInt(r[1]) : null, s = r[2] ? parseInt(r[2]) : null;
|
|
85
96
|
return {
|
|
86
|
-
year:
|
|
87
|
-
restDateString: t.slice((
|
|
97
|
+
year: s === null ? i : s * 100,
|
|
98
|
+
restDateString: t.slice((r[1] || r[2]).length)
|
|
88
99
|
};
|
|
89
100
|
}
|
|
90
101
|
function j(t, e) {
|
|
91
102
|
if (e === null) return /* @__PURE__ */ new Date(NaN);
|
|
92
|
-
const n = t.match(
|
|
103
|
+
const n = t.match(_);
|
|
93
104
|
if (!n) return /* @__PURE__ */ new Date(NaN);
|
|
94
|
-
const
|
|
95
|
-
if (
|
|
96
|
-
return
|
|
105
|
+
const r = !!n[4], i = f(n[1]), s = f(n[2]) - 1, u = f(n[3]), a = f(n[4]), c = f(n[5]) - 1;
|
|
106
|
+
if (r)
|
|
107
|
+
return G(e, a, c) ? J(e, a, c) : /* @__PURE__ */ new Date(NaN);
|
|
97
108
|
{
|
|
98
|
-
const
|
|
99
|
-
return !
|
|
109
|
+
const o = /* @__PURE__ */ new Date(0);
|
|
110
|
+
return !q(e, s, u) || !B(e, i) ? /* @__PURE__ */ new Date(NaN) : (o.setUTCFullYear(e, s, Math.max(i, u)), o);
|
|
100
111
|
}
|
|
101
112
|
}
|
|
102
|
-
function
|
|
113
|
+
function f(t) {
|
|
103
114
|
return t ? parseInt(t) : 1;
|
|
104
115
|
}
|
|
105
116
|
function A(t) {
|
|
106
|
-
const e = t.match(
|
|
117
|
+
const e = t.match(b);
|
|
107
118
|
if (!e) return NaN;
|
|
108
|
-
const n =
|
|
109
|
-
return
|
|
119
|
+
const n = g(e[1]), r = g(e[2]), i = g(e[3]);
|
|
120
|
+
return K(n, r, i) ? n * m + r * w + i * 1e3 : NaN;
|
|
110
121
|
}
|
|
111
|
-
function
|
|
122
|
+
function g(t) {
|
|
112
123
|
return t && parseFloat(t.replace(",", ".")) || 0;
|
|
113
124
|
}
|
|
114
125
|
function E(t) {
|
|
115
126
|
if (t === "Z") return 0;
|
|
116
|
-
const e = t.match(
|
|
127
|
+
const e = t.match(R);
|
|
117
128
|
if (!e) return 0;
|
|
118
|
-
const n = e[1] === "+" ? -1 : 1,
|
|
119
|
-
return
|
|
129
|
+
const n = e[1] === "+" ? -1 : 1, r = parseInt(e[2]), i = e[3] && parseInt(e[3]) || 0;
|
|
130
|
+
return P(r, i) ? n * (r * m + i * w) : NaN;
|
|
120
131
|
}
|
|
121
132
|
function J(t, e, n) {
|
|
122
|
-
const
|
|
123
|
-
|
|
124
|
-
const
|
|
125
|
-
return
|
|
133
|
+
const r = /* @__PURE__ */ new Date(0);
|
|
134
|
+
r.setUTCFullYear(t, 0, 4);
|
|
135
|
+
const i = r.getUTCDay() || 7, s = (e - 1) * 7 + n + 1 - i;
|
|
136
|
+
return r.setUTCDate(r.getUTCDate() + s), r;
|
|
126
137
|
}
|
|
127
|
-
const
|
|
128
|
-
function
|
|
138
|
+
const V = [31, null, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
|
|
139
|
+
function $(t) {
|
|
129
140
|
return t % 400 === 0 || t % 4 === 0 && t % 100 !== 0;
|
|
130
141
|
}
|
|
131
|
-
function
|
|
132
|
-
return e >= 0 && e <= 11 && n >= 1 && n <= (
|
|
142
|
+
function q(t, e, n) {
|
|
143
|
+
return e >= 0 && e <= 11 && n >= 1 && n <= (V[e] || ($(t) ? 29 : 28));
|
|
133
144
|
}
|
|
134
|
-
function
|
|
135
|
-
return e >= 1 && e <= (
|
|
145
|
+
function B(t, e) {
|
|
146
|
+
return e >= 1 && e <= ($(t) ? 366 : 365);
|
|
136
147
|
}
|
|
137
|
-
function
|
|
148
|
+
function G(t, e, n) {
|
|
138
149
|
return e >= 1 && e <= 53 && n >= 0 && n <= 6;
|
|
139
150
|
}
|
|
140
|
-
function
|
|
151
|
+
function K(t, e, n) {
|
|
141
152
|
return t === 24 ? e === 0 && n === 0 : n >= 0 && n < 60 && e >= 0 && e < 60 && t >= 0 && t < 25;
|
|
142
153
|
}
|
|
143
|
-
function
|
|
154
|
+
function P(t, e) {
|
|
144
155
|
return e >= 0 && e <= 59;
|
|
145
156
|
}
|
|
146
|
-
function
|
|
157
|
+
function Q(t, e, n) {
|
|
147
158
|
return H(t, -e);
|
|
148
159
|
}
|
|
149
|
-
function
|
|
160
|
+
function ne(t) {
|
|
150
161
|
if (!t)
|
|
151
162
|
return;
|
|
152
|
-
const e =
|
|
153
|
-
if (
|
|
163
|
+
const e = O(t);
|
|
164
|
+
if (U(e)) {
|
|
154
165
|
if (t.includes("Z"))
|
|
155
166
|
return new Date(t.replace("Z", ""));
|
|
156
167
|
if (t.includes("T")) {
|
|
@@ -161,26 +172,26 @@ function te(t) {
|
|
|
161
172
|
return new Date(t);
|
|
162
173
|
}
|
|
163
174
|
}
|
|
164
|
-
const
|
|
165
|
-
const n = [],
|
|
166
|
-
let
|
|
167
|
-
const
|
|
168
|
-
|
|
169
|
-
`${
|
|
170
|
-
),
|
|
171
|
-
const
|
|
172
|
-
|
|
173
|
-
`${
|
|
174
|
-
),
|
|
175
|
-
const
|
|
176
|
-
return
|
|
177
|
-
`${
|
|
175
|
+
const re = (t, e) => {
|
|
176
|
+
const n = [], r = [];
|
|
177
|
+
let s = Y(0, t);
|
|
178
|
+
const u = S(s, 0);
|
|
179
|
+
u > 0 && (n.push(`${u} d`), e && r.push(
|
|
180
|
+
`${u} ${u > 1 ? h.multiple.long[e] : h.single.long[e]}`
|
|
181
|
+
), s = v(s, u));
|
|
182
|
+
const a = Z(s, 0);
|
|
183
|
+
a > 0 && (n.push(`${a} h`), e && r.push(
|
|
184
|
+
`${a} ${a > 1 ? T.multiple.long[e] : T.single.long[e]}`
|
|
185
|
+
), s = Q(s, a));
|
|
186
|
+
const c = F(s, 0);
|
|
187
|
+
return c > 0 && (n.push(`${c} min`), e && r.push(
|
|
188
|
+
`${c} ${c > 1 ? p.multiple.long[e] : p.single.long[e]}`
|
|
178
189
|
)), {
|
|
179
190
|
short: n.join(" "),
|
|
180
|
-
long:
|
|
191
|
+
long: r.join(" ")
|
|
181
192
|
};
|
|
182
193
|
};
|
|
183
194
|
export {
|
|
184
|
-
|
|
185
|
-
|
|
195
|
+
re as durationToTime,
|
|
196
|
+
ne as removeTimezoneFromISOTimeString
|
|
186
197
|
};
|