lakutata
Version:
An IoC-based universal application framework.
233 lines (204 loc) • 6.75 kB
JavaScript
/* Build Date: Mon Jan 05 2026 23:52:23 GMT+0800 (China Standard Time) */
import "../../../vendor/Package.internal.1.mjs";
import { M as e } from "../../../vendor/Package.internal.5.mjs";
import { D as t } from "../../../vendor/Package.internal.7.mjs";
import "../../../vendor/Package.internal.2.mjs";
import "../helpers/As.mjs";
import "../../../vendor/Package.internal.6.mjs";
import "../base/internal/ThrowWarning.mjs";
import "../../../vendor/Package.internal.3.mjs";
import "../base/internal/DataValidator.mjs";
import "node:util/types";
import "../validation/VLD.mjs";
import "url";
import "util";
import "../../exceptions/dto/InvalidValueException.mjs";
import "../base/abstracts/Exception.mjs";
import "../helpers/Templating.mjs";
import "../base/internal/CamelCase.mjs";
import "../helpers/NoCase.mjs";
import "../helpers/DevNull.mjs";
import "../../../vendor/Package.internal.8.mjs";
import "../helpers/IsHtml.mjs";
import "../helpers/IsXML.mjs";
import "../../constants/DTOMetadataKey.mjs";
import "../helpers/ObjectConstructor.mjs";
import "../helpers/ObjectParentConstructors.mjs";
import "../helpers/ObjectParentConstructor.mjs";
import "../helpers/ObjectPrototype.mjs";
class Time extends Date {
#e;
constructor(i) {
if (i && typeof i === "string") i = t.validate(i, t.Date().strict(false));
const n = i ? i instanceof Time ? e(i.#e) : process.env.TZ ? e(i).tz(process.env.TZ) : e(i) : e().tz(process.env.TZ || Intl.DateTimeFormat().resolvedOptions().timeZone);
super(n.valueOf());
this.#e = n;
}
static timezones() {
return e.tz.names();
}
static max(...t) {
if (!t.length) return new Time;
const i = new Map;
t.forEach(e => i.set(e.#e, e));
return i.get(e.max(...i.keys()));
}
static min(...t) {
if (!t.length) return new Time;
const i = new Map;
t.forEach(e => i.set(e.#e, e));
return i.get(e.min(...i.keys()));
}
updateTimestampWithNewTime(e) {
const t = new Time(e);
const i = this.tz();
if (i) t.tz(i);
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, i) {
return this.#e.diff(new Time(e).#e, t, i);
}
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, i, n) {
return this.#e.isBetween(new Time(e).#e, new Time(t).#e, i, n);
}
isLeapYear() {
return this.#e.isLeapYear();
}
clone() {
return new Time(this.#e.clone().valueOf());
}
}
export { Time };