velt/time
import { DateTime, Duration, delay, Ticker } from "velt/time". Time:
DateTimeandDuration: a UTC-first instant (JavaScript'sDatewithout its local-time pitfalls; months are 1-12) and a signed span with millisecond precision, with parsing, formatting and calendar fields (DateParts);DateTimeError.- Timers:
setTimeout,setInterval,setImmediateand theirclear…functions (also globals, as in Node) returning aTimer;delay(ms);Ticker, a drift-free periodic schedule tofor awaitover, stopped from any task with aTickerStop.
ts
import { DateTime, Duration, delay } from "velt/time";
const start = DateTime.now();
await delay(20);
const took = DateTime.now().since(start);
console.log(took.compareTo(Duration.ofMs(20)) >= 0); // true
console.log(DateTime.utc(2024, 2, 29).format("ddd D MMM YYYY")); // Thu 29 Feb 2024