Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pickers][DatePicker] Weekdays are shifted when using GMT timezone (such as Europe/London) #16090

Closed
jimmyh-onepilot opened this issue Jan 7, 2025 · 5 comments
Labels
component: pickers This is the name of the generic UI component, not the React module! external dependency Blocked by external dependency, we can’t do anything about it

Comments

@jimmyh-onepilot
Copy link

jimmyh-onepilot commented Jan 7, 2025

Steps to reproduce

  • Set up a DatePicker with @mui/x-date-pickers.
  • Configure a dayjs timezone to 'Europe/London'.
  • Open the calendar and observe the incorrect alignment.

Current behavior

The calendar displays incorrect dates when using the @mui/x-date-pickers with dayjs and setting the timezone to 'Europe/London' (or any GMT timezone).

For example, January 1, 2025, is shown as a Thursday instead of a Wednesday.

I need to display the hours according to the timezone from my event. However, when selecting a date with Europe/London, the current month is wrong (the previous month?) and the days are incorrect.

Capture d’écran 2025-01-07 à 12 46 47

While it seems to be working as expected for any other timezone, such as Europe/Paris (GMT+1) or Europe/Riga (GMT+2).
Capture d’écran 2025-01-07 à 12 50 10

Here's my following code:

        <DateTimePicker value={dayjs(start).tz(timezone, true)}.../>

Also tried with this one, but does not seem to resolve the issue.

        <DateTimePicker value={dayjs(start)} timezone={timezone}.../>

Expected behavior

DateTimePicker should also work with values from the GMT timezone and must suggest current month of selected date, and not the previous one.

Also reproduced on the documentation example with 'Europe/London' value.

Capture d’écran 2025-01-07 à 12 38 00

Context

I need to display the hours according to the timezone from my event, which is currently working. But when coming to selecting a value, it seems to have an issue with events having specific timezone. (such as Europe/London)

Your environment

npx @mui/envinfo
  System:
    OS: macOS 15.1.1
  Binaries:
    Node: 18.18.2 - ~/.nvm/versions/node/v18.18.2/bin/node
    npm: 9.8.1 - ~/.nvm/versions/node/v18.18.2/bin/npm
    pnpm: Not Found
  Browsers:
    Chrome: 131.0.6778.205
    Edge: Not Found
    Safari: 18.1.1
  npmPackages:
    @emotion/react: ^11.9.0 => 11.11.1 
    @emotion/styled: ^11.8.1 => 11.11.0 
    @mui/base:  5.0.0-beta.7 
    @mui/core-downloads-tracker:  5.16.8 
    @mui/icons-material: ^5.16.8 => 5.16.8 
    @mui/lab: ^5.0.0-alpha.121 => 5.0.0-alpha.136 
    @mui/material: ^5.16.8 => 5.16.8 
    @mui/private-theming:  5.16.8 
    @mui/styled-engine:  6.3.1 
    @mui/styles: ^5.16.8 => 5.16.8 
    @mui/system: ^6.3.1 => 6.3.1 
    @mui/types:  7.2.19 
    @mui/utils:  5.13.7 
    @mui/x-date-pickers: ^7.23.3 => 7.23.3 
    @mui/x-internals:  7.23.0 
    @types/react: ^18.3.3 => 18.3.10 
    react: ^18.3.1 => 18.3.1 
    react-dom: ^18.3.1 => 18.3.1 
    typescript: ^4.3.3 => 4.9.5 

Environment:

  • @mui/x-date-pickers: 6.14 (Also tried with latest update 7.23.3)
  • dayjs: 1.11.5 (Also tried with latest update 1.11.13)
  • Build tool: Vite
  • OS: macOS Ventura

Search keywords: Picker wrong weekdays timezone

@jimmyh-onepilot jimmyh-onepilot added bug 🐛 Something doesn't work status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Jan 7, 2025
@github-actions github-actions bot added the component: pickers This is the name of the generic UI component, not the React module! label Jan 7, 2025
@michelengelen
Copy link
Member

Hey @jimmyh-onepilot ... as you stated correctly this is due to a bug from dayjs when using a zero offset timezone, such as UTC or Europe/London.

duplicate of #9653

@michelengelen michelengelen removed the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Jan 7, 2025
Copy link

github-actions bot commented Jan 7, 2025

This issue has been closed. If you have a similar problem but not exactly the same, please open a new issue.
Now, if you have additional information related to this issue or things that could help future readers, feel free to leave a comment.

Note

@jimmyh-onepilot How did we do? Your experience with our support team matters to us. If you have a moment, please share your thoughts in this short Support Satisfaction survey.

@michelengelen michelengelen added external dependency Blocked by external dependency, we can’t do anything about it and removed bug 🐛 Something doesn't work labels Jan 7, 2025
@michelengelen michelengelen changed the title DatePicker shifts week days when using GMT timezone (such as Europe/London) [pickers][DatePicker] Weekdays are shifted when using GMT timezone (such as Europe/London) Jan 7, 2025
@jimmyh-onepilot
Copy link
Author

jimmyh-onepilot commented Jan 7, 2025

Thanks for your reply @michelengelen

This is unfortunate.. is there any workaround or anything to prevent this issue?

@michelengelen
Copy link
Member

Thanks for your reply @michelengelen

This is unfortunate.. is there any workaround or anything to prevent this issue?

Well, the obvious workaround is to use a different library like datefns, but I do understand that this might not be possible, especially inside an application where everything is built around dayjs.

Unfortunately we do not have any other workaround as of now and the dayjs maintainer seems relatively inactive (last release was Aug 20, 2024), so fixing this might take a while.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: pickers This is the name of the generic UI component, not the React module! external dependency Blocked by external dependency, we can’t do anything about it
Projects
None yet
Development

No branches or pull requests

2 participants