You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This means if the programmer provides a date string without time, such as '2024-02-29', this function will use the UTC midnight, which will lead to problems in various internal date comparisons against other local timestamps, as well populating the datepicker grid itself, especially in min/max mode which uses
This may be one of the underlying issues in #589, #544, #504, #462, and possibly others. In particular #589 illustrates a divergence between ill- and well-formatted date/time strings as they use different Date() constructors mentioned above.
The best solution probably is to extract year, month ... from date so all internal calls uses new Date(year, month ...) syntax. This enables _createMinMaxDates above to use 00:00:00 for min, and 23:59:59 for max. The other solution is to get the programmer to supply a well-formatted timestamp in the user's timezone. But as a lazy programmer who just want to use a third-party datepicker, I like the first one better.
The text was updated successfully, but these errors were encountered:
In the meantime let date = new Date('2024-02-29'); date.setTime(date.getTime() + date.getTimezoneOffset() * 60 * 1000) will set a Date to midnight local time.
Basically,
Date(year, month ... )
is interpreted in local time butDate(string)
uses the timezone in the string and date strings without time resolves to UTCThis means if the programmer provides a date string without time, such as '2024-02-29', this function will use the UTC midnight, which will lead to problems in various internal date comparisons against other local timestamps, as well populating the datepicker grid itself, especially in min/max mode which uses
This may be one of the underlying issues in #589, #544, #504, #462, and possibly others. In particular #589 illustrates a divergence between ill- and well-formatted date/time strings as they use different
Date()
constructors mentioned above.The best solution probably is to extract year, month ... from
date
so all internal calls usesnew Date(year, month ...)
syntax. This enables_createMinMaxDates
above to use 00:00:00 for min, and 23:59:59 for max. The other solution is to get the programmer to supply a well-formatted timestamp in the user's timezone. But as a lazy programmer who just want to use a third-party datepicker, I like the first one better.The text was updated successfully, but these errors were encountered: