UNPKG

@everwhen/temporal

Version:
47 lines 1.43 kB
import { Temporal } from 'temporal-polyfill'; import { Duration } from './duration.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); } compare(other) { return PlainTime.compare(this, other); } /** * Check if this time is before another time. * @param other The other PlainTime instance to compare. */ isBefore(other) { return PlainTime.compare(this, other) === -1; } /** * Check if this time is after another time. * @param other The other PlainTime instance to compare. */ 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(...args); } } //# sourceMappingURL=plain-time.js.map