INNER CODE UNIT · Python

_uses_24h

GHJJ123/brainrotguard · i18n/__init__.py:102

def _uses_24h(locale: str | None, time_format: str | None) -> bool:
    """Decide whether to render times in 24-hour format."""
    normalized_format = normalize_time_format(time_format)
    if normalized_format == "24h":
        return True
    if normalized_format == "12h":
        return False
    return normalize_locale(locale) == "nb"


def format_time(hhmm: str | None, locale: str | None, time_format: str | None = None) -> str | None:
    """Locale-aware time formatting with optional explicit time format."""
    if hhmm is None:
        return None
    try:
        hour, minute = map(int, hhmm.split(":"))
    except (ValueError, AttributeError):
        return hhmm

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…