@bereasoftware/time-guard 2.5.4 → 2.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/calendars/index.cjs.map +1 -1
- package/dist/calendars/index.es.js +1 -1
- package/dist/calendars/index.es.js.map +1 -1
- package/dist/locales/index.cjs +1 -2
- package/dist/locales/index.es.js +3 -2797
- package/dist/locales-DSBvgSaw.js +2798 -0
- package/dist/locales-DSBvgSaw.js.map +1 -0
- package/dist/locales-ybx7jS8G.cjs +2 -0
- package/dist/locales-ybx7jS8G.cjs.map +1 -0
- package/dist/plugins/advanced-format.cjs.map +1 -1
- package/dist/plugins/advanced-format.es.js +1 -1
- package/dist/plugins/advanced-format.es.js.map +1 -1
- package/dist/plugins/duration.cjs.map +1 -1
- package/dist/plugins/duration.es.js +1 -1
- package/dist/plugins/duration.es.js.map +1 -1
- package/dist/plugins/relative-time.cjs.map +1 -1
- package/dist/plugins/relative-time.es.js +1 -1
- package/dist/plugins/relative-time.es.js.map +1 -1
- package/dist/time-guard.cjs +2 -2
- package/dist/time-guard.cjs.map +1 -1
- package/dist/time-guard.es.js +54 -17
- package/dist/time-guard.es.js.map +1 -1
- package/dist/time-guard.iife.js +2 -2
- package/dist/time-guard.iife.js.map +1 -1
- package/dist/time-guard.umd.js +2 -2
- package/dist/time-guard.umd.js.map +1 -1
- package/dist/types/adapters/temporal.adapter.d.ts +9 -6
- package/dist/types/index.d.ts +10 -10
- package/dist/types/plugins/index.d.ts +5 -5
- package/dist/types/time-guard.d.ts +2 -0
- package/dist/types/types/index.d.ts +67 -12
- package/package.json +20 -6
- package/dist/locales/index.cjs.map +0 -1
- package/dist/locales/index.es.js.map +0 -1
package/dist/time-guard.es.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
/*! time-guard v2.
|
|
1
|
+
/*! time-guard v2.6.1 | (c) 2026 Berea-Soft | MIT License | https://github.com/Berea-Soft/time-guard */
|
|
2
2
|
//#region \0rolldown/runtime.js
|
|
3
|
-
var e = Object.create, t = Object.defineProperty, n = Object.getOwnPropertyDescriptor, r = Object.getOwnPropertyNames, i = Object.getPrototypeOf, a = Object.prototype.hasOwnProperty, o = (e, t) => () => (t || e((t = { exports: {} }).exports, t), t.exports), s = (e, i, o, s) => {
|
|
3
|
+
var e = Object.create, t = Object.defineProperty, n = Object.getOwnPropertyDescriptor, r = Object.getOwnPropertyNames, i = Object.getPrototypeOf, a = Object.prototype.hasOwnProperty, o = (e, t) => () => (t || (e((t = { exports: {} }).exports, t), e = null), t.exports), s = (e, i, o, s) => {
|
|
4
4
|
if (i && typeof i == "object" || typeof i == "function") for (var c = r(i), l = 0, u = c.length, d; l < u; l++) d = c[l], !a.call(e, d) && d !== o && t(e, d, {
|
|
5
5
|
get: ((e) => i[e]).bind(null, d),
|
|
6
6
|
enumerable: !(s = n(i, d)) || s.enumerable
|
|
@@ -7127,7 +7127,7 @@ for (let e of Ro) {
|
|
|
7127
7127
|
var zo = null;
|
|
7128
7128
|
function Bo() {
|
|
7129
7129
|
if (zo) return zo;
|
|
7130
|
-
let e = globalThis.Temporal
|
|
7130
|
+
let e = globalThis.Temporal ?? Lo;
|
|
7131
7131
|
if (!e) throw Error("Temporal API not loaded. Make sure @js-temporal/polyfill is imported in your app.");
|
|
7132
7132
|
return zo = e, e;
|
|
7133
7133
|
}
|
|
@@ -7163,13 +7163,13 @@ var $ = class {
|
|
|
7163
7163
|
static fromObject(e) {
|
|
7164
7164
|
let t = Bo(), n = e.year || t.Now.plainDateISO().year, r = e.month || 1, i = e.day || 1, a = e.hour || 0, o = e.minute || 0, s = e.second || 0, c = e.millisecond || 0;
|
|
7165
7165
|
return t.PlainDateTime.from({
|
|
7166
|
-
year: n,
|
|
7167
|
-
month: r,
|
|
7168
|
-
day: i,
|
|
7169
|
-
hour: a,
|
|
7170
|
-
minute: o,
|
|
7171
|
-
second: s,
|
|
7172
|
-
millisecond: c
|
|
7166
|
+
year: this.toFiniteInteger(n),
|
|
7167
|
+
month: this.toFiniteInteger(r),
|
|
7168
|
+
day: this.toFiniteInteger(i),
|
|
7169
|
+
hour: this.toFiniteInteger(a),
|
|
7170
|
+
minute: this.toFiniteInteger(o),
|
|
7171
|
+
second: this.toFiniteInteger(s),
|
|
7172
|
+
millisecond: this.toFiniteInteger(c)
|
|
7173
7173
|
});
|
|
7174
7174
|
}
|
|
7175
7175
|
static toDate(e) {
|
|
@@ -7198,6 +7198,25 @@ var $ = class {
|
|
|
7198
7198
|
static isPlainTime(e) {
|
|
7199
7199
|
return typeof e == "object" && !!e && "hour" in e && !("year" in e);
|
|
7200
7200
|
}
|
|
7201
|
+
static toFiniteInteger(e) {
|
|
7202
|
+
let t = Number(e);
|
|
7203
|
+
if (!Number.isFinite(t)) throw Error(`Temporal error: Expected finite integer, got ${e}`);
|
|
7204
|
+
return Math.trunc(t);
|
|
7205
|
+
}
|
|
7206
|
+
static validatePlainDateTime(e) {
|
|
7207
|
+
for (let t of [
|
|
7208
|
+
"year",
|
|
7209
|
+
"month",
|
|
7210
|
+
"day",
|
|
7211
|
+
"hour",
|
|
7212
|
+
"minute",
|
|
7213
|
+
"second",
|
|
7214
|
+
"millisecond"
|
|
7215
|
+
]) {
|
|
7216
|
+
let n = e[t];
|
|
7217
|
+
if (typeof n != "number" || !Number.isFinite(n) || !Number.isInteger(n)) throw typeof console < "u" && typeof console.error == "function" && console.error("TemporalAdapter.validatePlainDateTime: campo inválido", t, n, e), Error(`Temporal error: Expected finite integer for ${t}, got ${n}`);
|
|
7218
|
+
}
|
|
7219
|
+
}
|
|
7201
7220
|
static now() {
|
|
7202
7221
|
return Bo().Now.plainDateTimeISO();
|
|
7203
7222
|
}
|
|
@@ -7206,7 +7225,7 @@ var $ = class {
|
|
|
7206
7225
|
}
|
|
7207
7226
|
static compare(e, t) {
|
|
7208
7227
|
let n = Bo();
|
|
7209
|
-
if (n.PlainDateTime && typeof n.PlainDateTime.compare == "function") return n.PlainDateTime.compare(e, t);
|
|
7228
|
+
if (this.validatePlainDateTime(e), this.validatePlainDateTime(t), n.PlainDateTime && typeof n.PlainDateTime.compare == "function") return n.PlainDateTime.compare(e, t);
|
|
7210
7229
|
let r = e.toString(), i = t.toString();
|
|
7211
7230
|
return r < i ? -1 : +(r > i);
|
|
7212
7231
|
}
|
|
@@ -10740,7 +10759,7 @@ var ls = 40, us = class {
|
|
|
10740
10759
|
return;
|
|
10741
10760
|
}
|
|
10742
10761
|
try {
|
|
10743
|
-
e.install(t, n), this.plugins.set(e.name, e), console.
|
|
10762
|
+
e.install(t, n), this.plugins.set(e.name, e), process.env.NODE_ENV !== "production" && console.warn(`Plugin "${e.name}" v${e.version} registered successfully`);
|
|
10744
10763
|
} catch (t) {
|
|
10745
10764
|
throw console.error(`Failed to register plugin "${e.name}":`, t), Error(`Failed to register plugin "${e.name}": ${t instanceof Error ? t.message : String(t)}`);
|
|
10746
10765
|
}
|
|
@@ -11321,7 +11340,8 @@ var Rs = class {
|
|
|
11321
11340
|
timezone: t?.timezone || "UTC",
|
|
11322
11341
|
strict: t?.strict ?? !1
|
|
11323
11342
|
}, this.temporal = $.parseToPlainDateTime(e), this.config.timezone && this.config.timezone !== "UTC") try {
|
|
11324
|
-
|
|
11343
|
+
let e = this.temporal.toZonedDateTime(this.config.timezone);
|
|
11344
|
+
this.temporal = e;
|
|
11325
11345
|
} catch {}
|
|
11326
11346
|
}
|
|
11327
11347
|
static now(t) {
|
|
@@ -11359,6 +11379,9 @@ var Rs = class {
|
|
|
11359
11379
|
toJSON() {
|
|
11360
11380
|
return this.toISOString();
|
|
11361
11381
|
}
|
|
11382
|
+
[Symbol.toPrimitive](e) {
|
|
11383
|
+
return e === "number" ? this.valueOf() : this.toISOString();
|
|
11384
|
+
}
|
|
11362
11385
|
toString() {
|
|
11363
11386
|
return this.format("YYYY-MM-DD HH:mm:ss");
|
|
11364
11387
|
}
|
|
@@ -11404,10 +11427,24 @@ var Rs = class {
|
|
|
11404
11427
|
}[e]];
|
|
11405
11428
|
}
|
|
11406
11429
|
add(t) {
|
|
11407
|
-
let n = $.toPlainDateTime(this.temporal), r = {
|
|
11430
|
+
let n = $.toPlainDateTime(this.temporal), r = {
|
|
11431
|
+
year: 0,
|
|
11432
|
+
month: 0,
|
|
11433
|
+
week: 0,
|
|
11434
|
+
day: 0,
|
|
11435
|
+
hour: 0,
|
|
11436
|
+
minute: 0,
|
|
11437
|
+
second: 0,
|
|
11438
|
+
millisecond: 0,
|
|
11439
|
+
microsecond: 0,
|
|
11440
|
+
nanosecond: 0
|
|
11441
|
+
}, i = !1;
|
|
11408
11442
|
return Object.entries(t).forEach(([e, t]) => {
|
|
11409
|
-
t !== void 0 && t !== 0
|
|
11410
|
-
|
|
11443
|
+
if (t !== void 0 && t !== 0) {
|
|
11444
|
+
let n = Number(t);
|
|
11445
|
+
Number.isFinite(n) && (r[e + "s"] = Math.trunc(n), i = !0);
|
|
11446
|
+
}
|
|
11447
|
+
}), i ? (n = n.add(r), e.fromTemporal(n, this.config)) : this;
|
|
11411
11448
|
}
|
|
11412
11449
|
subtract(e) {
|
|
11413
11450
|
let t = {};
|
|
@@ -11763,7 +11800,7 @@ var Rs = class {
|
|
|
11763
11800
|
function Hs(e, t) {
|
|
11764
11801
|
return new Vs(e, t);
|
|
11765
11802
|
}
|
|
11766
|
-
var Us = "2.
|
|
11803
|
+
var Us = "2.6.1";
|
|
11767
11804
|
Uo.getInstance().loadLocales(os);
|
|
11768
11805
|
//#endregion
|
|
11769
11806
|
export { os as ALL_LOCALES, Es as AdvancedFormatPlugin, _s as BuddhistCalendar, ds as CalendarManager, hs as ChineseCalendar, Wo as DateFormatter, Cs as Duration, ws as DurationPlugin, zs as DurationResult, Vo as EN_LOCALE, Ho as ES_LOCALE, us as GregorianCalendar, ms as HebrewCalendar, ps as IslamicCalendar, gs as JapaneseCalendar, ls as LOCALES_COUNT, Uo as LocaleManager, vs as PluginManager, xs as RelativeTimePlugin, $ as TemporalAdapter, Vs as TimeGuard, Bs as TimeRange, Ds as advancedFormatPlugin, fs as calendarManager, Ts as durationPlugin, cs as getAvailableLocales, ss as registerAllLocales, Ss as relativeTimePlugin, Hs as timeGuard, Us as version };
|