SHIVANSH-ux-ys opened a new pull request, #72774:
URL: https://github.com/apache/airflow/pull/72774

   closes: #72694
   
   ### Rationale for this change
   
   Fixes #72694.
   
   `td_format` in `shared/timezones` rendered negative `timedelta` objects as 
large positive durations (e.g. `timedelta(seconds=-3752)` rendered as 
`29d:22h:57M:28s`). This occurred because `relativedelta` days normalization 
via `divmod` produced negative months (`months=-1, days=+29`) which were 
stripped by positive magnitude filtering (`value < 1`). Furthermore, numeric 
negative inputs (e.g. `-3752`) returned `<1s`.
   
   ### What changes are included in this PR?
   
   1. Updated `td_format` in 
`shared/timezones/src/airflow_shared/timezones/timezone.py` to extract negative 
sign prefix (`"-"`) and compute duration string using the absolute magnitude of 
the timedelta or numeric duration.
   2. Added test cases in `test_timezone.py` verifying negative `timedelta` and 
negative numeric inputs format correctly (e.g. 
`td_format(timedelta(seconds=-3752))` returns `"-1h:2M:32s"`, 
`td_format(-3752)` returns `"-1h:2M:32s"`, `td_format(timedelta(days=-5))` 
returns `"-5d"`).
   
   ### Are these changes tested?
   
   Yes. Added unit tests in `shared/timezones/tests/timezones/test_timezone.py` 
and verified all 30 timezone unit tests pass.


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