Hello
i am trying to get dates from a pdf with ha-pdf from github. i have the regex working and now trying to make a template to get dates and show me the next date
{% set today = now().date() %}
{% set month_map = {
'jan': 'Jan', 'feb': 'Feb', 'mar': 'Mar', 'apr': 'Apr',
'maj': 'May', 'jun': 'Jun', 'jul': 'Jul', 'aug': 'Aug',
'sep': 'Sep', 'okt': 'Oct', 'nov': 'Nov', 'dec': 'Dec'
} %}
{% set dates = ['21 jan 2025', '04 feb 2025', '18 feb 2025', '04 mar 2025', '18 mar 2025', '01 apr 2025', '15 apr 2025', '29 apr 2025', '13 maj 2025', '27 maj 2025', '10 jun 2025', '24 jun 2025', '08 jul 2025', '22 jul 2025', '05 aug 2025'] %}
{% set next_date = none %}
{% for date_str in dates %}
{% set parts = date_str.split(' ') %}
{% set day = parts[0] %}
{% set month = month_map[parts[1] | lower] %}
{% set year = parts[2] %}
{% set match_date = strptime(day + ' ' + month + ' ' + year, '%d %b %Y').date() %}
{% if match_date > today and next_date is none %}
{% set next_date = match_date %}
{% endif %}
{% endfor %}
{% if next_date %}
Next match date: {{ next_date }}
{% else %}
No future dates found
{% endif %}
Here is the code i am trying, and it gives me “No future dates found”
Does anyone have and idea?