Skip to content

Deadline and Scheduled store a UTC instant, so a date-only value changes day across time zones and DST #1295

Open

Description

@yuxi-liu-wired

What happens

Deadline and Scheduled (type :datetime) store one number, a UTC millisecond timestamp. A value picked without a time is stored as local midnight on the device that picked it, and it shows no time only because the local clock reads 00:00 (frontend.components.property.value, the datetime display checks (= 0 hours minutes)). The zone that wrote the value is not stored, and neither is the fact that no time was chosen. Three consequences, each reproduced on master:

  1. Another zone reads another day. "Sep 23, no time" picked in Los Angeles is 1790146800000. Read in Tokyo it is Sep 23 16:00, so the date-only deadline now shows a time. Read in Honolulu it is Sep 22 21:00, so it shows a time and sits on the previous day's journal (ms->journal-day reads the local day). A graph synced between devices in different zones, or opened while traveling, shows this.
  2. A repeat drifts across DST. get-next-time adds the interval to the value as a UTC date-time. A weekly task scheduled for Sat 2026-10-31 (no time) and completed in America/Los_Angeles is rescheduled to Fri 2026-11-06 23:00: one hour short, because US DST ends on Nov 1, so the next occurrence moves to the previous day and gains a time. In zones without a DST change that week it lands on Sat 2026-11-07 00:00.
  3. Tests depend on the machine's zone. Code that builds a day with journal-day->ms (midnight UTC) and reads it back with ms->journal-day (local) disagrees with itself west of UTC. fix(test): build test dates in local time logseq#13430 fixes 3 tests of this kind that pass only in UTC, which is where CI runs.

Related: logseq/logseq#12538 (entries written in one zone missing on a device in another).

Proposal

Store what the user chose, and derive the instant from it.

  • A date without a time stored as a day with no zone, the way journal pages already are (:block/journal-day 20261031) and the way :date properties already are (a reference to the journal page). It reads as the same day everywhere. Its journal ref is that day's page, with no conversion.
  • A date with a time stored as the wall-clock fields plus the zone's name, for example 2026-10-31T15:00 and America/Los_Angeles. The instant, when needed for sorting, reminders or "overdue", is computed from the two with the platform's time zone data (Intl.DateTimeFormat with timeZone, or Temporal.ZonedDateTime where available). A repeat adds its interval to the wall-clock fields in that zone, so a weekly 15:00 stays at 15:00 across DST.

The zone name matters, not only the UTC offset at the time of writing: the offset of the next occurrence can differ (DST, or a change in a country's rules), and only the name lets the time zone data answer that.

Migration

Existing values are timestamps without a zone, so the migration has to assume one. The device's current zone is the best available guess and is right for most graphs:

  • a timestamp that is local midnight in that zone becomes a date without a time;
  • any other timestamp becomes wall-clock fields in that zone plus the zone's name.

A value written on another device in another zone comes out as it reads on the migrating device today, which can be a different day or a time where none was chosen, as in case 1 above. After the migration it reads the same on every device.

This changes the stored schema, so it is filed as a proposal before any code.

Activity

  1. yuxi-liu-wired commented on Sep 25, 2026

    @yuxi-liu-wired
    Author

    A worked example of the DST case, reproduced on master in America/Los_Angeles (US DST ends on Sun 2026-11-01; Los Angeles is UTC-7 before that day and UTC-8 after):

    1. A task "Water plants" has Scheduled Sat 2026-10-31 09:00 and repeats every week.
    2. The stored value is the timestamp of 2026-10-31 16:00 UTC.
    3. The task is marked done. get-next-time (frontend.worker.commands) converts the value with tc/to-date-time, a UTC date-time, and adds 1 week there: 7 × 24 hours.
    4. The new value is 2026-11-07 16:00 UTC, which is 08:00 in Los Angeles. The task now shows Sat Nov 7 at 08:00 instead of 09:00.

    A task scheduled without a time is stored at local midnight, 2026-10-31 07:00 UTC. The same step gives 2026-11-07 07:00 UTC, which is Fri 2026-11-06 23:00 in Los Angeles: the task moves to the previous day and gains a time. In a zone without a DST change that week, the same task comes back on Sat 2026-11-07 00:00.

    With the zone name stored next to the time, as proposed above, the repeat can add 1 week on the Los Angeles clock (for example Temporal.ZonedDateTime.add({weeks: 1}), or cljs-time arithmetic on a local date-time) and keep 09:00, and keep Saturday for the task without a time. Adding in local wall-clock time would change what get-next-time-test asserts (intervals of exactly 24 hours per day), so I have not opened that change; it seemed better to settle the storage question first.

  2. yuxi-liu-wired commented on Sep 25, 2026

    @yuxi-liu-wired
    Author

    Another instance of the same class, already fixed: #693, where on iOS at GMT-6 tapping a future journal date in the picker selected the following day. Each of these comes from a day turned into an instant in one zone and read back in another.

  3. transferred this issue fromlogseq/logseqon Sep 25, 2026
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