Taragolis commented on code in PR #34744:
URL: https://github.com/apache/airflow/pull/34744#discussion_r1369303186


##########
airflow/utils/timezone.py:
##########
@@ -18,14 +18,20 @@
 from __future__ import annotations
 
 import datetime as dt
+from functools import lru_cache
 from typing import overload
 
 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")
+# UTC time zone as a FixedTimezone instance (subclass of tzinfo)
+# This type uses for compatibility with type provided by pendulum 2.x
+# - in pendulum 2.x ``pendulum.tz.timezone`` returns FixedTimezone
+# - in pendulum 3.x ``pendulum.timezone`` returns Timezone
+utc = FixedTimezone(offset=0, name="UTC")

Review Comment:
   @bolkedebruin 
   Well as we could see on our CI `Timezone("UTC")` in pendulum 2.x might not 
work into some specific cases such 
   
   
https://github.com/apache/airflow/blob/562357528d85a1d1a3054b2f7b88511e1c5337f4/airflow/example_dags/plugins/workday.py#L51-L52
   
   This code works fine in pendulum 3, however it failed (or spawn a lot of 
warnings) in 2.1.2
   
   ```python
   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}")
   ``` 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to