Skip to content

Commit

Permalink
address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
dougiesquire committed Sep 28, 2023
1 parent cc62671 commit 4024c97
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/access_nri_intake/source/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ def _add_month_start(time, n):

def _add_year_start(time, n):
"""Add years to cftime datetime and truncate to start"""
return time.replace(year=time.year + n, month=1, day=1, hour=0, minute=0, second=0)
return time.replace(
year=time.year + n, month=1, day=1, hour=0, minute=0, second=0, microsecond=0
)


def _guess_start_end_dates(ts, te, frequency):
Expand Down Expand Up @@ -81,8 +83,9 @@ def _todate(t):
start_date = "none"
end_date = "none"
frequency = "fx"
has_time = time_dim in ds

if time_dim in ds:
if has_time:
time_var = ds[time_dim]

if len(time_var) == 0:
Expand Down Expand Up @@ -131,7 +134,7 @@ def _todate(t):
frequency = filename_frequency
warnings.warn(f"{msg} Using '{frequency}'.")

if frequency != "fx":
if has_time & (frequency != "fx"):
if not has_bounds:
ts, te = _guess_start_end_dates(ts, te, frequency)
start_date = ts.strftime(time_format)
Expand Down

0 comments on commit 4024c97

Please sign in to comment.