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