naive-ui icon indicating copy to clipboard operation
naive-ui copied to clipboard

Wrong first month in Date Picker

Open quevlu opened this issue 1 year ago • 2 comments

Describe the bug

Wron number months in date picker. January is twelve.

image

Steps to reproduce

  1. Go to https://www.naiveui.com/en-US/dark/components/date-picker
  2. Open a date picker
  3. Select a month

Link to minimal reproduction

https://www.naiveui.com/en-US/dark/components/date-picker

System Info

.

Used Package Manager

npm

Validations

quevlu avatar Feb 22 '24 23:02 quevlu

has not the same problem in my test maybe need more info

Th1Humble avatar Feb 23 '24 14:02 Th1Humble

cant confirm this.

image

please open a code sandbox. and add your system info

OrbisK avatar Feb 25 '24 10:02 OrbisK

I'm seeing the same problem. Tried with Chrome, Firefox and DuckDuckGo. All on a Mac running MacOS Sonoma:

Screenshot 2024-02-29 at 1 42 45 PM

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.

uzi avatar Feb 29 '24 21:02 uzi

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.

uzi avatar Mar 01 '24 00:03 uzi

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.

uzi avatar Mar 01 '24 02:03 uzi