Skip to content

Commit

Permalink
make manual entries 0ver again, fix isoparse Z handling, and refresh …
Browse files Browse the repository at this point in the history
…data
  • Loading branch information
mahmoud committed Jan 2, 2025
1 parent 50ed83e commit a025a3c
Show file tree
Hide file tree
Showing 3 changed files with 1,530 additions and 1,167 deletions.
17 changes: 12 additions & 5 deletions custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@

NA_VAL = "---"

def isoparse(s):
return datetime.datetime.fromisoformat(s.rstrip("Z"))


def chert_post_load(chert_obj):
# https://github.com/mahmoud/chert/blob/b4a91b5a66ec5f5002d6e67a2f880709e2e11326/chert/core.py#L840
Expand Down Expand Up @@ -77,10 +80,10 @@ def _zv_to_htmltable(entries):
]

def _get_row(entry):
irel_dt = datetime.datetime.fromisoformat(entry["first_release_date"])
irel_dt = isoparse(entry["first_release_date"])
lrel_dt, zv_streak = None, None
if entry.get("latest_release_date"):
lrel_dt = datetime.datetime.fromisoformat(entry["latest_release_date"])
lrel_dt = isoparse(entry["latest_release_date"])
zv_streak = datetime.datetime.now() - irel_dt.replace(tzinfo=None)
zv_streak_years = round(zv_streak.days / 365.0, 1)

Expand Down Expand Up @@ -142,10 +145,14 @@ def _emeritus_to_htmltable(entries):

rows = []
for entry in entries:
irel_dt = datetime.datetime.fromisoformat(entry["first_release_date"])
irel_dt = isoparse(entry["first_release_date"])
lrel_dt, zv_streak = None, None
if entry.get("first_nonzv_release_date"):
lrel_dt = datetime.datetime.fromisoformat(entry["first_nonzv_release_date"])
lrel_entry = entry.get("first_nonzv_release_date")
if lrel_entry:
lrel_dt = isoparse(lrel_entry)
else:
lrel_dt = datetime.datetime.now()

zv_streak = lrel_dt.replace(tzinfo=None) - irel_dt.replace(tzinfo=None)
zv_streak_years = round(zv_streak.days / 365.0, 1)

Expand Down
Loading

0 comments on commit a025a3c

Please sign in to comment.