Skip to content

Commit

Permalink
Fix ValueError: day is out of range for month (#55)
Browse files Browse the repository at this point in the history
Fixes #54
  • Loading branch information
TheFes authored May 30, 2024
1 parent 54bc7ee commit 8a0a7d4
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion relative_time_plus.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -313,11 +313,15 @@
{%- if check_mth -%}
{#- set numer of months, and set highest date using this number of months #}
{%- set ns = namespace(dm=date_max, mth=0) -%}
{%- set dmd = ns.dm.day -%}
{%- for m in range(1, 12) -%}
{%- set dmm, dmy = ns.dm.month, ns.dm.year -%}
{%- set day_max = (ns.dm.replace(day=1) - timedelta(days=1)).day -%}
{%- set dm = ns.dm.replace(
month=12 if dmm == 1 else dmm - 1,
year=dmy - 1 if dmm == 1 else dmy)
year=dmy - 1 if dmm == 1 else dmy,
day= [dmd, day_max] | min
)
-%}
{%- if dm < date_min -%}
{%- break -%}
Expand Down

0 comments on commit 8a0a7d4

Please sign in to comment.