dhruv-techdev opened a new pull request, #75530:
URL: https://github.com/apache/airflow/pull/75530

   When `target_lower` and `target_upper` are `datetime.time` values and 
`target_upper` is earlier than `target_lower` (for example 22:00 → 02:00), the 
docs say the window spans two dates. Before midnight this works. After 
midnight, a time like 01:00 was compared against the window that starts at 
22:00 later the same day, so `follow_task_ids_if_false` was followed even 
though 01:00 is inside the window.
   
   `target_times_as_dates` now checks which side of midnight the current time 
is on. Between midnight and `target_upper`, the window started the previous 
day, so `target_lower` moves back one day. Otherwise `target_upper` moves 
forward one day, as before. Exactly `target_upper` (02:00) still counts as 
inside the window, the same as for non-overnight windows.
   
   The documented example (15:00 → 00:00) never showed the problem because its 
window ends exactly at midnight.
   
   This is independent of #74838, which fixes which date the time targets are 
combined with for Dags not in UTC. The two changes touch different lines and 
together give the right result in any Dag timezone.
   
   closes: #75528 
   related: #74838
   
   **Tests**
   
   Added `test_branch_datetime_operator_window_spans_midnight` with times at 
23:00, 01:00 and 02:00 for a 22:00 → 02:00 window. Without the fix, the 01:00 
and 02:00 cases fail (`branch_2` instead of `branch_1`).
   
   ```
   TZ=UTC uv run --project providers/standard pytest 
providers/standard/tests/unit/standard/operators/test_datetime.py
   37 passed
   ```
   
   `ruff format --check` and `ruff check` pass on both changed files.
   
   ---
   
   ##### Was generative AI tooling used to co-author this PR?
   
   <!--
   If generative AI tooling has been used in the process of authoring this PR, 
please
   change below checkbox to `[X]` followed by the name of the tool, uncomment 
the "Generated-by".
   -->
   
   - [X] Yes (please specify the tool below)
   
   <!--
   Generated-by: Claude Opus 5.5 following [the 
guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions)
   -->
   
   ---
   
   * Read the **[Pull Request 
Guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#pull-request-guidelines)**
 for more information. Note: commit author/co-author name and email in commits 
become permanently public when merged.
   * For fundamental code changes, an Airflow Improvement Proposal 
([AIP](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvement+Proposals))
 is needed.
   * When adding dependency, check compliance with the [ASF 3rd Party License 
Policy](https://www.apache.org/legal/resolved.html#category-x).
   * For significant user-facing changes create newsfragment: 
`{pr_number}.significant.rst`, in 
[airflow-core/newsfragments](https://github.com/apache/airflow/tree/main/airflow-core/newsfragments).
 You can add this file in a follow-up commit after the PR is created so you 
know the PR number.
   


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