Skip to content

Commit 49b4fe7

Browse files
authored
Default EOL to end of month in SVG (#1672)
1 parent 024490c commit 49b4fe7

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

_tools/generate_release_cycle.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from __future__ import annotations
44

55
import argparse
6+
import calendar
67
import csv
78
import datetime as dt
89
import json
@@ -18,10 +19,17 @@ def csv_date(date_str: str, now_str: str) -> str:
1819
return date_str
1920

2021

21-
def parse_date(date_str: str) -> dt.date:
22+
def parse_date(date_str: str, *, last: bool = False) -> dt.date:
2223
if len(date_str) == len("yyyy-mm"):
2324
# We need a full yyyy-mm-dd, so let's approximate
24-
return dt.date.fromisoformat(date_str + "-01")
25+
if last:
26+
# Last day of month
27+
year, month = map(int, date_str.split("-"))
28+
last_day = calendar.monthrange(year, month)[1]
29+
return dt.date(year, month, last_day)
30+
else:
31+
return dt.date.fromisoformat(date_str + "-01")
32+
2533
return dt.date.fromisoformat(date_str)
2634

2735

@@ -46,7 +54,7 @@ def __init__(self, *, limit_to_active=False, special_py27=False) -> None:
4654
full_years = 1.5
4755
version["first_release_date"] = r1 = parse_date(version["first_release"])
4856
version["start_security_date"] = r1 + dt.timedelta(days=full_years * 365)
49-
version["end_of_life_date"] = parse_date(version["end_of_life"])
57+
version["end_of_life_date"] = parse_date(version["end_of_life"], last=True)
5058

5159
self.cutoff = min(ver["first_release_date"] for ver in self.versions.values())
5260

0 commit comments

Comments
 (0)