lakutata
Version:
An IoC-based universal application framework.
239 lines (208 loc) • 7 kB
JavaScript
/* Build Date: Mon Jan 05 2026 23:52:23 GMT+0800 (China Standard Time) */
"use strict";
Object.defineProperty(exports, Symbol.toStringTag, {
value: "Module"
});
require("../../../vendor/Package.internal.1.cjs");
const e = require("../../../vendor/Package.internal.5.cjs");
const t = require("../../../vendor/Package.internal.7.cjs");
require("../../../vendor/Package.internal.2.cjs");
require("../helpers/As.cjs");
require("../../../vendor/Package.internal.6.cjs");
require("../base/internal/ThrowWarning.cjs");
require("../../../vendor/Package.internal.3.cjs");
require("../base/internal/DataValidator.cjs");
require("node:util/types");
require("../validation/VLD.cjs");
require("url");
require("util");
require("../../exceptions/dto/InvalidValueException.cjs");
require("../base/abstracts/Exception.cjs");
require("../helpers/Templating.cjs");
require("../base/internal/CamelCase.cjs");
require("../helpers/NoCase.cjs");
require("../helpers/DevNull.cjs");
require("../../../vendor/Package.internal.8.cjs");
require("../helpers/IsHtml.cjs");
require("../helpers/IsXML.cjs");
require("../../constants/DTOMetadataKey.cjs");
require("../helpers/ObjectConstructor.cjs");
require("../helpers/ObjectParentConstructors.cjs");
require("../helpers/ObjectParentConstructor.cjs");
require("../helpers/ObjectPrototype.cjs");
class Time extends Date {
#e;
constructor(n) {
if (n && typeof n === "string") n = t.DTO.validate(n, t.DTO.Date().strict(false));
const i = n ? n instanceof Time ? e.MomentTimezone(n.#e) : process.env.TZ ? e.MomentTimezone(n).tz(process.env.TZ) : e.MomentTimezone(n) : e.MomentTimezone().tz(process.env.TZ || Intl.DateTimeFormat().resolvedOptions().timeZone);
super(i.valueOf());
this.#e = i;
}
static timezones() {
return e.MomentTimezone.tz.names();
}
static max(...t) {
if (!t.length) return new Time;
const n = new Map;
t.forEach(e => n.set(e.#e, e));
return n.get(e.MomentTimezone.max(...n.keys()));
}
static min(...t) {
if (!t.length) return new Time;
const n = new Map;
t.forEach(e => n.set(e.#e, e));
return n.get(e.MomentTimezone.min(...n.keys()));
}
updateTimestampWithNewTime(e) {
const t = new Time(e);
const n = this.tz();
if (n) t.tz(n);
return t;
}
tz(e) {
if (e) {
this.#e = this.#e.tz(e);
return this;
} else {
return this.#e.tz();
}
}
getTimezoneOffset() {
return this.#e.utcOffset();
}
timezone(e) {
if (e) {
return new Time(this.getTime()).tz(e);
} else {
return this.tz();
}
}
milliseconds(e) {
return e !== undefined ? this.updateTimestampWithNewTime(this.#e.clone().milliseconds(e).valueOf()) : this.#e.milliseconds();
}
seconds(e) {
return e !== undefined ? this.updateTimestampWithNewTime(this.#e.clone().seconds(e).valueOf()) : this.#e.seconds();
}
minutes(e) {
return e !== undefined ? this.updateTimestampWithNewTime(this.#e.clone().minutes(e).valueOf()) : this.#e.minutes();
}
hours(e) {
return e !== undefined ? this.updateTimestampWithNewTime(this.#e.clone().hours(e).valueOf()) : this.#e.hours();
}
date(e) {
return e !== undefined ? this.updateTimestampWithNewTime(this.#e.clone().date(e).valueOf()) : this.#e.date();
}
weekday(e) {
return e !== undefined ? this.updateTimestampWithNewTime(this.#e.clone().weekday(e).valueOf()) : this.#e.weekday();
}
isoWeekday(e) {
return e !== undefined ? this.updateTimestampWithNewTime(this.#e.clone().isoWeekday(e).valueOf()) : this.#e.isoWeekday();
}
dayOfYear(e) {
return e !== undefined ? this.updateTimestampWithNewTime(this.#e.clone().dayOfYear(e).valueOf()) : this.#e.dayOfYear();
}
weeks(e) {
return e !== undefined ? this.updateTimestampWithNewTime(this.#e.clone().weeks(e).valueOf()) : this.#e.weeks();
}
isoWeeks(e) {
return e !== undefined ? this.updateTimestampWithNewTime(this.#e.clone().isoWeeks(e).valueOf()) : this.#e.isoWeeks();
}
month(e) {
return e !== undefined ? this.updateTimestampWithNewTime(this.#e.clone().month(e).valueOf()) : this.#e.month();
}
quarters(e) {
return e !== undefined ? this.updateTimestampWithNewTime(this.#e.clone().quarters(e).valueOf()) : this.#e.quarters();
}
year(e) {
return e !== undefined ? this.updateTimestampWithNewTime(this.#e.clone().year(e).valueOf()) : this.#e.year();
}
isoWeekYear(e) {
return e !== undefined ? this.updateTimestampWithNewTime(this.#e.clone().isoWeekYear(e).valueOf()) : this.#e.isoWeekYear();
}
weeksInYear() {
return this.#e.weeksInYear();
}
isoWeeksInYear() {
return this.#e.weeksInYear();
}
get(e) {
return this.#e.get(e);
}
set(e, t) {
return this.updateTimestampWithNewTime(this.#e.clone().set(e, t).valueOf());
}
add(e, t) {
return this.updateTimestampWithNewTime(this.#e.clone().add(e, t).valueOf());
}
subtract(e, t) {
return this.updateTimestampWithNewTime(this.#e.clone().subtract(e, t).valueOf());
}
startOf(e) {
return this.updateTimestampWithNewTime(this.#e.clone().startOf(e).valueOf());
}
endOf(e) {
return this.updateTimestampWithNewTime(this.#e.clone().endOf(e).valueOf());
}
format(e) {
return this.#e.format(e);
}
diff(e, t, n) {
return this.#e.diff(new Time(e).#e, t, n);
}
unix() {
this.valueOf();
return this.#e.unix();
}
daysInMonth() {
return this.#e.daysInMonth();
}
toArray() {
return this.#e.toArray();
}
toObject() {
return this.#e.toObject();
}
toString() {
return this.#e.toString();
}
toTimeString() {
return this.#e.toString();
}
toUTCString() {
return this.#e.toISOString(true);
}
toDateString() {
return this.#e.format("ddd MMM DD YYYY");
}
toISOString() {
return this.#e.toISOString();
}
toDate() {
return this.#e.toDate();
}
isBefore(e, t) {
return this.#e.isBefore(new Time(e).#e, t);
}
isSame(e, t) {
return this.#e.isSame(new Time(e).#e, t);
}
isAfter(e, t) {
return this.#e.isAfter(new Time(e).#e, t);
}
isSameOrBefore(e, t) {
return this.#e.isSameOrBefore(new Time(e).#e, t);
}
isSameOrAfter(e, t) {
return this.#e.isSameOrAfter(new Time(e).#e, t);
}
isBetween(e, t, n, i) {
return this.#e.isBetween(new Time(e).#e, new Time(t).#e, n, i);
}
isLeapYear() {
return this.#e.isLeapYear();
}
clone() {
return new Time(this.#e.clone().valueOf());
}
}
exports.Time = Time;