# `LocalTime`

A time on the clock, with no date or zone: `09:30:00`.

Use it for a time that repeats, such as a shop opening at 09:30. For one moment, use [`Instant`](/docs/types/type-instant.md).

## Shape

| Field | Type | Required? |
|---|---|---|
| `hour` | `Int` | Yes |
| `minute` | `Int` | Yes |
| `second` | `Int` | Yes |

## Example

```jadpo
LocalTime { hour: 9 minute: 30 second: 0 }
```

`text.parse(raw, as: LocalTime)` reads one from text that comes from outside. Text that isn't one at all fails `malformed`, such as `24:00:00`, `09:30` or `9:30:00`.

## Good to know

- The hour runs from 0 to 23. `24:00:00` is refused, and text needs the seconds, so `09:30` is refused as well.
- `==` 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
"00:00:00"
"09:30:00"
"23:59:59"
```

## Details

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

`LocalTime` 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: `00:00:00`, `09:30:00` and `23:59:59`.

### How it is stored

It is stored in one column named for the field, of type `time`. `09:30:00` is stored as `'09:30:00.000000'::time`.

### 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.time_medium`:

| Value | Shown |
|---|---|
| `00:00:00` | `00:00:00` |
| `09:30:00` | `09:30:00` |
| `23:59:59` | `23:59:59` |

### Operations

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>
