dhruv-techdev commented on code in PR #75530:
URL: https://github.com/apache/airflow/pull/75530#discussion_r4373850019


##########
providers/standard/src/airflow/providers/standard/operators/datetime.py:
##########
@@ -110,5 +110,9 @@ def target_times_as_dates(
         return lower, upper
 
     if upper < lower:
-        upper += datetime.timedelta(days=1)
+        # Past midnight, the window that contains base_date started the 
previous day
+        if base_date.time() <= upper.time():
+            lower -= datetime.timedelta(days=1)

Review Comment:
   Good catch, thanks! No, it doesn't. When `target_lower` is a `datetime` and 
`target_upper` is a `time`, the new branch can move the user's exact 
`target_lower` back a day.
   
   For example, with `target_lower=datetime(2020, 7, 7, 22, 0)` and 
`target_upper=time(2, 0)`, a run at 2020-07-07 01:00 now takes the true branch, 
because the window becomes Jul 6 22:00 → Jul 7 02:00. Before this change it 
took the false branch, which is right: 01:00 is before the start the user set.
   
   A fixed datetime shouldn't be shifted, so I'll only move `target_lower` back 
when it was passed as a `time`. Mixed targets then behave exactly as they did 
before, and the overnight case with two `time` targets stays fixed. I'll push 
that with a test for the mixed case.



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