Skip to content

Hourly buckets ignore the site time zone #6

Closed

Description

@sinnercode228

bucketStart() in packages/core/src/time.ts takes a timeZone but only applies it to day buckets. The 'hour' case is Math.floor(ts / HOUR) * HOUR, which is UTC-aligned. So on a site whose zone has a half-hour offset (Asia/Kolkata, Asia/Tehran, Australia/Adelaide) the hourly timeseries buckets land 30 minutes off the local clock, and the range snapping in query.ts resolve() is off by the same amount.

Repro: bucketStart(Date.parse('2026-05-10T13:47:00Z'), 'hour', 'Asia/Kolkata') returns 2026-05-10T13:00:00Z, but the local hour that contains that instant is 19:00 IST, which starts at 2026-05-10T13:30:00Z. queryTimeseries() then returns hourly points at :30 past every local hour.

Fix: align the 'hour' case to the zone the same way startOfDay already does (shift by tzOffsetMinutes, floor to the hour, subtract the offset at the boundary back out). Minute buckets are fine as they are, because every zone offset is a whole number of minutes. nextBucket stays bucket + HOUR; for whole-hour zones that is still exact across DST, since the offset changes by a whole hour on an hour boundary.

Activity

  1. added a commit that references this issue on Oct 21, 2026
    4da642b
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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions