diff --git a/agenda/thespacedevs.py b/agenda/thespacedevs.py index f6107a2..b7260a8 100644 --- a/agenda/thespacedevs.py +++ b/agenda/thespacedevs.py @@ -40,28 +40,27 @@ def format_time(time_str: str, net_precision: str) -> tuple[str, str | None]: include_time = False # Format the date based on precision - time_format: str | None = None + time_format: str | None field2 = None - if net_precision == "Year": - time_format = "%Y" - if net_precision == "Month": - time_format = "%b %Y" - if net_precision == "Week": - time_format = "%d %b %Y" - field2 = "(Week of)" - if net_precision == "Day": - time_format = "%d %b %Y" - if net_precision == "Hour": - time_format = "%d %b %Y" - include_time = True - if net_precision == "Minute": - time_format = "%d %b %Y" - include_time = True - elif net_precision == "Second": - time_format = "%d %b %Y" - include_time = True - elif net_precision.startswith("Quarter "): - time_format = f"Q{net_precision[-1]} %Y" + + match net_precision: + case "Year": + time_format = "%Y" + case "Month": + time_format = "%b %Y" + case "Week": + time_format = "%d %b %Y" + field2 = "(Week of)" + case "Day" | "Hour" | "Minute": + time_format = "%d %b %Y" + include_time = net_precision in {"Hour", "Minute"} + case "Second": + time_format = "%d %b %Y" + include_time = True + case _ if net_precision.startswith("Quarter "): + time_format = f"Q{net_precision[-1]} %Y" + case _: + time_format = None if not time_format: return (repr(time_str), repr(net_precision))