Lee-W commented on code in PR #75847:
URL: https://github.com/apache/airflow/pull/75847#discussion_r4410865425
##########
airflow-core/src/airflow/timetables/_cron.py:
##########
@@ -162,7 +195,16 @@ def _get_next(self, current: DateTime) -> DateTime:
assert isinstance(scheduled, datetime.datetime)
if not _covers_every_hour(cron):
return convert_to_utc(make_aware(scheduled, self._timezone))
+
delta = scheduled - naive
+ if delta >= _FOLD_DELTA_LIMIT:
Review Comment:
didn't even know a 30 mins shift is possible......
Instead of comparing the UTC offset at both ends, add a helper
`_localize_if_unambiguous` takes the shortcut only when neither the current
wall-clock time nor the target tick sits in a fold or a gap, and returns that
single instant. The fold search runs only when one of them does. An offset
comparison alone still misses sparse crons such as `0 * 1 3,11
*`, where both ends share an offset while the target (or the current time)
is inside a fold. The look-back is bounded by `_MAX_DST_SHIFT`
Lord_Howe `0,10 * * * 0` from 2026-04-04T14:10Z now gives 15:30Z and `0,45 *
* * 0` gives 14:45Z.
@uranusjr's cases pass as well:
Godthab `0 * * * 0` (also `0,10` and `* * * * 0`) from 2026-10-25T00:30Z
gives 02:00Z, and Havana `0,30 * * * 6` `_get_prev(2026-11-01T05:00Z)` gives
03:30Z
A minute-grid oracle over 11 zones (including Lord_Howe and Troll) × 15
crons (210,400 checks) and a sparse-cron sweep (180,140 checks) all passes.
`_get_next` for `0 * * * *` on an ordinary day is back to about 44 µs
against about 40 µs on main.
--
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]