iamtodor-fb opened a new issue, #41772:
URL: https://github.com/apache/airflow/issues/41772

   ### What do you see as an issue?
   
   The Templates: macros [documentation 
page](https://airflow.apache.org/docs/apache-airflow/2.7.3/templates-ref.html#macros)
 leads to the deprecated `datetime.utcnow` and `datetime.utcfromtimestamp`.
   
   Upon now we are using `current_timestamp_utc="{{ 
macros.datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S') }}"` which is 
deprecated. Now I'm looking for a way to specify the UTC timezone in the 
macros, that is not deprecated.
   
   Per documentation:
   
   Variable | Description
   -- | --
   macros.datetime | The standard lib’s datetime.datetime
   macros.timedelta | The standard lib’s datetime.timedelta
   macros.dateutil | A reference to the dateutil package
   macros.time | The standard lib’s time
   macros.uuid | The standard lib’s uuid
   macros.random | The standard lib’s random.random
   
   However for example,
   
   ```python
   >>> import datetime
   >>> datetime.datetime.now()
   datetime.datetime(2024, 8, 22, 18, 3, 31, 124275)
   >>> datetime.datetime.now(datetime.timezone.utc)
   datetime.datetime(2024, 8, 22, 16, 3, 49, 878177, 
tzinfo=datetime.timezone.utc)
   ```
   
   `timezone.utc` comes from `datetime` and it cannot be imported on a macros 
level.
   
   If I miss anything please feel free to ping me and I would be happy to 
provide more details
   
   ### Solving the problem
   
   Please update the documentation on how to specify the`datetime.utcnow` in 
macros.
   
   ### Anything else
   
   I also found the related issue, where the internal Airflow code was 
transitioned to the up-to-date toolset 
https://github.com/apache/airflow/issues/32344
   
   ### Are you willing to submit PR?
   
   - [ ] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [X] I agree to follow this project's [Code of 
Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md)
   


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