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


##########
airflow/serialization/serializers/datetime.py:
##########
@@ -44,7 +44,7 @@ def serialize(o: object) -> tuple[U, str, int, bool]:
         if is_naive(o):
             o = convert_to_utc(o)
 
-        tz = o.tzname()
+        tz = o.tzinfo.name  # type: ignore

Review Comment:
   Hmmmmmm
   
   ```python
   from datetime import datetime, timezone, timedelta
   
   import pendulum
   from zoneinfo import ZoneInfo
   from pytz import timezone as pytz_tz
   
   
   for tz_type, dt in {
       "pendulum": datetime.now(tz=pendulum.tz.timezone("America/New_York")),
       "zoneinfo": datetime.now(tz=ZoneInfo("America/Los_Angeles")),
       "pytz": datetime.now(tz=pytz_tz("Europe/London")),
       "datetime.timezone.utc": datetime.now(tz=timezone.utc),
       "datetime.timezone unnamed": 
datetime.now(tz=timezone(timedelta(hours=4))),
       "datetime.timezone": datetime.now(tz=timezone(timedelta(hours=4), 
name="FooBar")),
   }.items():
       print(f" {tz_type} ".center(110, "="))
       try:
           print(dt, dt.tzinfo.name)
       except Exception as e:
           print(dt, str(e))
   ```
   
   ```console
   ================================================== pendulum 
==================================================
   2023-09-19 18:17:42.185971-04:00 America/New_York
   ================================================== zoneinfo 
==================================================
   2023-09-19 15:17:42.186350-07:00 'zoneinfo.ZoneInfo' object has no attribute 
'name'
   ==================================================== pytz 
====================================================
   2023-09-19 23:17:42.201468+01:00 'Europe/London' object has no attribute 
'name'
   =========================================== datetime.timezone.utc 
============================================
   2023-09-19 22:17:42.201476+00:00 'datetime.timezone' object has no attribute 
'name'
   ========================================= datetime.timezone unnamed 
==========================================
   2023-09-20 02:17:42.201478+04:00 'datetime.timezone' object has no attribute 
'name'
   ============================================= datetime.timezone 
==============================================
   2023-09-20 02:17:42.201480+04:00 'datetime.timezone' object has no attribute 
'name'
   ```



-- 
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