Skip to content

Commit

Permalink
Fix dates as strings
Browse files Browse the repository at this point in the history
  • Loading branch information
b8raoult committed Mar 21, 2024
1 parent b3bee2a commit 0ae4902
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions ecml_tools/data/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,13 @@ def _as_date(d, dates, last):
return np.datetime64(f"{year:04}-{month:02}-{day:02}T00:00:00")

if isinstance(d, str):

if "-" in d and ":" in d:
date, time = d.replace(" ", "T").split("T")
year, month, day = date.split("-")
hour, minute, second = time.split(":")
return np.datetime64(f"{year:04}-{month:02}-{day:02}T{hour}:{minute}:{second}")

if "-" in d:
assert ":" not in d
bits = d.split("-")
Expand Down

0 comments on commit 0ae4902

Please sign in to comment.