Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Date binding misbehaves (probably depending on locale) #7897

Closed
tosinek opened this issue Sep 27, 2022 · 1 comment · Fixed by #10616
Closed

Date binding misbehaves (probably depending on locale) #7897

tosinek opened this issue Sep 27, 2022 · 1 comment · Fixed by #10616

Comments

@tosinek
Copy link

tosinek commented Sep 27, 2022

Describe the bug

Date binding input type=date bind:value={date} is broken if system locale (at least on Windows) is not set to MM/DD/YY (so it is broken for DD/MM/YY or YY/MM/DD), especially when editing an existing date.

I tested Chrome, Edge and Firefox.

Using on:input={e => date=e} or on:change will not work either.

Reproduction

With locale DD/MM/YYYY, the most annoying case is when you type "0" (for 01) in days or months, it resets the whole field (if there is an existing date already).

REPL with examples:
https://svelte.dev/repl/594639752b464fdc8ad7cc2d50f3d499?version=4.2.8

Logs

No particular logs, in some cases I was able to make it log

The specified value "[object Event]" does not conform to the required format, "yyyy-MM-dd".
prop_dev	@	VM233:350
update	@	VM233:426
update	@	VM233:177
flush	@	VM233:144
Promise.then (async)		
schedule_update	@	VM233:109
make_dirty	@	VM233:222
eval	@	VM233:260
change_handler	@	VM233:472

System Info

Windows 11, regional settings set to Czech. Newest Chrome and Firefox. Newest Svelte (from 3.55.1 up to 4.2.8)

Severity

annoyance

Workaround

As a workaround, use two variables instead of one.

<input type=date value={initialDate} on:change={handleDateChange}>
let otherDate
const handleDateChange = () => {
    otherDate = event.target.value
}
@tosinek
Copy link
Author

tosinek commented Dec 30, 2023

Can you please confirm this bug? (@Conduitry, I found you added such label to one of the issues). The latest repl:
https://svelte.dev/repl/594639752b464fdc8ad7cc2d50f3d499?version=4.2.8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant