INNER CODE UNIT · Python

normalize_time_format

GHJJ123/brainrotguard · i18n/__init__.py:42

def normalize_time_format(value: str | None) -> str:
    """Normalize configured time format to a supported value."""
    if not value:
        return DEFAULT_TIME_FORMAT
    normalized = value.strip().lower().replace("_", "").replace("-", "")
    if normalized in ("locale", "default", "auto"):
        return "locale"
    if normalized in ("12h", "12hr", "12hour", "ampm"):
        return "12h"
    if normalized in ("24h", "24hr", "24hour"):
        return "24h"
    return DEFAULT_TIME_FORMAT


def get_time_format(config) -> str:
    """Extract normalized time format from config."""
    app = getattr(config, "app", None)
    return normalize_time_format(getattr(app, "time_format", DEFAULT_TIME_FORMAT))

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…