lakutata
Version:
An IoC-based universal application framework.
182 lines (174 loc) • 5.27 kB
JavaScript
"use strict";
Object.defineProperty(exports, Symbol.toStringTag, {
value: "Module"
});
require("../../../vendor/Package.4.cjs");
const e = require("../../../vendor/Package.6.cjs");
require("../../../vendor/Package.5.cjs");
require("../../../vendor/Package.7.cjs");
class Time extends Date {
#e;
constructor(t) {
const n = t ? t instanceof Time ? e.MomentTimezone(t.#e) : process.env.TZ ? e.MomentTimezone(t).tz(process.env.TZ) : e.MomentTimezone(t) : e.MomentTimezone().tz(process.env.TZ || Intl.DateTimeFormat().resolvedOptions().timeZone);
super(n.valueOf());
this.#e = n;
}
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()));
}
updateTimestamp(e) {
this.setTime(e);
return this;
}
getTimezoneOffset() {
return this.#e.utcOffset();
}
timezone(e) {
if (e) {
this.#e = this.#e.tz(e);
return this;
} else {
return this.#e.tz();
}
}
milliseconds(e) {
return e !== undefined ? this.updateTimestamp(this.#e.milliseconds(e).valueOf()) : this.#e.milliseconds();
}
seconds(e) {
return e !== undefined ? this.updateTimestamp(this.#e.seconds(e).valueOf()) : this.#e.seconds();
}
minutes(e) {
return e !== undefined ? this.updateTimestamp(this.#e.minutes(e).valueOf()) : this.#e.minutes();
}
hours(e) {
return e !== undefined ? this.updateTimestamp(this.#e.hours(e).valueOf()) : this.#e.hours();
}
date(e) {
return e !== undefined ? this.updateTimestamp(this.#e.date(e).valueOf()) : this.#e.date();
}
weekday(e) {
return e !== undefined ? this.updateTimestamp(this.#e.weekday(e).valueOf()) : this.#e.weekday();
}
isoWeekday(e) {
return e !== undefined ? this.updateTimestamp(this.#e.isoWeekday(e).valueOf()) : this.#e.isoWeekday();
}
dayOfYear(e) {
return e !== undefined ? this.updateTimestamp(this.#e.dayOfYear(e).valueOf()) : this.#e.dayOfYear();
}
weeks(e) {
return e !== undefined ? this.updateTimestamp(this.#e.weeks(e).valueOf()) : this.#e.weeks();
}
isoWeeks(e) {
return e !== undefined ? this.updateTimestamp(this.#e.isoWeeks(e).valueOf()) : this.#e.isoWeeks();
}
month(e) {
return e !== undefined ? this.updateTimestamp(this.#e.month(e).valueOf()) : this.#e.month();
}
quarters(e) {
return e !== undefined ? this.updateTimestamp(this.#e.quarters(e).valueOf()) : this.#e.quarters();
}
year(e) {
return e !== undefined ? this.updateTimestamp(this.#e.year(e).valueOf()) : this.#e.year();
}
isoWeekYear(e) {
return e !== undefined ? this.updateTimestamp(this.#e.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.updateTimestamp(this.#e.set(e, t).valueOf());
}
add(e, t) {
return this.updateTimestamp(this.#e.add(e, t).valueOf());
}
subtract(e, t) {
return this.updateTimestamp(this.#e.subtract(e, t).valueOf());
}
startOf(e) {
return this.updateTimestamp(this.#e.startOf(e).valueOf());
}
endOf(e) {
return this.updateTimestamp(this.#e.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;