@bereasoftware/time-guard 2.5.3 → 2.6.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/dist/calendars/index.es.js +1 -1
- package/dist/plugins/advanced-format.es.js +1 -1
- package/dist/plugins/duration.es.js +1 -1
- package/dist/plugins/relative-time.es.js +1 -1
- package/dist/time-guard.cjs +1 -1
- package/dist/time-guard.cjs.map +1 -1
- package/dist/time-guard.es.js +38 -13
- package/dist/time-guard.es.js.map +1 -1
- package/dist/time-guard.iife.js +1 -1
- package/dist/time-guard.iife.js.map +1 -1
- package/dist/time-guard.umd.js +1 -1
- package/dist/time-guard.umd.js.map +1 -1
- package/dist/types/adapters/temporal.adapter.d.ts +74 -0
- package/dist/types/calendars/calendar.manager.d.ts +52 -0
- package/dist/types/calendars/index.d.ts +81 -1
- package/dist/types/formatters/date.formatter.d.ts +21 -0
- package/dist/types/index.d.ts +206 -1
- package/dist/types/locales/additional.locale.d.ts +5 -0
- package/dist/types/locales/asian.locale.d.ts +9 -0
- package/dist/types/locales/english.locale.d.ts +6 -0
- package/dist/types/locales/european.locale.d.ts +9 -0
- package/dist/types/locales/index.d.ts +17 -1
- package/dist/types/locales/locale.manager.d.ts +42 -0
- package/dist/types/locales/middle-eastern.locale.d.ts +5 -0
- package/dist/types/locales/nordic.locale.d.ts +6 -0
- package/dist/types/locales/romance.locale.d.ts +7 -0
- package/dist/types/locales/slavic.locale.d.ts +6 -0
- package/dist/types/locales/spanish.locale.d.ts +5 -0
- package/dist/types/plugins/advanced-format/index.d.ts +15 -0
- package/dist/types/plugins/advanced-format.d.ts +5 -0
- package/dist/types/plugins/duration/index.d.ts +107 -0
- package/dist/types/plugins/duration/types.d.ts +85 -0
- package/dist/types/plugins/duration.d.ts +5 -0
- package/dist/types/plugins/index.d.ts +10 -0
- package/dist/types/plugins/manager.d.ts +58 -0
- package/dist/types/plugins/relative-time/index.d.ts +39 -0
- package/dist/types/plugins/relative-time/types.d.ts +27 -0
- package/dist/types/plugins/relative-time.d.ts +5 -0
- package/dist/types/types/index.d.ts +586 -0
- package/dist/types/utils/duration-locale.d.ts +33 -0
- package/package.json +1 -1
package/dist/time-guard.es.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! time-guard v2.
|
|
1
|
+
/*! time-guard v2.6.0 | (c) 2026 Berea-Soft | MIT License | https://github.com/Berea-Soft/time-guard */
|
|
2
2
|
//#region \0rolldown/runtime.js
|
|
3
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) => {
|
|
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, {
|
|
@@ -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 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
|
}
|
|
@@ -11359,6 +11378,9 @@ var Rs = class {
|
|
|
11359
11378
|
toJSON() {
|
|
11360
11379
|
return this.toISOString();
|
|
11361
11380
|
}
|
|
11381
|
+
[Symbol.toPrimitive](e) {
|
|
11382
|
+
return e === "number" ? this.valueOf() : this.toISOString();
|
|
11383
|
+
}
|
|
11362
11384
|
toString() {
|
|
11363
11385
|
return this.format("YYYY-MM-DD HH:mm:ss");
|
|
11364
11386
|
}
|
|
@@ -11404,10 +11426,13 @@ var Rs = class {
|
|
|
11404
11426
|
}[e]];
|
|
11405
11427
|
}
|
|
11406
11428
|
add(t) {
|
|
11407
|
-
let n = $.toPlainDateTime(this.temporal), r = {};
|
|
11429
|
+
let n = $.toPlainDateTime(this.temporal), r = {}, i = !1;
|
|
11408
11430
|
return Object.entries(t).forEach(([e, t]) => {
|
|
11409
|
-
t !== void 0 && t !== 0
|
|
11410
|
-
|
|
11431
|
+
if (t !== void 0 && t !== 0) {
|
|
11432
|
+
let n = Number(t);
|
|
11433
|
+
Number.isFinite(n) && (r[e + "s"] = Math.trunc(n), i = !0);
|
|
11434
|
+
}
|
|
11435
|
+
}), i ? (n = n.add(r), e.fromTemporal(n, this.config)) : this;
|
|
11411
11436
|
}
|
|
11412
11437
|
subtract(e) {
|
|
11413
11438
|
let t = {};
|
|
@@ -11763,7 +11788,7 @@ var Rs = class {
|
|
|
11763
11788
|
function Hs(e, t) {
|
|
11764
11789
|
return new Vs(e, t);
|
|
11765
11790
|
}
|
|
11766
|
-
var Us = "2.
|
|
11791
|
+
var Us = "2.6.0";
|
|
11767
11792
|
Uo.getInstance().loadLocales(os);
|
|
11768
11793
|
//#endregion
|
|
11769
11794
|
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 };
|