Skip to content

Commit

Permalink
Fix tz-localize when DST-ambiguous
Browse files Browse the repository at this point in the history
  • Loading branch information
ValueRaider committed Oct 21, 2022
1 parent b27cc0c commit f1ad8f0
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion yfinance/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,9 @@ def history(self, period="1mo", interval="1d",
elif params["interval"] == "1h":
pass
else:
df.index = _pd.to_datetime(df.index.date).tz_localize(tz_exchange)
# If a midnight is during DST transition hour when clocks roll back,
# meaning clock hits midnight twice, then use the 2nd (ambiguous=True)
df.index = _pd.to_datetime(df.index.date).tz_localize(tz_exchange, ambiguous=True)
df.index.name = "Date"

# duplicates and missing rows cleanup
Expand Down

0 comments on commit f1ad8f0

Please sign in to comment.