varadendrasimha511 opened a new pull request, #72877: URL: https://github.com/apache/airflow/pull/72877
## What `td_format` incorrectly rendered negative durations as large positive-looking values (e.g. `timedelta(seconds=-3752)` returned `29d:22h:57M:28s` instead of a negative representation). ## Why Python's internal `timedelta`/`relativedelta` normalization mixes signs (e.g. `days=-1, seconds=82048`), and the subsequent `divmod(delta.days, 30)` month calculation flipped the sign further, silently dropping the negative months field due to the `if value < 1: return ""` check in `_format_part`. The negative sign information was lost entirely. ## Fix - Detect whether the input duration is negative up front. - Perform all relativedelta/formatting math on the absolute value. - Prepend a `-` sign to the final formatted string if the original duration was negative. ## Testing Added test cases to `test_td_format` covering negative `timedelta`, negative `float`, and negative `int` inputs, including a sub-second negative duration (`<1s` case). All 30 existing tests in `test_timezone.py` 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]
