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