Skip to content

fix(repeat): step Deadline and Scheduled in the local calendar - #13615

Merged
tiensonqin merged 1 commit into
logseq:masterfrom
yuxi-liu-wired:fix/repeat-local-calendar
Oct 7, 2026
Merged

tiensonqin merged 1 commit into
logseq:masterfrom
yuxi-liu-wired:fix/repeat-local-calendar

Conversation

@yuxi-liu-wired

Copy link
Copy Markdown
Contributor

Fixes logseq/db-test#1355.

In a time zone east of UTC (Europe/Berlin, Asia/Tokyo), a task with Deadline March 1, 2026 (no time) repeating every 1 month comes back with Deadline March 29, 2026 instead of April 1. More cases from the issue: yearly from 2027-03-01 gives 2028-02-29; + every 3 months from 2026-08-31 gives 2026-12-01 at UTC+14; .+ monthly completed 2026-04-30 17:00 in Los Angeles gives 2026-05-31 17:00.

Deadline and Scheduled store an instant, and a date picked without a time is local midnight. get-next-time in src/main/frontend/worker/commands.cljs turned it into a UTC date-time (tc/to-date-time) and added months and years in the UTC calendar. East of UTC, local midnight of March 1 is February 28 in UTC; 1 month later is March 28 UTC, which is local March 29.

get-next-time now steps an instant in the local calendar (a goog.date.DateTime at the same instant), so local midnight of the 1st stays local midnight of the 1st, and a value with a time keeps its local time across a clock change. A :date property keeps the UTC-day stepping it already has (it passes local? false).

Tests in src/test/frontend/worker/commands_test.cljs:

  • New repeated-instant-steps-in-the-local-calendar-test: the cases above, plus weekly and hourly. On master it fails 3 times in Europe/Berlin, Asia/Tokyo and America/New_York; with the change it passes.
  • double-plus-month-end-keeps-its-day-test and repeated-task-monthly-deadline-from-31st-test wrote their dates as UTC times (t/date-time); they now use local times (t/local-date-time), as the date picker stores them. With UTC times, January 31 UTC is January 30 local west of UTC, and the old tests passed only in UTC.
  • The day and week counts in the older get-next-time tests used fixed 24-hour days, and their "now" was the real current time; they now count local calendar days (local-days) from a fixed mid-June "now", away from clock changes.

frontend.worker.commands-test passes with TZ set to Europe/Berlin, Asia/Tokyo, Pacific/Kiritimati, America/New_York, America/Los_Angeles, Australia/Sydney, America/Santiago, Etc/GMT+12 and UTC. frontend.components.property.value-test, frontend.worker.handler.property-test and frontend.worker.pipeline-test pass in Europe/Berlin and America/New_York.

A date picked without a time is local midnight. get-next-time added
months and years in UTC, so east of UTC local midnight of March 1
(Feb 28 in UTC) came back as March 29 local, at the end of the same
month (db-test logseq#1355). Instants now step in the local calendar; :date
properties keep stepping whole UTC days.

Tests: new local-calendar cases; the month-end tests use local times as
the date picker stores them; day and week counts are local calendar days
from a fixed now.
@tiensonqin
tiensonqin force-pushed the fix/repeat-local-calendar branch from 6b22a44 to 0c8d333 Compare October 7, 2026 12:05
@tiensonqin
tiensonqin merged commit 533ac43 into logseq:master Oct 7, 2026
yuxi-liu-wired added a commit to yuxi-liu-wired/logseq that referenced this pull request Oct 8, 2026
devin-ai-integration Bot pushed a commit that referenced this pull request Oct 8, 2026
A date picked without a time is local midnight. get-next-time added
months and years in UTC, so east of UTC local midnight of March 1
(Feb 28 in UTC) came back as March 29 local, at the end of the same
month (db-test #1355). Instants now step in the local calendar; :date
properties keep stepping whole UTC days.

Tests: new local-calendar cases; the month-end tests use local times as
the date picker stores them; day and week counts are local calendar days
from a fixed now.
yuxi-liu-wired added a commit to yuxi-liu-wired/logseq that referenced this pull request Oct 11, 2026
yuxi-liu-wired added a commit to yuxi-liu-wired/logseq that referenced this pull request Oct 13, 2026
yuxi-liu-wired added a commit to yuxi-liu-wired/logseq that referenced this pull request Oct 16, 2026
@yuxi-liu-wired
yuxi-liu-wired deleted the fix/repeat-local-calendar branch October 21, 2026 18:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

East of UTC, a monthly repeat moves a Deadline on the 1st to the end of the same month

2 participants