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_r294097557
 
 

 ##########
 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:
   The issue causing failing `test_following_previous_schedule` is due to this 
`convert_to_utc` function.  
   
   The problem is with using `pendulum.instance()` in the localized case.
   
   To see why, you can run this:
   ```        
   local_tz = pendulum.timezone('Europe/Zurich')
   start = local_tz.convert(datetime.datetime(2018, 10, 28, 2, 55), 
dst_rule=pendulum.PRE_TRANSITION)
   print(start.isoformat()) # '2018-10-28T02:55:00+02:00'
   print(pendulum.instance(start).isoformat()) # '2018-10-28T02:55:00+01:00'
   ```
   
   Replacing your return statement with the following seems to resolve the 
issue:
   ```suggestion
       if not is_localized(value):
           value = pendulum.instance(value, TIMEZONE)
   
       return utc.convert(value)
   ```

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