Skip to content

Commit

Permalink
Merge pull request #113 from filips123/fix-menu-date-regex
Browse files Browse the repository at this point in the history
Fix menu date regex with new format
  • Loading branch information
filips123 authored Nov 1, 2024
2 parents 9fe734f + 776e05e commit 374c5cc
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion API/gimvicurnik/updaters/menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,15 @@ def get_document_title(self, document: DocumentInfo) -> str:
def get_document_effective(self, document: DocumentInfo) -> datetime.date:
"""Return the document effective date in a local timezone from the URL."""

# Example URL formats (with variations):
# jedilnik-kosilo-YYYY-MM-DD(-popravek).pdf
# jedilnik-malica-YYYY-MM-DD(-popravek).pdf
# 01-splet-K-YYYY-MM-DD(-popravek).pdf
# 01-splet-M-YYYY-MM-DD(-popravek).pdf

date = re.search(
r"jedilnik-(?:kosilo|malica|K|M)-(\d+)-(\d+)-(\d+)(?:-[\w-]*)?\.(?:pdf|xlsx)", document.url
r"(?:jedilnik|\d+-splet)-(?:kosilo|malica|K|M)-(\d+)-(\d+)-(\d+)(?:-[\w-]*)?\.(?:pdf|xlsx)",
document.url,
)

# The specified date is commonly Monday of the effective week
Expand Down

0 comments on commit 374c5cc

Please sign in to comment.