feat: Czech day name format 'Pondělí (20.2)' in canvas + PDF; wider date column
Some checks failed
Build & Push Docker / build (push) Has been cancelled

This commit is contained in:
2026-02-20 17:34:14 +01:00
parent 47add509ca
commit f0e7c3b093
2 changed files with 23 additions and 4 deletions

View File

@@ -45,6 +45,20 @@ def is_light(hex_color: str) -> bool:
return (0.299 * r + 0.587 * g + 0.114 * b) > 0.6
_CS_WEEKDAYS = ['Pondělí', 'Úterý', 'Středa', 'Čtvrtek', 'Pátek', 'Sobota', 'Neděle']
def format_date_cs(date_str: str) -> str:
"""Format date as 'Pondělí (20.2)'."""
from datetime import date as dt_date
try:
d = dt_date.fromisoformat(date_str)
weekday = _CS_WEEKDAYS[d.weekday()]
return f"{weekday} ({d.day}.{d.month})"
except Exception:
return date_str
def time_to_min(s: str) -> int:
parts = s.split(':')
return int(parts[0]) * 60 + int(parts[1])
@@ -153,7 +167,7 @@ def generate_pdf(doc) -> bytes:
FOOTER_H = 10
TIME_AXIS_H = 18
DATE_COL_W = 18 * mm
DATE_COL_W = 28 * mm # wider for Czech day names like "Pondělí (20.2)"
# Available area for the timetable grid
avail_h = PAGE_H - 2 * MARGIN - header_h - LEGEND_H - FOOTER_H - TIME_AXIS_H - 6
@@ -248,7 +262,7 @@ def generate_pdf(doc) -> bytes:
# Date label cell
fill_rect(c, x0, row_y, DATE_COL_W, row_h, AXIS_BG, BORDER, 0.4)
draw_clipped_text(c, date_key, x0, row_y, DATE_COL_W, row_h,
draw_clipped_text(c, format_date_cs(date_key), x0, row_y, DATE_COL_W, row_h,
'Helvetica-Bold', date_font, AXIS_TEXT, 'center')
# Vertical grid lines (15-min slots, hour lines darker)