# orca.key

> A module of Orca's API.

`Key`: what a partition key is, whatever it counts.

A key is written as text (`2024-01`, `2024-01-31`, `log-0f3a`), read back
by `parse`, and ordered, for sorting and display. `Month` and `Day` are
`TimeKey`s too: each has a next and a previous key, and the key a date
falls in, which ranges, schedules' fills and sensors' day-to-month mapping
need. `Name` (`orca.name`) is a key that isn't a date, so asking it for its
next key doesn't compile. `parse_keys` reads the ranges and lists the
command line takes for time keys.

## Traits

### `Key`

```mojo
undefined
```

Implements: `Copyable`, `Equatable`, `Movable`, `Writable`

#### `__lt__`

```mojo
def __lt__(self, other: Self) -> Bool
```

#### `parse`

```mojo
def parse(s: StringSpan) -> Self
```

Reads the key as `write_to` writes it, and nothing else.

### `TimeKey`

```mojo
undefined
```

A key that is a span of the calendar.

Implements: `Copyable`, `Equatable`, `Key`, `Movable`, `Writable`

#### `next`

```mojo
def next(self) -> Self
```

The key after this one.

#### `prev`

```mojo
def prev(self) -> Self
```

The key before this one.

#### `containing`

```mojo
def containing(year: Int, month: Int, day: Int) -> Self
```

The key a date falls in.

## Functions

### `parse_keys`

```mojo
def parse_keys[K: TimeKey](s: StringSpan, first: StringSpan = "") -> List[K]
```

Reads a key, `A..B` (both ends included), or a comma-separated list of either, in the order given. A key given twice, or one before `first` (when given), is an error.
