diff --git a/src/quartermaster/month_service.py b/src/quartermaster/month_service.py index 9ecc0b9..097adb1 100644 --- a/src/quartermaster/month_service.py +++ b/src/quartermaster/month_service.py @@ -83,6 +83,19 @@ def shift_year_month(year_month: str, delta: int) -> str: return f"{new_year:04d}-{new_month0 + 1:02d}" +_MONTH_NAMES = [ + "", "January", "February", "March", "April", "May", "June", + "July", "August", "September", "October", "November", "December", +] + + +def pretty_year_month(year_month: str) -> str: + if not valid_year_month(year_month): + return year_month + year, month = year_month.split("-") + return f"{_MONTH_NAMES[int(month)]} {year}" + + def get_month(db: Session, year_month: str) -> Month | None: stmt = select(Month).where(Month.year_month == year_month) return db.scalar(stmt) diff --git a/src/quartermaster/routes_month.py b/src/quartermaster/routes_month.py index 729dee6..e64fc75 100644 --- a/src/quartermaster/routes_month.py +++ b/src/quartermaster/routes_month.py @@ -131,6 +131,9 @@ def view_month( "month_create.html", { "year_month": year_month, + "pretty_year_month": month_service.pretty_year_month(year_month), + "pretty_prev": month_service.pretty_year_month(prev_ym), + "pretty_next": month_service.pretty_year_month(next_ym), "prev_year_month": prev_ym, "next_year_month": next_ym, "all_months": all_months, @@ -148,6 +151,9 @@ def view_month( { "month": month, "year_month": year_month, + "pretty_year_month": month_service.pretty_year_month(year_month), + "pretty_prev": month_service.pretty_year_month(prev_ym), + "pretty_next": month_service.pretty_year_month(next_ym), "prev_year_month": prev_ym, "next_year_month": next_ym, "all_months": all_months,