We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Based on my question:
import datetime from zoneinfo import ZoneInfo import pandas_market_calendars as mcal nyse = mcal.get_calendar("NYSE") def local2utc(date, time): return datetime.datetime.combine(date,time).astimezone(datetime.timezone.utc) for mon in [1,6]: date = datetime.datetime(2024,mon,1) time0 = nyse.open_time_on(date) print(f"date={date}; time={time0}; tz={time0.tzinfo!r}") print(f"bad UTC ={local2utc(date,time0)}") time1 = time0.replace(tzinfo=ZoneInfo(time0.tzname())) print(f"good UTC={local2utc(date,time1)}")
prints
date=2024-01-01 00:00:00; time=09:30:00; tz=<DstTzInfo 'America/New_York' LMT-1 day, 19:04:00 STD> bad UTC =2024-01-01 14:26:00+00:00 good UTC=2024-01-01 14:30:00+00:00 date=2024-06-01 00:00:00; time=09:30:00; tz=<DstTzInfo 'America/New_York' LMT-1 day, 19:04:00 STD> bad UTC =2024-06-01 14:26:00+00:00 good UTC=2024-06-01 13:30:00+00:00
You can see that local2utc works for stock zoneinfo.ZoneInfo but not for your DstTzInfo on two counts:
local2utc
zoneinfo.ZoneInfo
DstTzInfo
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Based on my question:
prints
You can see that
local2utc
works for stockzoneinfo.ZoneInfo
but not for yourDstTzInfo
on two counts:The text was updated successfully, but these errors were encountered: