# `Instant`

One moment in time, the same everywhere in the world: `2026-10-25T09:30:00Z`.

Use it for when something happened, such as when an order was placed. For a day on a calendar, use [`CalendarDate`](/docs/types/type-calendar-date.md). For a time on someone's clock in a place, use [`ZonedTime`](/docs/types/type-zoned-time.md). For a time with no place yet, use [`LocalDateTime`](/docs/types/type-local-date-time.md).

## Shape

One value, with no fields to fill in. As text it reads `2026-10-25T09:30:00.250Z`.

## Example

```jadpo
Instant("2026-10-25T09:30:00Z")
```

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

This operation gives one: `temporal.instant`.

## Good to know

- It is always in UTC, written with `Z`. An offset such as `+01:00` is refused.
- `clock.now` gives the current one. Adding a [`Duration`](/docs/types/type-duration.md) gives another: `clock.now + 14d`.
- `text.format` needs a zone and a format, since a moment looks different in each place.
- `==` tells you whether two are the same, and `<` and `list.sort_by` compare and sort them.

## In JSON

A string, in a request, a response or `json.write`:

```json
"2026-03-29T00:30:00Z"
"2026-10-25T09:30:00.250Z"
```

## Details

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

`Instant` 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-03-29T00:30:00Z` and `2026-10-25T09:30:00.250Z`.

### How it is stored

It is stored in one column named for the field, of type `timestamptz(3)`. `2026-10-25T09:30:00.250Z` is stored as `'2026-10-25 09:30:00.250000+00'::timestamptz`.

### How it is shown to people

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

With `locale: Locale.en_gb`, `zone: Zone.europe_london` and `format: TimeFormat.date_time_medium`:

| Value | Shown |
|---|---|
| `2026-03-29T00:30:00Z` | `29 Mar 2026, 00:30:00` |
| `2026-10-25T09:30:00.250Z` | `25 Oct 2026, 09:30:00` |

### Operations

- `temporal.between(start: Instant, end: Instant) -> Duration`: How long from `start` to `end`: `end - start`.
- `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.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.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.open_at(hours: OpeningHours, at: Instant) -> Bool`: Whether `hours` are open at `at`, by the clock in their zone.

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>
