dstandish commented on a change in pull request #5332: [AIRFLOW-3391] Upgrade 
pendulum to latest major version.
URL: https://github.com/apache/airflow/pull/5332#discussion_r296034481
 
 

 ##########
 File path: airflow/utils/timezone.py
 ##########
 @@ -89,10 +89,11 @@ def convert_to_utc(value):
     if not value:
         return value
 
-    if not is_localized(value):
-        value = pendulum.instance(value, TIMEZONE)
-
-    return value.astimezone(utc)
+    return (
 
 Review comment:
   OK so i finally installed py3.5 locally to see what’s going on.
   
   `Timezone.convert()` does not work right in pendulum 2.0 on python 3.5.  It 
does not respect `dst_rule`.  So the problem is with the structure of the test 
`test_following_previous_schedule` itself.
   
   In `test_following_previous_schedule`, `start` is defined like so:  ```python
   start = local_tz.convert(datetime.datetime(2018, 10, 28, 2, 55), 
dst_rule=pendulum.PRE_TRANSITION)```
   
   On py3.5 with pendulum 2.0, `start` gets the wrong utcoffset: 1 hour;  in 
all other combinations (i.e. 3.5/1.5, 3.6/1.5, 3.7/1.5, 3.6/2.0, 3.7/2.0), the 
offset is 2 hours (which is the correct offset).
   
   So, I think what we need to do is instead define `start` like so:
   ```
   start = pendulum.datetime(2018, 10, 28, 2, 55, 
dst_rule=pendulum.PRE_TRANSITION, tz=local_tz)```
   
   And additionally, we need to review the code, to see where we might be using 
`Timezone.convert`, and make changes as appropriate.
   
   Additional note:
   On py3.5 with pendulum 2.0 you can see that dst_rule is not respected in 
`convert`:
   ```python
   import pendulum, datetime
   
   local_tz = pendulum.timezone('Europe/Zurich')
   UTC = pendulum.timezone('UTC')
   start_post = local_tz.convert(datetime.datetime(2018, 10, 28, 2, 55), 
dst_rule=pendulum.POST_TRANSITION)
   start_pre = local_tz.convert(datetime.datetime(2018, 10, 28, 2, 55), 
dst_rule=pendulum.PRE_TRANSITION)
   print(start_post.isoformat())
   print(start_pre.isoformat())
   ```
   

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to