# `OpeningHours`

When a place is open each week, and the days that differ.

Use it for a shop's or a clinic's hours. `temporal.open_at` tells you whether it is open at an instant. For repeating calendar events, use [`RecurrenceRule`](/docs/types/type-recurrence-rule.md).

## Shape

One value, held as text in one set form, with no parts: `Mo-Th 17:00-23:00; Fr,Sa 17:00-02:00; 2026 Dec 25 off [America/New_York]`.

## Example

```jadpo
OpeningHours("Mo-Fr 09:00-17:30; Sa 10:00-16:00 [Europe/London]")
```

`OpeningHours(raw)` checks the text, and text that isn't one breaks the `format` rule.

`text.parse(raw, as: OpeningHours)` reads one from text that comes from outside. Text that isn't one at all fails `malformed`, such as `Mo-Fr 09:00-17:30`, `Mo-Fr 9:00-17:30 [Europe/London]` or `Mo-Fr 09:00-25:00 [Europe/London]`.

## Good to know

- It uses OpenStreetMap's form and ends with its zone in brackets. Times need two digits, so `9:00` is refused.
- `==` tells you whether two are the same. `<` and `list.sort_by` don't take it.

## In JSON

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

```json
"Mo-Fr 09:00-17:30; Sa 10:00-16:00 [Europe/London]"
"Mo-Th 17:00-23:00; Fr,Sa 17:00-02:00; 2026 Dec 25 off [America/New_York]"
```

## Details

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

`OpeningHours` 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: `Mo-Fr 09:00-17:30; Sa 10:00-16:00 [Europe/London]` and `Mo-Th 17:00-23:00; Fr,Sa 17:00-02:00; 2026 Dec 25 off [America/New_York]`.

### How it is stored

It is stored in one column named for the field, of type `text`. `Mo-Th 17:00-23:00; Fr,Sa 17:00-02:00; 2026 Dec 25 off [America/New_York]` is stored as `'Mo-Th 17:00-23:00; Fr,Sa 17:00-02:00; 2026 Dec 25 off [America/New_York]'`.

### How it is shown to people

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

With `locale: Locale.en_gb`:

| Value | Shown |
|---|---|
| `Mo-Fr 09:00-17:30; Sa 10:00-16:00 [Europe/London]` | `Mo-Fr 09:00-17:30; Sa 10:00-16:00 [Europe/London]` |
| `Mo-Th 17:00-23:00; Fr,Sa 17:00-02:00; 2026 Dec 25 off [America/New_York]` | `Mo-Th 17:00-23:00; Fr,Sa 17:00-02:00; 2026 Dec 25 off [America/New_York]` |

### Operations

- `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>
