The `startOf` method is not using the current locale when the `timezone` plugin is enabled
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 48.7k
- Forks
- 2.8k
- PR merge metrics
- No merged PRs in 30d
Description
Describe the bug
I am one of the maintainer of the MUI Date and Time Pickers which are using dayjs for date manipulation.
One of our users reported a bug when using both the timezone and the de locale.
The problem comes from the startOf methods which is not using the current locale when the timezone plugin is enabled.
If you take the following piece of code:
dayjs.tz('2022-04-17', 'Europe/Paris').locale('de').startOf('week')
The returned day is a Sunday but it should be a Monday.
Expected behavior
The timezone plugin should not impact the behavior of startOf('week').
I was able to make the plugin work by setting the locale explicitly on this line:
Information
- Day.js Version: 1.11.9
- OS: Ubuntu 22.04.2
- Browser: Chrome 115
- Time zone:
Europe/Paris
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with src/plugin/timezone/index.js at the referenced line and reproduce the supplied locale, timezone, and startOf('week') example. Trace how the timezone plugin creates or preserves locale state, then verify that the result uses Monday for the German locale without changing other startOf behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 38/100