Time Standards¶
Offline lookups against the bundled USA Swimming motivational standards (the 2025–2028
cuts), shipped as JSON inside the package — no setup or network access. USA Swimming revises
the cuts every four years, so refreshing them is just a matter of upgrading tunas.
TimeStandard is an ordered IntEnum from slowest to
fastest — B < BB < A < AA < AAA < AAAA — so a qualifies_for(...) result can be compared
directly (std >= TimeStandard.AA). Each member has a .display() name.
Lookups take an event, an age, and a sex, bucketing the age into single-year groups
(10 & under, 11-12, 13-14, 15-16, 17-18). Standards exist for MALE/FEMALE only —
passing Sex.MIXED raises ValueError. An event/age/sex with no defined cut returns None
(or an empty list).
qualifies_for— the single fastest standard a time meets, orNone.all_qualified— every standard met, ordered slowest first.standard_time— the cutoffTimefor one standard, orNone.
If the bundled data is missing or malformed, lookups raise
StandardsError.
standards
¶
USA Swimming motivational time standards (B through AAAA) bundled offline.
TimeStandard
¶
Bases: IntEnum
USA Swimming motivational standards ordered slowest (B) to fastest (AAAA).
qualifies_for
¶
qualifies_for(
time: Time, event: Event, age: int, sex: Sex
) -> TimeStandard | None
Determine the fastest USA Swimming motivational standard achieved for the given event, age, and sex.
Uses a youngest-first lookup for the swimmer's age group (10 & Under, 11-12, 13-14, 15-16, 17-18).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
time
|
Time
|
The swimmer's time. |
required |
event
|
Event
|
The event. |
required |
age
|
int
|
The swimmer's age in years. |
required |
sex
|
Sex
|
The swimmer's sex (must be MALE or FEMALE). |
required |
Returns:
| Type | Description |
|---|---|
TimeStandard | None
|
The fastest achieved |
TimeStandard | None
|
if the time does not qualify for any motivational standard. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in src/tunas/standards.py
all_qualified
¶
all_qualified(
time: Time, event: Event, age: int, sex: Sex
) -> list[TimeStandard]
Retrieve all USA Swimming motivational standards qualified for by the given time.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
time
|
Time
|
The swimmer's time. |
required |
event
|
Event
|
The event. |
required |
age
|
int
|
The swimmer's age in years. |
required |
sex
|
Sex
|
The swimmer's sex (must be MALE or FEMALE). |
required |
Returns:
| Type | Description |
|---|---|
list[TimeStandard]
|
A list of all qualified |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in src/tunas/standards.py
standard_time
¶
standard_time(
standard: TimeStandard, event: Event, age: int, sex: Sex
) -> Time | None
Get the cutoff time required to achieve a specific motivational standard.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
standard
|
TimeStandard
|
The target motivational standard. |
required |
event
|
Event
|
The event. |
required |
age
|
int
|
The swimmer's age in years. |
required |
sex
|
Sex
|
The swimmer's sex (must be MALE or FEMALE). |
required |
Returns:
| Type | Description |
|---|---|
Time | None
|
The cutoff |
Time | None
|
is undefined for the event/age/sex combination. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |