-
Notifications
You must be signed in to change notification settings - Fork 16.4k
Make core compatible with pendulum 3
#34744
New issue
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -23,9 +23,15 @@ | |||||
| import pendulum | ||||||
| from dateutil.relativedelta import relativedelta | ||||||
| from pendulum.datetime import DateTime | ||||||
| from pendulum.tz import fixed_timezone | ||||||
| from pendulum.tz.timezone import FixedTimezone, Timezone | ||||||
|
|
||||||
| # UTC time zone as a tzinfo instance. | ||||||
| utc = pendulum.tz.timezone("UTC") | ||||||
| from airflow.compat.functools import cache | ||||||
|
|
||||||
| # UTC time zone as a FixedTimezone instance (subclass of tzinfo) | ||||||
| # This type uses for compatibility with type provided by pendulum 2.x, | ||||||
| # some of the components might not work correctly with `pendulum.tz.timezone.Timezone` in pendulum 2.x | ||||||
| utc = FixedTimezone(offset=0, name="UTC") | ||||||
|
||||||
| else: | |
| holidays = holiday_calendar.holidays(start=next_start, end=next_start).to_pydatetime() |
This code works fine in pendulum 3, however it failed (or spawn a lot of warnings) in 2.1.2
from pendulum.tz.timezone import FixedTimezone, Timezone
from datetime import datetime
from pandas.tseries.holiday import USFederalHolidayCalendar
holiday_calendar = USFederalHolidayCalendar()
for utc in [FixedTimezone(offset=0, name="UTC"), Timezone("UTC")]:
print(f" {utc} {type(utc).__name__} ".center(72, "="))
next_start = datetime(2021, 9, 5, tzinfo=utc)
result = holiday_calendar.holidays(start=next_start, end=next_start)
print(f"Result: {next_start}")There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And revert it back to FixedTimezone
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and what about using
from datetime import timezone
utc = timezone.utcThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to check this one, some of the methods pendulum 2 have a problem with non-pendulum's timezones, e.g. ZoneInfo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
then leave it for now, we can switch later
Uh oh!
There was an error while loading. Please reload this page.