from __future__ import annotations

import pandas as pd

from web_core.time_display import format_timestamp, normalize_display_timezone


def test_normalize_display_timezone_defaults_to_central() -> None:
    assert normalize_display_timezone("bad-zone") == "America/Chicago"


def test_format_timestamp_converts_utc_to_central() -> None:
    stamp = pd.Timestamp("2026-02-17 19:00:00", tz="UTC")
    out = format_timestamp(stamp, display_timezone="America/Chicago", use_24h_time=True)
    assert out.endswith("CST")
    assert "2026-02-17 13:00" in out


def test_format_timestamp_12h_mode_uses_am_pm() -> None:
    stamp = pd.Timestamp("2026-02-17 19:00:00", tz="UTC")
    out = format_timestamp(stamp, display_timezone="America/Chicago", use_24h_time=False)
    assert out.endswith("PM CST")
    assert "2026-02-17 1:00" in out


def test_format_timestamp_returns_na_for_bad_value() -> None:
    assert format_timestamp("not-a-timestamp", display_timezone="America/Chicago", use_24h_time=False) == "n/a"
