Skip to content

Commit 40415fd

Browse files
committed
simplify tz handling
1 parent 880646c commit 40415fd

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

pvlib/iotools/merra2.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,10 @@ def get_merra2(latitude, longitude, start, end, username, password, dataset,
8484

8585
def _to_utc_dt_notz(dt):
8686
dt = pd.to_datetime(dt)
87-
if dt.tzinfo is None: # convert everything to UTC
88-
dt = dt.tz_localize("UTC")
89-
else:
90-
dt = dt.tz_convert("UTC")
91-
return dt.tz_localize(None) # drop tz so that isoformat() is clean
87+
if dt.tzinfo is not None:
88+
# convert to utc, then drop tz so that isoformat() is clean
89+
dt = dt.tz_convert("UTC").tz_localize(None)
90+
return dt
9291

9392
start = _to_utc_dt_notz(start)
9493
end = _to_utc_dt_notz(end)

0 commit comments

Comments
 (0)