Skip to content

Commit

Permalink
Return Nones from *_from_iso tool functions
Browse files Browse the repository at this point in the history
The today/now defaults were leading to buggy and unexpected data so
return None instead.
  • Loading branch information
ghickman committed Nov 14, 2023
1 parent 989113f commit aabf4fe
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions metrics/tools/dates.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
from datetime import date, datetime, timedelta
from datetime import datetime, timedelta


DELTA = timedelta(days=1)


def date_from_iso(value):
if value is None:
return date.today()
return None

return datetime_from_iso(value).date()


def datetime_from_iso(value):
if value is None:
return datetime.now()
return None

return datetime.fromisoformat(value)

Expand Down

0 comments on commit aabf4fe

Please sign in to comment.