Skip to content

Commit

Permalink
fix bug when adjusting start/end of datasets
Browse files Browse the repository at this point in the history
  • Loading branch information
b8raoult committed Jun 1, 2024
1 parent 07a5d69 commit 922a9b3
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/anemoi/datasets/data/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,12 @@ def _frequency_to_hours(frequency):


def _as_date(d, dates, last):
if isinstance(d, np.datetime64):
d = d.astype(datetime.datetime)

if isinstance(d, datetime.datetime):
if not d.minute == 0 and d.hour == 0 and d.second == 0:
return np.datetime64(d)
d = datetime.date(d.year, d.month, d.day)
# WARNING, datetime.datetime is a subclass of datetime.date
# so we need to check for datetime.datetime first

if isinstance(d, (np.datetime64, datetime.datetime)):
return d

if isinstance(d, datetime.date):
d = d.year * 10_000 + d.month * 100 + d.day
Expand Down

0 comments on commit 922a9b3

Please sign in to comment.