-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
selectDate #589
Comments
A workaround is let localDate = new Date(date)
localDate.setDate(localDate.getUTCDate())
datepicker.selectDate(localDate) This basically adds 24 hours when local date is one less than UTC date. |
Hi! Yeah, it seems like a problem =(. Thank you for a bug report, I'll see what I can do about it. |
It is not good idea, because you will get wrong dates in edge cases, when, for example, your date is '2024-03-01' you will get '2024-02-01` instead of what you'd expect. |
* #87 - added option to have same weeks count in every month * #87 - added description for `fixedHeight` option * #568 - fixed time change in same range dates, fixes #568 * #556 - added `disableDate` method * #556 - added tests for `disableDate` method, added docs for new methods * bumped up node version in docs package.json * #589 - added conversion from date-only string to local date * fixed wrong css class handling * added `silent` params in `update` method, wrote CHANGELOG * change CHANGELOG.md * fixed locale generation * fixed eu locale default export * bump version 3.5.0
Problem
selectDate()
behaves differently depending on whether the input is properly formatted or not. This leads to a properly formatted input date goes to previous day when system timezone is west of UTC +0.Background
I want the user to be able to enter a day on keyboard, and the datepicker should highlight that day. This works with a malformed date, such as
2024-2-26
. But if the value is instead2024-02-26
, it converts2024-02-26T00:00:00.000Z
to my local timezone in the Americas, then show '2024-02-25'. This occurs with everyfocusin
andfocusout
of the fie, either by mouse or by tabbing. I am only working with date, and it seems to be the same regardless what I put forupdateTime
, or whether I wrap the '2024-02-26in a
new Date()`.Reproduction
I couldn't quite get css to work in stackblitz, but you can 1) change system timezone to any Americas timezone and 2) go to https://stackblitz.com/edit/sveltejs-kit-template-default-uzophc?file=src%2Froutes%2F%2Bpage.svelte. 3) observe the differences between typing in
2024-02-26
and2024-2-26
.The text was updated successfully, but these errors were encountered: