Nakodo counts most of its limits by UTC day, and one of them by Pacific day, because that is the day the YouTube Data API's quota resets on. src/lib/time.ts is 69 lines and holds both ideas, with a comment at the top that is the whole design:
// Durations and day boundaries, in one place. Limits count by UTC day unless // a source says otherwise (YouTube's quota day is Pacific); billing periods // are months from the subscription's start.
Enter fullscreen mode
Exit fullscreen mode
The UTC half is unremarkable and heavily used: DAY_MS appears at 82 sites, daysAgo() at 11, nextUtcMidnight() at 11, startOfUtcDay() at 10. The zone-aware half has exactly two functions and, today, exactly one caller.
Finding midnight in a zone you do not control
There is no date library here. The only tool is Intl.DateTimeFormat , which can tell you what the wall clock in a zone reads at a given instant:
// Milliseconds since midnight on the wall clock in `timeZone`.…