Sonins commented on pull request #20508:
URL: https://github.com/apache/airflow/pull/20508#issuecomment-1043262523


   > If we change the timezone of `days_ago`, does that mean we will change the 
timezone of any dag that is using it, and therefore we'll change the time of 
day all those dags run? (assuming that they have changed default timezone to be 
non-UTC)
   
   For this, how about adding `days_ago` boolean option like below for backward 
compatibility?
   
   ```python
   def days_ago(n, hour=0, minute=0, second=0, microsecond=0, local=False):
       """
       Get a datetime object representing `n` days ago. By default the time is
       set to midnight.
       """
       if local:
           return datetime.combine(
               datetime.now(timezone.TIMEZONE) - timedelta(days=n),
               time(hour, minute, second, microsecond, 
tzinfo=timezone.TIMEZONE),
           )
       else:
          return datetime.combine(
               datetime.utcnow() - timedelta(days=n),
               time(hour, minute, second, microsecond),
          )
   ```
   


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