V0lantis commented on issue #35558:
URL: https://github.com/apache/airflow/issues/35558#issuecomment-1804240391

   After a lot of investigation, I am pretty sure the problem comes from the 
[following 
snippet](https://github.com/apache/airflow/blob/main/airflow/timetables/_cron.py#L131-L140):
   
   ```python
       def _align_to_prev(self, current: DateTime) -> DateTime:
           """Get the prev scheduled time.
   
           This is ``current - interval``, unless ``current`` falls right on the
           interval boundary, when ``current`` is returned.
           """
           prev_time = self._get_prev(current)
           if self._get_next(prev_time) != current:
               return prev_time
           return current
   ```
   Indeed, the test that I wrote above give us the following result:
   
   ```
   the 28 at 20 UTC: naive=2023-10-28 22:00:00 | scheduled=2023-10-28 21:00:00 
| pre_date=2023-10-28T19:00:00+00:00
   the 28 at 21 UTC: naive=2023-10-28 23:00:00 | scheduled=2023-10-28 21:00:00 
| pre_date=2023-10-28T19:00:00+00:00
   the 28 at 22 UTC: naive=2023-10-29 00:00:00 | scheduled=2023-10-28 21:00:00 
| pre_date=2023-10-28T19:00:00+00:00
   the 28 at 23 UTC: naive=2023-10-29 01:00:00 | scheduled=2023-10-28 21:00:00 
| pre_date=2023-10-28T19:00:00+00:00
   the 29 at 0 UTC: naive=2023-10-29 02:00:00 | scheduled=2023-10-28 21:00:00 | 
pre_date=2023-10-28T19:00:00+00:00
   the 29 at 1 UTC: naive=2023-10-29 02:00:00 | scheduled=2023-10-28 21:00:00 | 
pre_date=2023-10-28T20:00:00+00:00 # Same from midnight
   the 29 at 2 UTC: naive=2023-10-29 03:00:00 | scheduled=2023-10-28 21:00:00 | 
pre_date=2023-10-28T20:00:00+00:00
   the 29 at 3 UTC: naive=2023-10-29 04:00:00 | scheduled=2023-10-28 21:00:00 | 
pre_date=2023-10-28T20:00:00+00:00
   the 29 at 4 UTC: naive=2023-10-29 05:00:00 | scheduled=2023-10-28 21:00:00 | 
pre_date=2023-10-28T20:00:00+00:00
   the 29 at 5 UTC: naive=2023-10-29 06:00:00 | scheduled=2023-10-28 21:00:00 | 
pre_date=2023-10-29T05:00:00+00:00
   the 29 at 6 UTC: naive=2023-10-29 07:00:00 | scheduled=2023-10-28 21:00:00 | 
pre_date=2023-10-28T20:00:00+00:00
   the 29 at 7 UTC: naive=2023-10-29 08:00:00 | scheduled=2023-10-29 07:00:00 | 
pre_d
   ```


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