Skip to content

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

Closed
logseq/logseq
#13615

Description

@yuxi-liu-wired

Steps

In a time zone east of UTC (for example Europe/Berlin or Asia/Tokyo):

  1. Create a task and add a Deadline with /deadline: pick March 1, 2026, no time.
  2. In the same date picker tick "Repeat task", set "Every" to 1 Month and leave "Next date" at its default, "Advance from scheduled, skip to future" (++).
  3. On March 1, 2026, click the task's checkbox.

Expected

The task is Todo again with Deadline April 1, 2026, one month after March 1.

Actual

Deadline is March 29, 2026. West of UTC (America/New_York, UTC-12) the same steps give April 1.

More cases, each measured with the same kind of task (no time unless given):

  • Berlin, yearly, 2027-03-01 comes back as 2028-02-29.
  • UTC+14, "Advance from scheduled" (+), every 3 months, 2026-08-31 comes back as 2026-12-01 instead of 2026-11-30; UTC-12 gives 2026-11-30.
  • Los Angeles, "Advance from completion" (.+), every 1 month, completed on 2026-04-30 at 17:00: the new Deadline is 2026-05-31 17:00 instead of 2026-05-30 17:00.

A date on the 1st of a month lands on the last days of the same month whenever the month before is shorter: from February, April, June, September and November (read from the cause below; March 1 measured).

Cause

Deadline and Scheduled store an instant. A date picked without a time is local midnight of that day (the day picker's Date, then tc/to-long in calendar-inner, src/main/frontend/components/property/value.cljs). When the task is completed, get-next-time (src/main/frontend/worker/commands.cljs:157) turns the value into a UTC date-time (tc/to-date-time, line 164), and all 3 rules add the months with t/plus (lines 113, 120, 134, 138). cljs-time's period-fn adds months with goog.date.Date.prototype.add (goog/date/date.js), which clamps the day to the length of the target month, and on a goog.date.UtcDateTime that method reads and writes the UTC fields (getDate and setDate are getUTCDate and setUTCDate, goog/date/utcdatetime.js). East of UTC, local midnight of March 1 is still February 28 in UTC (23:00 in Berlin, 15:00 in Tokyo); February 28 plus 1 month is March 28 in UTC, which reads back as March 29 locally. The yearly case is the same on February 28, 2027 plus 1 year, 2028-02-28 UTC, which is February 29 locally. West of UTC it happens to values whose local evening is already the next day in UTC.

Days and weeks are a fixed number of milliseconds and keep the local day (apart from DST changes, #1295). :date properties are not affected: since cda0f025a their repeat is computed in whole days from the journal day. #1295 proposes storing a date without a time as a day, which would remove this case too; this issue is the one-zone consequence, with no second device and no DST change involved.

How found

A model-based property test of dates (frontend.worker.date-model-property-test, branch test/date-model-fuzz on upstream master 16c4ed1a0) sends every operation through the worker's apply-ops! with the arguments the UI sends, with the worker pipeline that runs the repeat command, and a fixed clock. Its oracle computes the next date from the org-mode repeater definitions in local calendar arithmetic (for +, the old date plus the interval). The same seed and sequence run once in UTC-12 and once in UTC+14 gave different dates for the same task. Shortest sequence: Deadline 2026-03-01 without a time, repeat every 1 month with +, task checked on 2026-01-31: 2026-03-29 at UTC+14. The Berlin, Tokyo, New York and UTC-12 cases above are replays of 1 sequence on master 16c4ed1a0.

Activity

  1. yuxi-liu-wired commented on Oct 6, 2026

    @yuxi-liu-wired
    Author
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions