@everwhen/temporal
Version:
_description_
46 lines (45 loc) • 1.32 kB
JavaScript
import { Temporal } from 'temporal-polyfill';
import { Duration } from "./duration.js";
import { max, min } from "./fn/index.js";
export class PlainTime extends Temporal.PlainTime {
static now() {
return PlainTime.from(Temporal.Now.plainTimeISO());
}
static from(...args) {
const time = Temporal.PlainTime.from(...args);
return new PlainTime(time.hour, time.minute, time.second, time.millisecond, time.microsecond, time.nanosecond);
}
static max(...dates) {
return max(...dates);
}
static min(...dates) {
return min(...dates);
}
compare(other) {
return PlainTime.compare(this, other);
}
isBefore(other) {
return PlainTime.compare(this, other) === -1;
}
isAfter(other) {
return PlainTime.compare(this, other) === 1;
}
add(...args) {
return PlainTime.from(super.add(...args));
}
subtract(...args) {
return PlainTime.from(super.subtract(...args));
}
round(...args) {
return PlainTime.from(super.round(...args));
}
until(...args) {
return Duration.from(super.until(...args));
}
since(...args) {
return Duration.from(super.since(...args));
}
with(...args) {
return PlainTime.from(super.with(...args));
}
}