naive-ui
naive-ui copied to clipboard
Wrong first month in Date Picker
Describe the bug
Wron number months in date picker. January is twelve.
Steps to reproduce
- Go to https://www.naiveui.com/en-US/dark/components/date-picker
- Open a date picker
- Select a month
Link to minimal reproduction
https://www.naiveui.com/en-US/dark/components/date-picker
System Info
.
Used Package Manager
npm
Validations
- [X] Read the Contributing Guidelines.
- [X] Read the docs.
- [X] Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- [X] Check that this is a concrete bug. For Q&A open a GitHub Discussion.
- [X] The provided reproduction is a minimal reproducible example of the bug.
has not the same problem in my test maybe need more info
cant confirm this.
please open a code sandbox. and add your system info
I'm seeing the same problem. Tried with Chrome, Firefox and DuckDuckGo. All on a Mac running MacOS Sonoma:
The display of the months is off by one... if I click on "Jan" the month it gives me is "Feb". So the results are correct for the month's order in the list ... just the display is off by one. I see the problem with all of the examples at
https://www.naiveui.com/en-US/os-theme/components/date-picker
so reproduction for me is just go to that page and try to select a month. You'll (allegedly) see it if you go on the months list and scroll up.
Here's a sample video of the interaction right form the naiveui website:
https://github.com/tusen-ai/naive-ui/assets/25475/c61db867-8188-48b6-afea-65f0d861d3db
You can see that after I select a month, that the month is off by one.
As you can see, I made a pull request for the issue. The problem is a timezone/locale mismatch. The code was getting a UTC-based timestamp and then using a locale-based string. In my case, being in GMT-8 (US/Pacific), the computed time was 8 hours into the previous month. Folks in timezones at or ahead of GMT wouldn't see the bug.