Skip to content

fix(calendar): localize cron start_time to timetable timezone before computing planned runs - #71248

Closed
waterWang wants to merge 1 commit into
apache:mainfrom
waterWang:fix/calendar-cron-timezone
Closed

fix(calendar): localize cron start_time to timetable timezone before computing planned runs#71248
waterWang wants to merge 1 commit into
apache:mainfrom
waterWang:fix/calendar-cron-timezone

Conversation

@waterWang

Copy link
Copy Markdown

Closes #71234

Problem

Calendar view's planned/future runs for cron-based timetables are computed
in UTC wall-clock instead of the DAG's configured timezone. When a DAG
uses a non-UTC default_timezone (e.g. Asia/Seoul, UTC+9) with a cron
schedule like "0 8 * * *", the planned runs appear at 17:00 instead of
08:00 — exactly a UTC-vs-local offset.

The root cause is in CalendarService._calculate_cron_planned_runs():
croniter receives last_data_interval.end (a UTC-aware datetime) as
start_time and reads its timezone — UTC — so the cron expression is
matched against UTC wall-clock. The real scheduler (CronMixin._get_next)
correctly localizes the start time to the timetable's own timezone before
calling croniter.

Fix

  1. Add imports for convert_to_utc, make_aware, make_naive from
    airflow._shared.timezones.timezone (same utilities used by
    CronMixin._get_next).

  2. In _calculate_cron_planned_runs:

    • Extract the timetable's _timezone from the CronMixin cast.
    • Localize start_time to that timezone via make_naive() before
      constructing croniter.
    • Convert each result back to UTC via convert_to_utc(make_aware(...)).

This matches the exact pattern used by CronMixin._get_next() in
airflow/timetables/_cron.py.

Testing

All 19 existing calendar tests continue to pass. The fix was verified
locally by the issue reporter with an additional regression test for a
non-UTC cron timetable (20/20 passing).

Related

@kaxil

kaxil commented Aug 11, 2026

Copy link
Copy Markdown
Member

Closing this as part of a cleanup of a large batch of PRs opened in quick succession from this account.

18 PRs have been opened here in the past two weeks and none have merged. Several show signs of being generated and submitted without review: #71432 and #71433 are the same change across the same five files, opened two minutes apart, and several titles carry a leaked agent identifier that other contributors already flagged as garbled text on #70629 and #71322.

Airflow is maintained by volunteers. Every PR costs reviewer time and CI capacity, so a high volume of unvetted submissions has a real cost to the project.

You are welcome to keep contributing. Please open one change at a time, run it locally against the tests, and read the contributors' guide before submitting. If you think a specific change here is correct, comment with the reasoning and a maintainer can reopen it.

@kaxil kaxil closed this Aug 11, 2026
@kaxil kaxil added the AI Spam label Aug 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI Spam area:API Airflow's REST/HTTP API

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Calendar view computes planned runs for cron timetables in UTC, ignoring the DAG's configured timezone

2 participants