# `ZonedTime`

A moment seen on the clock in one place: `2026-10-25T09:30:00+00:00[Europe/London]`.

Use it to do clock and calendar sums in a place, such as "9am the next day in London". To store a moment, use [`Instant`](/docs/types/type-instant.md). `temporal.in_zone` gives a `ZonedTime` from an [`Instant`](/docs/types/type-instant.md).

## Shape

One value, with no fields to fill in. As text it reads `2026-10-25T09:30:00+00:00[Europe/London]`.

## Example

```jadpo
temporal.in_zone(Instant("2026-10-25T09:30:00Z"), Zone.europe_london)
```

`text.parse(raw, as: ZonedTime)` reads one from text that comes from outside. Text that isn't one at all fails `malformed`, such as `2026-10-25T09:30:00Z` or `2026-10-25T09:30:00+00:00`.

These operations give one: `temporal.add_days`, `temporal.add_months`, `temporal.add_years`, `temporal.in_zone`, `temporal.occurrences` and `temporal.resolve`.

## Good to know

- `temporal.add_days` keeps the clock time across a daylight saving change, which adding 24 hours to an [`Instant`](/docs/types/type-instant.md) doesn't.
- `==` tells you whether two are the same. `<` and `list.sort_by` don't take it.

## In JSON

An object of its parts, in a request, a response or `json.write`:

```json
{"instant":"2026-10-25T09:30:00Z","zone":"Europe/London"}
```

## Details

<details>
<summary>Text form, storage, how it is shown, and operations</summary>

`ZonedTime` is in the group Time and calendar, and has been in Jadpo since 0.1.0.

### Text form

`text.from` writes one standard text form, the same form `text.parse` reads back: `2026-10-25T09:30:00+00:00[Europe/London]`.

### How it is stored

It is stored in 2 columns, each named for the field, `_` and its suffix. This is `2026-10-25T09:30:00+00:00[Europe/London]`:

| Column | Type | Holds |
|---|---|---|
| `<field>_instant` | `timestamptz(3)` | `'2026-10-25 09:30:00.000000+00'::timestamptz` |
| `<field>_zone` | `text` | `'Europe/London'` |

### How it is shown to people

`text.format(value, locale:)` shows it to people in their locale. A call also gives `format:`.

With `locale: Locale.en_gb` and `format: TimeFormat.date_time_medium`:

| Value | Shown |
|---|---|
| `2026-10-25T09:30:00+00:00[Europe/London]` | `25 Oct 2026, 09:30:00` |

### Operations

- `temporal.add_days(value: T, days: Int, dst: Dst?) -> T`: `value` moved by whole calendar days, the clock time kept.
- `temporal.add_months(value: T, months: Int, invalid_day: InvalidDay?, dst: Dst?) -> T`: `value` moved by whole calendar months, the day and clock time kept.
- `temporal.add_years(value: T, years: Int, invalid_day: InvalidDay?, dst: Dst?) -> T`: `value` moved by whole calendar years, the day and clock time kept.
- `temporal.date(value: ZonedTime) -> CalendarDate`: A local time's date.
- `temporal.day(value: T) -> Int`: The day of the month, from 1.
- `temporal.format_relative(value: T, now: Instant, zone: Zone?, locale: Locale) -> PresentationText`: `value` shown to a person in `locale` as how long ago it was from `now`: "just now", minutes, "Today at", "Yesterday at", the weekday, then the long date.
- `temporal.hour(value: ZonedTime) -> Int`: A local time's hour, from 0 to 23.
- `temporal.in_zone(instant: Instant, zone: Zone) -> ZonedTime`: `instant` as the local time in `zone`.
- `temporal.instant(value: ZonedTime) -> Instant`: The instant a local time is.
- `temporal.minute(value: ZonedTime) -> Int`: A local time's minute, from 0 to 59.
- `temporal.month(value: T) -> Int`: The month, from 1 for January.
- `temporal.occurrences(rule: RecurrenceRule, from: T, count: Int) -> List<ZonedTime>`: The next `count` occurrences of `rule` at or after `from`, in its zone (RFC 5545): fewer when the rule ends first; `count` is from 1 to 1000, so an unbounded rule is never expanded without a bound. From a date, the days they fall on, `List<CalendarDate>`, which a rule on dates gives; from an `Instant`, a timed rule's local times.
- `temporal.resolve(date: T, at: Text?, zone: Zone, dst: Dst?) -> ZonedTime`: The instant the clock reads `at` on `date` in `zone`, or a `LocalDateTime` given as `date` reads with no `at:`; `dst:` chooses one in a daylight-saving gap or overlap.
- `temporal.weekday(value: T) -> Weekday`: The day of the week.
- `temporal.year(value: T) -> Int`: The year of a date or of a local time's date.
- `temporal.zone(value: ZonedTime) -> Zone`: The zone a local time is seen in.

It also takes `text.parse`, `text.from`, `text.format`, `json.read`, `json.write` and `==`. [How every standard type behaves](/docs/every-standard-type-meets-one-contract.md) says how they work.

</details>
