qrono 1.2.1 → 1.3.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/README.md +7 -16
- package/dist/qrono.cjs +1 -1
- package/dist/qrono.cjs.map +1 -1
- package/dist/qrono.js +169 -201
- package/dist/qrono.js.map +1 -1
- package/dist/qrono.min.js +1 -1
- package/dist/qrono.min.js.map +1 -1
- package/package.json +1 -1
- package/src/qrono.js +4 -55
- package/types/qrono.d.ts +0 -85
package/dist/qrono.js
CHANGED
|
@@ -1,38 +1,38 @@
|
|
|
1
1
|
var rt = Object.defineProperty;
|
|
2
|
-
var
|
|
2
|
+
var Q = Object.getOwnPropertySymbols;
|
|
3
3
|
var st = Object.prototype.hasOwnProperty, at = Object.prototype.propertyIsEnumerable;
|
|
4
|
-
var
|
|
4
|
+
var G = (t, e, n) => e in t ? rt(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n, $ = (t, e) => {
|
|
5
5
|
for (var n in e || (e = {}))
|
|
6
|
-
st.call(e, n) &&
|
|
7
|
-
if (
|
|
8
|
-
for (var n of
|
|
9
|
-
at.call(e, n) &&
|
|
6
|
+
st.call(e, n) && G(t, n, e[n]);
|
|
7
|
+
if (Q)
|
|
8
|
+
for (var n of Q(e))
|
|
9
|
+
at.call(e, n) && G(t, n, e[n]);
|
|
10
10
|
return t;
|
|
11
11
|
};
|
|
12
|
-
const ut = new Date(1915, 0, 1, 12, 0, 0, 0),
|
|
13
|
-
function
|
|
12
|
+
const ut = new Date(1915, 0, 1, 12, 0, 0, 0), b = 7, K = 24, v = 60, N = v * K, V = 60, ct = V * v, ft = ct * K, _ = 1e3, ht = V * _, J = ft * _;
|
|
13
|
+
function p(t, ...e) {
|
|
14
14
|
return e.flat().some(t.hasOwnProperty, t);
|
|
15
15
|
}
|
|
16
|
-
function
|
|
16
|
+
function X(t) {
|
|
17
17
|
return Object.entries(t).filter(([, e]) => !lt(e)).map(([e]) => e);
|
|
18
18
|
}
|
|
19
|
-
function
|
|
19
|
+
function Y(t) {
|
|
20
20
|
return t !== void 0;
|
|
21
21
|
}
|
|
22
22
|
function lt(t) {
|
|
23
23
|
return t instanceof Function;
|
|
24
24
|
}
|
|
25
|
-
function
|
|
25
|
+
function yt(t) {
|
|
26
26
|
return typeof t == "string" || t instanceof String;
|
|
27
27
|
}
|
|
28
|
-
function
|
|
28
|
+
function T(t) {
|
|
29
29
|
return t !== null && typeof t == "object" && t.constructor === Object;
|
|
30
30
|
}
|
|
31
31
|
function tt(t) {
|
|
32
32
|
return !Number.isNaN(t.getTime());
|
|
33
33
|
}
|
|
34
|
-
function
|
|
35
|
-
return
|
|
34
|
+
function S(t) {
|
|
35
|
+
return p(t, [
|
|
36
36
|
"year",
|
|
37
37
|
"month",
|
|
38
38
|
"day",
|
|
@@ -42,41 +42,31 @@ function Y(t) {
|
|
|
42
42
|
"millisecond"
|
|
43
43
|
]);
|
|
44
44
|
}
|
|
45
|
-
const
|
|
45
|
+
const k = o;
|
|
46
46
|
o.date = a;
|
|
47
|
-
const
|
|
47
|
+
const M = {
|
|
48
48
|
localtime: !1,
|
|
49
49
|
disambiguation: "compatible"
|
|
50
50
|
};
|
|
51
|
-
for (const t of F(d))
|
|
52
|
-
o[t] = function(e) {
|
|
53
|
-
return w(e) ? (d[t] = e, this) : d[t];
|
|
54
|
-
};
|
|
55
51
|
o.context = function(t) {
|
|
56
|
-
if (
|
|
57
|
-
for (const e of
|
|
58
|
-
|
|
52
|
+
if (Y(t)) {
|
|
53
|
+
for (const e of X(M))
|
|
54
|
+
p(t, e) && (M[e] = t[e]);
|
|
59
55
|
return this;
|
|
60
56
|
}
|
|
61
|
-
return
|
|
62
|
-
};
|
|
63
|
-
o.asUtc = function() {
|
|
64
|
-
return d.localtime = !1, this;
|
|
65
|
-
};
|
|
66
|
-
o.asLocaltime = function() {
|
|
67
|
-
return d.localtime = !0, this;
|
|
57
|
+
return $({}, M);
|
|
68
58
|
};
|
|
69
|
-
const
|
|
59
|
+
const dt = 1, mt = 2, et = 3, w = 4, pt = 5, Dt = 6, gt = 7;
|
|
70
60
|
Object.assign(o, {
|
|
71
|
-
monday:
|
|
72
|
-
tuesday:
|
|
61
|
+
monday: dt,
|
|
62
|
+
tuesday: mt,
|
|
73
63
|
wednesday: et,
|
|
74
|
-
thursday:
|
|
64
|
+
thursday: w,
|
|
75
65
|
friday: pt,
|
|
76
66
|
saturday: Dt,
|
|
77
67
|
sunday: gt
|
|
78
68
|
});
|
|
79
|
-
const
|
|
69
|
+
const f = /* @__PURE__ */ Symbol();
|
|
80
70
|
function o(...t) {
|
|
81
71
|
var s;
|
|
82
72
|
if (!new.target)
|
|
@@ -88,26 +78,25 @@ function o(...t) {
|
|
|
88
78
|
disambiguation: "compatible",
|
|
89
79
|
// methods
|
|
90
80
|
set: Mt,
|
|
91
|
-
parse:
|
|
81
|
+
parse: Tt,
|
|
92
82
|
valid: Ot,
|
|
93
83
|
context: wt,
|
|
94
84
|
getNative: bt
|
|
95
85
|
};
|
|
96
|
-
if (this[
|
|
97
|
-
const
|
|
98
|
-
|
|
99
|
-
e[i] = r[i]();
|
|
86
|
+
if (this[f] = e, e.context(M), t[0] instanceof o) {
|
|
87
|
+
const i = t.shift();
|
|
88
|
+
e.nativeDate = i.nativeDate(), e.context(i.context());
|
|
100
89
|
}
|
|
101
|
-
|
|
90
|
+
T(t[0]) && !S(t[0]) && e.context(t.shift());
|
|
102
91
|
const n = t[0], u = t[1];
|
|
103
92
|
if (n == null)
|
|
104
93
|
(s = e.nativeDate) != null || (e.nativeDate = /* @__PURE__ */ new Date());
|
|
105
94
|
else if (n instanceof Date)
|
|
106
95
|
e.nativeDate = new Date(n.getTime());
|
|
107
|
-
else if (
|
|
96
|
+
else if (yt(n))
|
|
108
97
|
e.parse(n);
|
|
109
|
-
else if (
|
|
110
|
-
if (!
|
|
98
|
+
else if (T(n)) {
|
|
99
|
+
if (!S(n))
|
|
111
100
|
throw RangeError(
|
|
112
101
|
"Missing time field (year, minute, day, hour, minute, second or millisecond)"
|
|
113
102
|
);
|
|
@@ -115,19 +104,19 @@ function o(...t) {
|
|
|
115
104
|
} else if (Number.isFinite(n) && !Number.isFinite(u))
|
|
116
105
|
e.nativeDate = new Date(n);
|
|
117
106
|
else if (Number.isFinite(n) || Array.isArray(n)) {
|
|
118
|
-
const
|
|
119
|
-
if (
|
|
107
|
+
const i = t.flat(), r = i.filter((l) => Number.isSafeInteger(l));
|
|
108
|
+
if (r.length !== i.length)
|
|
120
109
|
throw RangeError("Should be safe integers");
|
|
121
|
-
if (
|
|
110
|
+
if (r.length > 7)
|
|
122
111
|
throw RangeError("Too many numbers");
|
|
123
112
|
e.set({
|
|
124
|
-
year:
|
|
125
|
-
month:
|
|
126
|
-
day:
|
|
127
|
-
hour:
|
|
128
|
-
minute:
|
|
129
|
-
second:
|
|
130
|
-
millisecond:
|
|
113
|
+
year: r[0],
|
|
114
|
+
month: r[1],
|
|
115
|
+
day: r[2],
|
|
116
|
+
hour: r[3],
|
|
117
|
+
minute: r[4],
|
|
118
|
+
second: r[5],
|
|
119
|
+
millisecond: r[6]
|
|
131
120
|
});
|
|
132
121
|
} else
|
|
133
122
|
throw TypeError(`Invalid argument ${t}`);
|
|
@@ -138,8 +127,8 @@ function Ot() {
|
|
|
138
127
|
}
|
|
139
128
|
function wt(t) {
|
|
140
129
|
if (t) {
|
|
141
|
-
for (const e of
|
|
142
|
-
|
|
130
|
+
for (const e of X(M))
|
|
131
|
+
p(t, e) && (this[e] = t[e]);
|
|
143
132
|
return this;
|
|
144
133
|
}
|
|
145
134
|
}
|
|
@@ -147,120 +136,111 @@ function bt(t) {
|
|
|
147
136
|
return this.nativeDate[`get${this.localtime ? "" : "UTC"}${t}`]();
|
|
148
137
|
}
|
|
149
138
|
function Mt(t) {
|
|
150
|
-
var A, H, I, E, R, P, W, j,
|
|
151
|
-
const e =
|
|
139
|
+
var C, A, H, I, U, E, R, P, x, W, j, B, L, z, q, Z;
|
|
140
|
+
const e = $({}, t);
|
|
152
141
|
if (e.month = e.month && e.month - 1, !this.localtime) {
|
|
153
|
-
const
|
|
154
|
-
return
|
|
155
|
-
(
|
|
156
|
-
(
|
|
157
|
-
(
|
|
158
|
-
),
|
|
159
|
-
(
|
|
160
|
-
(
|
|
161
|
-
(
|
|
162
|
-
(
|
|
163
|
-
), this.nativeDate =
|
|
142
|
+
const g = (C = this.nativeDate) != null ? C : /* @__PURE__ */ new Date(0), F = /* @__PURE__ */ new Date(0);
|
|
143
|
+
return F.setUTCFullYear(
|
|
144
|
+
(A = e.year) != null ? A : g.getUTCFullYear(),
|
|
145
|
+
(H = e.month) != null ? H : g.getUTCMonth(),
|
|
146
|
+
(I = e.day) != null ? I : g.getUTCDate()
|
|
147
|
+
), F.setUTCHours(
|
|
148
|
+
(U = e.hour) != null ? U : g.getUTCHours(),
|
|
149
|
+
(E = e.minute) != null ? E : g.getUTCMinutes(),
|
|
150
|
+
(R = e.second) != null ? R : g.getUTCSeconds(),
|
|
151
|
+
(P = e.millisecond) != null ? P : g.getUTCMilliseconds()
|
|
152
|
+
), this.nativeDate = F, this;
|
|
164
153
|
}
|
|
165
|
-
const n = !
|
|
166
|
-
year: (
|
|
167
|
-
month: (
|
|
168
|
-
day: (
|
|
169
|
-
hour: (
|
|
170
|
-
minute: (
|
|
171
|
-
second: (
|
|
172
|
-
millisecond: (
|
|
154
|
+
const n = !p(t, "hour", "minute", "second", "millisecond"), u = n ? "later" : this.disambiguation, s = (x = this.nativeDate) != null ? x : new Date(0, 0), i = new Date(ut.getTime()), r = {
|
|
155
|
+
year: (W = e.year) != null ? W : s.getFullYear(),
|
|
156
|
+
month: (j = e.month) != null ? j : s.getMonth(),
|
|
157
|
+
day: (B = e.day) != null ? B : s.getDate(),
|
|
158
|
+
hour: (L = e.hour) != null ? L : n ? 0 : s.getHours(),
|
|
159
|
+
minute: (z = e.minute) != null ? z : n ? 0 : s.getMinutes(),
|
|
160
|
+
second: (q = e.second) != null ? q : n ? 0 : s.getSeconds(),
|
|
161
|
+
millisecond: (Z = e.millisecond) != null ? Z : n ? 0 : s.getMilliseconds()
|
|
173
162
|
};
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
163
|
+
i.setFullYear(r.year, r.month, r.day), i.setHours(
|
|
164
|
+
r.hour,
|
|
165
|
+
r.minute,
|
|
166
|
+
r.second,
|
|
167
|
+
r.millisecond
|
|
179
168
|
);
|
|
180
|
-
const
|
|
181
|
-
|
|
182
|
-
const h = new Date(
|
|
183
|
-
h.setDate(
|
|
184
|
-
const
|
|
185
|
-
if (u === "compatible" ||
|
|
186
|
-
return this.nativeDate =
|
|
187
|
-
const
|
|
188
|
-
new Date(
|
|
189
|
-
), it =
|
|
190
|
-
if (!
|
|
191
|
-
return this.nativeDate =
|
|
169
|
+
const l = i.getTime(), d = new Date(l);
|
|
170
|
+
d.setDate(i.getDate() + 1);
|
|
171
|
+
const h = new Date(l);
|
|
172
|
+
h.setDate(i.getDate() - 1);
|
|
173
|
+
const c = d.getTimezoneOffset() - h.getTimezoneOffset();
|
|
174
|
+
if (u === "compatible" || c === 0)
|
|
175
|
+
return this.nativeDate = i, this;
|
|
176
|
+
const D = r.year * 1e8 + r.month * 1e6 + r.day * 1e4 + r.hour * 100 + r.minute < i.getFullYear() * 1e8 + i.getMonth() * 1e6 + i.getDate() * 1e4 + i.getHours() * 100 + i.getMinutes(), O = new Date(
|
|
177
|
+
new Date(l).setUTCMinutes(i.getUTCMinutes() + c)
|
|
178
|
+
), it = O.getHours() === i.getHours() && O.getMinutes() === i.getMinutes();
|
|
179
|
+
if (!D && !it)
|
|
180
|
+
return this.nativeDate = i, this;
|
|
192
181
|
if (u === "reject")
|
|
193
|
-
throw new RangeError(`Requested local time ${
|
|
194
|
-
return this.nativeDate = u === "later" ?
|
|
182
|
+
throw new RangeError(`Requested local time ${r} is ambiguous.`);
|
|
183
|
+
return this.nativeDate = u === "later" ? i : O, this;
|
|
195
184
|
}
|
|
196
|
-
const
|
|
185
|
+
const vt = new RegExp(
|
|
197
186
|
// yyyy[[-|/]MM[[-|/]DD]]
|
|
198
187
|
"^(\\d{4})(?:[-/]?([0-2]?\\d)(?:[-/]?([0-3]?\\d))?)?(?:[T\\s]([0-2]?\\d)(?::([0-5]?\\d)?(?::([0-6]?\\d)?(?:[.:](\\d{1,3})?\\d*)?)?)?)?(Z|[-+]\\d{2}:?\\d{2})?$"
|
|
199
188
|
);
|
|
200
|
-
function
|
|
189
|
+
function Tt(t) {
|
|
201
190
|
var h;
|
|
202
|
-
const e = t.trim().toUpperCase(), n = e.match(
|
|
191
|
+
const e = t.trim().toUpperCase(), n = e.match(vt);
|
|
203
192
|
if (!n)
|
|
204
193
|
throw RangeError(
|
|
205
194
|
`Failed to parse '${t}'. Should be yyyy[[-|/]MM[[-|/]DD]][(T| )HH:mm[:ss[(.|:)SSS]]][Z|(+|-)hh:mm]`
|
|
206
195
|
);
|
|
207
|
-
const u = n[4] !== void 0, [s,
|
|
196
|
+
const u = n[4] !== void 0, [s, i, r, l] = [
|
|
208
197
|
+n[1],
|
|
209
198
|
+n[2] || 1,
|
|
210
199
|
+n[3] || 1,
|
|
211
200
|
n[8]
|
|
212
|
-
],
|
|
213
|
-
if (!tt(
|
|
201
|
+
], d = new Date(e);
|
|
202
|
+
if (!tt(d))
|
|
214
203
|
throw RangeError(
|
|
215
204
|
`Failed to parse '${t}' by Date. Should be yyyy[[-|/]MM[[-|/]DD]][(T| )HH:mm[:ss[(.|:)SSS]]][Z|(+|-)hh:mm]`
|
|
216
205
|
);
|
|
217
|
-
return
|
|
206
|
+
return l ? this.nativeDate = d : u ? this.set({
|
|
218
207
|
year: s,
|
|
219
|
-
month:
|
|
220
|
-
day:
|
|
208
|
+
month: i,
|
|
209
|
+
day: r,
|
|
221
210
|
hour: +n[4] || 0,
|
|
222
211
|
minute: +n[5] || 0,
|
|
223
212
|
second: +n[6] || 0,
|
|
224
213
|
millisecond: +((h = n[7]) == null ? void 0 : h.padStart(3, "0")) || 0
|
|
225
|
-
}) : this.set({ year: s, month:
|
|
214
|
+
}) : this.set({ year: s, month: i, day: r }), this;
|
|
226
215
|
}
|
|
227
|
-
const
|
|
216
|
+
const m = (t, e) => String(t).padStart(e, "0");
|
|
228
217
|
o.prototype.toString = function() {
|
|
229
|
-
if (this[
|
|
230
|
-
const t = this[
|
|
231
|
-
return `${
|
|
218
|
+
if (this[f].localtime) {
|
|
219
|
+
const t = this[f].nativeDate, e = -t.getTimezoneOffset(), n = Math.abs(e);
|
|
220
|
+
return `${m(t.getFullYear(), 4)}-${m(t.getMonth() + 1, 2)}-${m(t.getDate(), 2)}T${m(t.getHours(), 2)}:${m(t.getMinutes(), 2)}:${m(t.getSeconds(), 2)}.${m(t.getMilliseconds(), 3)}${e >= 0 ? "+" : "-"}${m(Math.trunc(n / v), 2)}:${m(n % v, 2)}`;
|
|
232
221
|
}
|
|
233
|
-
return this[
|
|
222
|
+
return this[f].nativeDate.toISOString();
|
|
234
223
|
};
|
|
235
224
|
o.prototype.valueOf = function() {
|
|
236
|
-
return this[
|
|
225
|
+
return this[f].nativeDate.valueOf();
|
|
237
226
|
};
|
|
238
227
|
o.prototype.clone = function(...t) {
|
|
239
228
|
return new o(this, ...t);
|
|
240
229
|
};
|
|
241
230
|
o.prototype.context = function(t) {
|
|
242
|
-
return
|
|
243
|
-
localtime: this[
|
|
244
|
-
disambiguation: this[
|
|
231
|
+
return Y(t) ? this.clone(t) : {
|
|
232
|
+
localtime: this[f].localtime,
|
|
233
|
+
disambiguation: this[f].disambiguation
|
|
245
234
|
};
|
|
246
235
|
};
|
|
247
236
|
o.prototype.nativeDate = function() {
|
|
248
|
-
return new Date(this[
|
|
237
|
+
return new Date(this[f].nativeDate.getTime());
|
|
249
238
|
};
|
|
250
239
|
o.prototype.offset = function() {
|
|
251
|
-
return this[
|
|
252
|
-
};
|
|
253
|
-
o.prototype.localtime = function(t) {
|
|
254
|
-
return w(t) ? this.clone({ localtime: t }) : this[c].localtime;
|
|
255
|
-
};
|
|
256
|
-
o.prototype.disambiguation = function(t) {
|
|
257
|
-
return w(t) ? this.clone({ disambiguation: t }) : this[c].disambiguation;
|
|
240
|
+
return this[f].localtime ? -this[f].nativeDate.getTimezoneOffset() : 0;
|
|
258
241
|
};
|
|
259
242
|
o.prototype.valid = function() {
|
|
260
|
-
return this[
|
|
261
|
-
};
|
|
262
|
-
o.prototype.numeric = function() {
|
|
263
|
-
return this[c].nativeDate.getTime();
|
|
243
|
+
return this[f].valid();
|
|
264
244
|
};
|
|
265
245
|
o.prototype.toObject = function() {
|
|
266
246
|
return {
|
|
@@ -287,12 +267,6 @@ o.prototype.toArray = function() {
|
|
|
287
267
|
o.prototype.toDate = function(...t) {
|
|
288
268
|
return new a(this.clone(...t));
|
|
289
269
|
};
|
|
290
|
-
o.prototype.asUtc = function() {
|
|
291
|
-
return this.clone({ localtime: !1 });
|
|
292
|
-
};
|
|
293
|
-
o.prototype.asLocaltime = function() {
|
|
294
|
-
return this.clone({ localtime: !0 });
|
|
295
|
-
};
|
|
296
270
|
for (const [t, e, n] of [
|
|
297
271
|
["year", "FullYear", 0],
|
|
298
272
|
["month", "Month", 1],
|
|
@@ -303,37 +277,37 @@ for (const [t, e, n] of [
|
|
|
303
277
|
["millisecond", "Milliseconds", 0]
|
|
304
278
|
])
|
|
305
279
|
o.prototype[t] = function(u) {
|
|
306
|
-
return
|
|
280
|
+
return Y(u) ? this.clone({ [t]: u }) : this[f].getNative(e) + n;
|
|
307
281
|
};
|
|
308
282
|
o.prototype.dayOfWeek = function() {
|
|
309
|
-
return 1 + (this[
|
|
283
|
+
return 1 + (this[f].getNative("Day") - 1 + b) % b;
|
|
310
284
|
};
|
|
311
285
|
o.prototype.dayOfYear = function() {
|
|
312
286
|
const t = this.toDate();
|
|
313
287
|
return 1 + t - t.startOfYear();
|
|
314
288
|
};
|
|
315
289
|
o.prototype.weekOfYear = function() {
|
|
316
|
-
const t = this.toDate(), e = t.day(t.day() - t.dayOfWeek() +
|
|
317
|
-
1 + (
|
|
290
|
+
const t = this.toDate(), e = t.day(t.day() - t.dayOfWeek() + w), n = e.startOfYear(), u = n.dayOfWeek() === w ? n : n.day(
|
|
291
|
+
1 + (w - n.dayOfWeek() + b) % b
|
|
318
292
|
);
|
|
319
|
-
return 1 + Math.ceil((e - u) /
|
|
293
|
+
return 1 + Math.ceil((e - u) / b);
|
|
320
294
|
};
|
|
321
295
|
o.prototype.yearOfWeek = function() {
|
|
322
296
|
const t = this.toDate();
|
|
323
|
-
return t.day(t.day() - t.dayOfWeek() +
|
|
297
|
+
return t.day(t.day() - t.dayOfWeek() + w).year();
|
|
324
298
|
};
|
|
325
299
|
o.prototype.isLeapYear = function() {
|
|
326
300
|
const t = this.year();
|
|
327
301
|
return t % 4 === 0 && (t % 100 !== 0 || t % 400 === 0);
|
|
328
302
|
};
|
|
329
303
|
o.prototype.hasDstInYear = function() {
|
|
330
|
-
if (!this[
|
|
304
|
+
if (!this[f].localtime)
|
|
331
305
|
return !1;
|
|
332
306
|
const t = this.offset();
|
|
333
307
|
return [3, 6, 9, 12].map((e) => this.month(e).offset()).some((e) => e !== t);
|
|
334
308
|
};
|
|
335
309
|
o.prototype.isInDst = function() {
|
|
336
|
-
if (!this[
|
|
310
|
+
if (!this[f].localtime)
|
|
337
311
|
return !1;
|
|
338
312
|
const t = Array.from(
|
|
339
313
|
{ length: 12 },
|
|
@@ -342,10 +316,10 @@ o.prototype.isInDst = function() {
|
|
|
342
316
|
return e !== n && this.offset() === n;
|
|
343
317
|
};
|
|
344
318
|
o.prototype.isDstTransitionDay = function() {
|
|
345
|
-
return this[
|
|
319
|
+
return this[f].localtime ? this.minutesInDay() !== N : !1;
|
|
346
320
|
};
|
|
347
321
|
o.prototype.minutesInDay = function() {
|
|
348
|
-
if (!this[
|
|
322
|
+
if (!this[f].localtime)
|
|
349
323
|
return N;
|
|
350
324
|
const t = this.context({ disambiguation: "later" }).startOfDay(), e = t.plus({ day: 1 }).startOfDay();
|
|
351
325
|
return t.day() === e.day() ? N : (e - t) / ht;
|
|
@@ -359,7 +333,7 @@ o.prototype.daysInYear = function() {
|
|
|
359
333
|
};
|
|
360
334
|
o.prototype.weeksInYear = function() {
|
|
361
335
|
const t = this.toDate({ month: 12, day: 31 }), e = t.minus({ year: 1 });
|
|
362
|
-
return t.dayOfWeek() ===
|
|
336
|
+
return t.dayOfWeek() === w || e.dayOfWeek() === et ? 53 : 52;
|
|
363
337
|
};
|
|
364
338
|
for (const [t, e] of [
|
|
365
339
|
["Year", { month: 1, day: 1, hour: 0, minute: 0, second: 0, millisecond: 0 }],
|
|
@@ -375,7 +349,7 @@ o.prototype.startOfDay = function() {
|
|
|
375
349
|
const t = this.clone(
|
|
376
350
|
{ disambiguation: "later" },
|
|
377
351
|
{ hour: 0, minute: 0, second: 0, millisecond: 0 }
|
|
378
|
-
).
|
|
352
|
+
).valueOf();
|
|
379
353
|
return this.clone(t);
|
|
380
354
|
};
|
|
381
355
|
o.prototype.isSame = function(t) {
|
|
@@ -403,81 +377,78 @@ o.prototype.minus = function(...t) {
|
|
|
403
377
|
return nt.call(this, -1, ...t);
|
|
404
378
|
};
|
|
405
379
|
function nt(t, ...e) {
|
|
406
|
-
var
|
|
380
|
+
var l, d;
|
|
407
381
|
const n = e[0], u = e[1];
|
|
408
382
|
if (Number.isFinite(n) && !Number.isFinite(u))
|
|
409
|
-
return this.clone(this.
|
|
383
|
+
return this.clone(this.valueOf() + n);
|
|
410
384
|
let s = null;
|
|
411
|
-
if (
|
|
412
|
-
if (!
|
|
385
|
+
if (T(n)) {
|
|
386
|
+
if (!S(n))
|
|
413
387
|
throw RangeError(
|
|
414
388
|
"Missing time field (year, minute, day, hour, minute, second or millisecond)"
|
|
415
389
|
);
|
|
416
390
|
s = n;
|
|
417
391
|
} else if (Number.isFinite(n) || Array.isArray(n)) {
|
|
418
|
-
const h = e.flat(),
|
|
419
|
-
if (
|
|
392
|
+
const h = e.flat(), c = h.filter((D) => Number.isSafeInteger(D));
|
|
393
|
+
if (c.length !== h.length)
|
|
420
394
|
throw RangeError("Should be safe integers");
|
|
421
|
-
if (
|
|
395
|
+
if (c.length > 7)
|
|
422
396
|
throw RangeError("Too many numbers");
|
|
423
397
|
s = {
|
|
424
|
-
year:
|
|
425
|
-
month:
|
|
426
|
-
day:
|
|
427
|
-
hour:
|
|
428
|
-
minute:
|
|
429
|
-
second:
|
|
430
|
-
millisecond:
|
|
398
|
+
year: c[0],
|
|
399
|
+
month: c[1],
|
|
400
|
+
day: c[2],
|
|
401
|
+
hour: c[3],
|
|
402
|
+
minute: c[4],
|
|
403
|
+
second: c[5],
|
|
404
|
+
millisecond: c[6]
|
|
431
405
|
};
|
|
432
406
|
} else
|
|
433
407
|
throw TypeError();
|
|
434
|
-
const
|
|
435
|
-
if (
|
|
436
|
-
const h = this.year() + t * ((
|
|
437
|
-
|
|
438
|
-
const
|
|
439
|
-
|
|
408
|
+
const i = this.nativeDate(), r = this[f].localtime ? "" : "UTC";
|
|
409
|
+
if (p(s, "year") || p(s, "month")) {
|
|
410
|
+
const h = this.year() + t * ((l = s.year) != null ? l : 0), c = this.month() + t * ((d = s.month) != null ? d : 0), D = new Date(i.getTime());
|
|
411
|
+
D[`set${r}FullYear`](h, c, 0);
|
|
412
|
+
const O = D[`get${r}Date`]();
|
|
413
|
+
O < this.day() ? i[`set${r}FullYear`](h, D[`get${r}Month`](), O) : i[`set${r}FullYear`](h, c - 1);
|
|
440
414
|
}
|
|
441
|
-
|
|
442
|
-
for (const [h,
|
|
415
|
+
p(s, "day") && i[`set${r}Date`](i[`get${r}Date`]() + t * s.day);
|
|
416
|
+
for (const [h, c] of [
|
|
443
417
|
["hour", "Hours"],
|
|
444
418
|
["minute", "Minutes"],
|
|
445
419
|
["second", "Seconds"],
|
|
446
420
|
["millisecond", "Milliseconds"]
|
|
447
421
|
])
|
|
448
|
-
!
|
|
449
|
-
|
|
422
|
+
!p(s, h) || s[h] == null || i[`setUTC${c}`](
|
|
423
|
+
i[`getUTC${c}`]() + t * s[h]
|
|
450
424
|
);
|
|
451
|
-
return this.clone(
|
|
425
|
+
return this.clone(i);
|
|
452
426
|
}
|
|
453
|
-
const
|
|
427
|
+
const y = /* @__PURE__ */ Symbol();
|
|
454
428
|
function a(...t) {
|
|
455
429
|
if (!new.target)
|
|
456
430
|
return new a(...t);
|
|
457
431
|
const e = { datetime: null };
|
|
458
|
-
this[
|
|
432
|
+
this[y] = e;
|
|
459
433
|
let n = null;
|
|
460
434
|
t[0] instanceof a ? n = t.shift().toDatetime() : t[0] instanceof o && (n = t.shift());
|
|
461
435
|
const u = t[0], s = t[1];
|
|
462
|
-
return Number.isFinite(u) && !Number.isFinite(s) && (t[0] = Math.floor(u) *
|
|
436
|
+
return Number.isFinite(u) && !Number.isFinite(s) && (t[0] = Math.floor(u) * J), n ? n = n.clone(...t) : n = k(...t), e.datetime = n.startOfDay(), this;
|
|
463
437
|
}
|
|
464
438
|
a.prototype.toString = function() {
|
|
465
|
-
return this[
|
|
439
|
+
return this[y].datetime.toString().substring(0, 10);
|
|
466
440
|
};
|
|
467
441
|
a.prototype.valueOf = function() {
|
|
468
|
-
return this[
|
|
442
|
+
return this[y].datetime / J;
|
|
469
443
|
};
|
|
470
444
|
a.prototype.valid = function() {
|
|
471
|
-
return this[
|
|
445
|
+
return this[y].datetime.valid();
|
|
472
446
|
};
|
|
473
447
|
a.prototype.clone = function(...t) {
|
|
474
448
|
return new a(this, ...t);
|
|
475
449
|
};
|
|
476
450
|
a.prototype.toDatetime = function() {
|
|
477
|
-
return
|
|
478
|
-
};
|
|
479
|
-
a.prototype.numeric = function() {
|
|
480
|
-
return this[l].datetime.numeric() / U;
|
|
451
|
+
return k(this[y].datetime.toArray());
|
|
481
452
|
};
|
|
482
453
|
a.prototype.toObject = function() {
|
|
483
454
|
return {
|
|
@@ -490,17 +461,14 @@ a.prototype.toArray = function() {
|
|
|
490
461
|
return [this.year(), this.month(), this.day()];
|
|
491
462
|
};
|
|
492
463
|
a.prototype.startOfYear = function() {
|
|
493
|
-
return new a(this[
|
|
464
|
+
return new a(this[y].datetime.startOfYear());
|
|
494
465
|
};
|
|
495
466
|
a.prototype.startOfMonth = function() {
|
|
496
|
-
return new a(this[
|
|
497
|
-
};
|
|
498
|
-
a.prototype.startOfDay = function() {
|
|
499
|
-
return this[l].datetime.clone();
|
|
467
|
+
return new a(this[y].datetime.startOfMonth());
|
|
500
468
|
};
|
|
501
469
|
for (const t of ["year", "month", "day"])
|
|
502
470
|
a.prototype[t] = function(e) {
|
|
503
|
-
return
|
|
471
|
+
return Y(e) ? new a(this[y].datetime[t](e)) : this[y].datetime[t]();
|
|
504
472
|
};
|
|
505
473
|
for (const t of [
|
|
506
474
|
"dayOfWeek",
|
|
@@ -513,13 +481,13 @@ for (const t of [
|
|
|
513
481
|
"weeksInYear"
|
|
514
482
|
])
|
|
515
483
|
a.prototype[t] = function() {
|
|
516
|
-
return this[
|
|
484
|
+
return this[y].datetime[t]();
|
|
517
485
|
};
|
|
518
486
|
for (const t of ["minutesInDay", "hasDstInYear", "isDstTransitionDay"])
|
|
519
487
|
a.prototype[t] = function() {
|
|
520
|
-
return
|
|
488
|
+
return k(
|
|
521
489
|
{ disambiguation: "later" },
|
|
522
|
-
this[
|
|
490
|
+
this[y].datetime.toArray().slice(0, 3)
|
|
523
491
|
)[t]();
|
|
524
492
|
};
|
|
525
493
|
a.prototype.endOfYear = function() {
|
|
@@ -553,34 +521,34 @@ a.prototype.minus = function(...t) {
|
|
|
553
521
|
return ot.call(this, -1, ...t);
|
|
554
522
|
};
|
|
555
523
|
function ot(t, ...e) {
|
|
556
|
-
var
|
|
557
|
-
const n = e[0], u = e[1], s = this[
|
|
524
|
+
var r, l, d;
|
|
525
|
+
const n = e[0], u = e[1], s = this[y].datetime;
|
|
558
526
|
if (Number.isFinite(n) && !Number.isFinite(u))
|
|
559
527
|
return s.plus({ day: t * n }).toDate();
|
|
560
|
-
let
|
|
561
|
-
if (
|
|
562
|
-
|
|
563
|
-
year: t * ((
|
|
564
|
-
month: t * ((
|
|
565
|
-
day: t * ((
|
|
528
|
+
let i = null;
|
|
529
|
+
if (T(n) && S(n))
|
|
530
|
+
i = {
|
|
531
|
+
year: t * ((r = n.year) != null ? r : 0),
|
|
532
|
+
month: t * ((l = n.month) != null ? l : 0),
|
|
533
|
+
day: t * ((d = n.day) != null ? d : 0)
|
|
566
534
|
};
|
|
567
535
|
else if (Number.isFinite(n)) {
|
|
568
536
|
if (e.length > 3)
|
|
569
537
|
throw RangeError("Too many arguments");
|
|
570
|
-
|
|
538
|
+
i = { year: t * n, month: t * u, day: t * arg2 };
|
|
571
539
|
} else if (Array.isArray(n)) {
|
|
572
540
|
if (n.length > 3)
|
|
573
541
|
throw RangeError("Too many elements");
|
|
574
|
-
|
|
542
|
+
i = {
|
|
575
543
|
year: t * n[0],
|
|
576
544
|
month: t * n[1],
|
|
577
545
|
day: t * n[2]
|
|
578
546
|
};
|
|
579
547
|
} else
|
|
580
548
|
throw TypeError();
|
|
581
|
-
return s.plus(
|
|
549
|
+
return s.plus(i).toDate();
|
|
582
550
|
}
|
|
583
551
|
export {
|
|
584
|
-
|
|
552
|
+
k as qrono
|
|
585
553
|
};
|
|
586
554
|
//# sourceMappingURL=qrono.js.map
|