1"""For when pip wants to check the date or time."""
2
3import datetime
4import sys
5
6
7def today_is_later_than(year: int, month: int, day: int) -> bool:
8 today = datetime.date.today()
9 given = datetime.date(year, month, day)
10
11 return today > given
12
13
14def parse_iso_datetime(isodate: str) -> datetime.datetime:
15 """Convert an ISO format string to a datetime.
16
17 Handles the format 2020-01-22T14:24:01Z (trailing Z)
18 which is not supported by older versions of fromisoformat.
19 """
20 # Python 3.11+ supports Z suffix natively in fromisoformat
21 if sys.version_info >= (3, 11):
22 return datetime.datetime.fromisoformat(isodate)
23 else:
24 return datetime.datetime.fromisoformat(
25 isodate.replace("Z", "+00:00")
26 if isodate.endswith("Z") and ("T" in isodate or " " in isodate.strip())
27 else isodate
28 )