486e1288bf
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
15 lines
544 B
Python
15 lines
544 B
Python
"""Shared Pydantic types for datetimes (#42): UTC in the DB, explicit +00:00 on the wire."""
|
|
from datetime import datetime
|
|
from typing import Annotated, Optional
|
|
|
|
from pydantic import AfterValidator, PlainSerializer
|
|
|
|
from src.backend.utils.tempo import as_utc_naive, to_utc_aware
|
|
|
|
UtcDateTime = Annotated[
|
|
datetime, PlainSerializer(lambda v: to_utc_aware(v).isoformat(), return_type=str)
|
|
]
|
|
|
|
# Input: aware values are converted to UTC naive, naive is taken as UTC.
|
|
UtcNaiveInput = Annotated[Optional[datetime], AfterValidator(as_utc_naive)]
|