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