INNER CODE UNIT · Python

normalize_release_date

RockxyApp/Rockxy · releases/validate_metadata.py:113

def normalize_release_date(value: Any) -> str:
    raw = str(value or "").strip()
    if not raw:
        return ""
    if re.fullmatch(r"\d{4}-\d{2}-\d{2}", raw):
        return f"{raw}T00:00:00Z"
    candidate = raw.replace("Z", "+00:00")
    try:
        parsed = datetime.fromisoformat(candidate)
    except ValueError:
        fail(f"release_date is not UTC ISO-8601: {raw}")
    if parsed.tzinfo is None:
        fail(f"release_date must include a timezone: {raw}")
    parsed = parsed.astimezone(timezone.utc).replace(microsecond=0)
    return parsed.isoformat().replace("+00:00", "Z")


def validate_utc_release_date(value: Any, label: str) -> str:

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…