Skip to content

[BUGFIX] sync timezon using dayjs#82

Closed
shahrokni wants to merge 0 commit intomainfrom
fix/sync-timezone-dayjs
Closed

[BUGFIX] sync timezon using dayjs#82
shahrokni wants to merge 0 commit intomainfrom
fix/sync-timezone-dayjs

Conversation

@shahrokni
Copy link
Contributor

@shahrokni shahrokni commented Mar 6, 2026

closes perses/perses#3935

Description

This change adjust the initial and subsequently updated time range with the time zone. This fix keeps all elements of date/time synced.

Please note, The AdapterDateFns uses standard JavaScript Date objects, which only recognize the browser's local time or UTC. It cannot "shift" to a specific IANA timezone like Europe/London internally. MUI's timezone prop explicitly requires an adapter that supports timezones, such as Day.js. Day.js allows you to extend its functionality with the utc and timezone plugins. This lets the adapter calculate the correct offsets

In the following screenshot my local timezone is CEST and I had changed the timezone to GMT+0 (London)
CEST is GMT+1. As you can see, everything is synced. Either, you change the range from the inputs or the x-picker control, everything should be synced.

⚠️ When you are testing please take AM/PM into account, otherwise you may get confused and think something is wrong.

image

Screenshots

Checklist

  • Pull request has a descriptive title and context useful to a reviewer.
  • Pull request title follows the [<catalog_entry>] <commit message> naming convention using one of the
    following catalog_entry values: FEATURE, ENHANCEMENT, BUGFIX, BREAKINGCHANGE, DOC,IGNORE.
  • All commits have DCO signoffs.

UI Changes

  • Changes that impact the UI include screenshots and/or screencasts of the relevant changes.
  • Code follows the UI guidelines.
  • E2E tests are stable and unlikely to be flaky.
    See e2e docs for more details. Common issues include:
    • Is the data inconsistent? You need to mock API requests.
    • Does the time change? You need to use consistent time values or mock time utilities.
    • Does it have loading states? You need to wait for loading to complete.

@shahrokni shahrokni marked this pull request as ready for review March 6, 2026 15:57
@shahrokni shahrokni requested a review from a team as a code owner March 6, 2026 15:57
@Gladorme
Copy link
Member

Gladorme commented Mar 6, 2026

I still did not review the PR.

However, I don't think it's a great idea to have two time libs (date-fns /datejs). If date-fns is not good enough, we should move everything to the lib supporting everything. But are you sure date-fns don't support timezone? I see support on date-fns v4: https://date-fns.org/v4.1.0/docs/Time-Zones

@shahrokni
Copy link
Contributor Author

shahrokni commented Mar 9, 2026

I still did not review the PR.

However, I don't think it's a great idea to have two time libs (date-fns /datejs). If date-fns is not good enough, we should move everything to the lib supporting everything. But are you sure date-fns don't support timezone? I see support on date-fns v4: https://date-fns.org/v4.1.0/docs/Time-Zones

OK, I will set the version to date-fns v4

@shahrokni shahrokni closed this Mar 9, 2026
@shahrokni shahrokni force-pushed the fix/sync-timezone-dayjs branch from 48fe9b9 to 0425188 Compare March 9, 2026 10:39
@shahrokni shahrokni deleted the fix/sync-timezone-dayjs branch March 9, 2026 10:53
@Gladorme
Copy link
Member

Gladorme commented Mar 9, 2026

PR moved to: #83

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.

Custom time range selection is not aligned with timezone selection

2 participants