You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2021/07/02 06:37:28 UTC

[GitHub] [airflow] ecerulm commented on pull request #16678: Serialize dag timezone to a tzname or offset

ecerulm commented on pull request #16678:
URL: https://github.com/apache/airflow/pull/16678#issuecomment-872756457


   > Oh, do we actually need it to be a pendulum.TZ, or do we already "support" that and the build in dt.zoneinfo?
   
   There is no guarantee that he zoneinfo tzname() will return something that can be fed to `pendulum.timezone(xx)` 
   
   ```
   from zoneinfo import ZoneInfo
   from datetime import datetime,timedelta
   import pendulum
   dt = datetime(2020, 10, 31, 12, tzinfo=ZoneInfo("America/Los_Angeles"))
   print(dt.tzname()) # PDT
   pendulum.timezone(dt.tzname()) # InvalidTimezone "PDT"
   ```
   
   So for example `ZoneInfo("America/Los_Angeles")` will be interpreted as an integer offset in the current status of this PR. 
   
   If we wanted to support `ZoneInfo` too we would need to check for `.key` attribute too (in addition to `.name`) and hopefully they both have the same IANA names supported so `pendulum.timezone(zinfoobj.key)` will provide an equivalent pendulum timezone to the specified zoneinfo. 
   
   But it's not better to just say that it has to be a pendulum timezone, since at the end at deserializaiton time it will be reconstructed as a pendulum? 


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org