Larkspur Physio closes for staff training on Tuesday, November 3. That closure is a calendar day. Fiona’s appointment is a moment on that day, at eleven in London. Treating both as Date objects let the laptop’s time zone change which day looked closed.
You can give those two kinds of information different types. Temporal, JavaScript’s modern date and time API, has separate types for calendar dates, zoned appointments, and timestamps. It’s a global in Node 26, so you don’t import it. Recent browsers support it too, though older runtimes may not.
Match the Type to the Information
You already follow this approach with Python’s datetime module. You use a date for a closure and an aware datetime for an appointment. Temporal makes similar distinctions, with a type for each kind of information:
| What you know in Python | Temporal type |
|---|---|
A date |
Temporal.PlainDate |
A time without a time zone |
Temporal.PlainTime |
A naive datetime |
Temporal.PlainDateTime |
An aware datetime with a ZoneInfo |
Temporal.ZonedDateTime |
| A UTC timestamp | Temporal.Instant |
An amount expressed with timedelta |
Temporal.Duration |
The last row is an analogy: unlike timedelta, a Duration can keep calendar units such as months and years. It also distinguishes a calendar day from twenty-four elapsed hours when clocks change. The later reminder and duration lessons put those differences to work.
The type says what the value knows. A PlainDate has no time or time zone, so it can’t shift to the previous evening on Callum’s New York laptop. A PlainDateTime also has no time zone, so a naive appointment time can’t tell you when to join the call in New York. Use a ZonedDateTime for the clinic’s appointments.
Temporal values are immutable, as Python’s dates and datetimes are. An operation that produces another value leaves the original alone. Month numbers also start at one, as they do in Python. In contrast, the month argument in new Date() is zero-based.