Skip to content

Search on:/before:/after: shifted by the timezone offset #42592

Open

Description

@mandar1045

The date filters in message search return the wrong day for anyone not in the server's timezone.

To reproduce: on a server running in UTC, set your browser to Tokyo (UTC+9), send a message at 10am, then search on:<today>. It isn't found, because the search window actually starts at 6pm local time.

The offset math in parseMessageSearchQuery.ts has both signs flipped (+ getTimezoneOffset()/60 + utcOffset), so the day ends up shifted by about twice the user's offset. It only works when the server and the user share a timezone, which is probably why it hasn't come up in local dev. Something like Date.UTC(y, m - 1, d) - utcOffset * 3600000 should fix it. Happy to send a PR.

Tested on 8.10.0-develop (83d0fc2), Docker.

Activity

  1. schizophrenicmaniac commented on Oct 6, 2026

    @schizophrenicmaniac

    Hi, I'd like to work on this. The before:/after:/on: handlers in parseMessageSearchQuery.ts add both offsets instead of subtracting them, so I'd build the day start from Date.UTC minus the user's utcOffset, and add spec cases for positive and negative offsets.

  2. mandar1045 commented on Oct 6, 2026

    @mandar1045
    Author

    @schizophrenicmaniac thanks for it , but im already working on this issue .

  3. goransh-walia commented on Oct 7, 2026

    @goransh-walia

    This is a known pattern that's worth having documented clearly in the issue tracker.

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions