amoghrajesh commented on code in PR #75847:
URL: https://github.com/apache/airflow/pull/75847#discussion_r4411013590
##########
airflow-core/src/airflow/timetables/_cron.py:
##########
@@ -153,6 +174,31 @@ def localize_partition_datetime(self, dt:
datetime.datetime) -> DateTime:
"""
return convert_to_utc(make_aware(dt.replace(tzinfo=None),
self._timezone))
+ def _localized_ticks_within_limit(self, naive: datetime.datetime, *,
before: bool) -> list[DateTime]:
+ """Localize every cron tick within ``_MAX_DST_SHIFT`` on one side of
``naive``, ``naive`` included."""
+ nudge = datetime.timedelta(microseconds=1)
+ cron = croniter(self._expression, start_time=naive + nudge if before
else naive - nudge)
+ step = cron.get_prev if before else cron.get_next
+ localized: list[DateTime] = []
+ tick = step(datetime.datetime)
+ while abs(tick - naive) <= _MAX_DST_SHIFT:
+ localized += _localize_all_folds(tick, self._timezone)
+ tick = step(datetime.datetime)
+ return localized
+
+ def _localize_if_unambiguous(
+ self, naive: datetime.datetime, scheduled: datetime.datetime
+ ) -> DateTime | None:
+ """
+ Localize ``scheduled`` when neither it nor ``naive`` is ambiguous,
else return ``None``.
+
+ Without a fold or gap at either end, localizing the wall-clock tick is
exact.
Review Comment:
It says the two ends must be unambiguous, but the part that is not obvious
is why a fold *between* them is harmless: any tick inside it resolves on the
far side of `current`, so it cannot win. I checked that
holds, including across the 49-hour weekend gap. Saves the next reader the
derivation.
--
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]