localized date incorrectly submitted as part of <form>
See original GitHub issueI am trying to use duet-date-picker with Thymeleaf (server-side rendering). It works as long as I don’t use the localization support.
I added this in a <script>
tag in my page:
const picker = document.querySelector('duet-date-picker');
const DATE_FORMAT = /^(\d{1,2})\.(\d{1,2})\.(\d{4})$/;
if (picker) {
picker.dateAdapter = {
parse(value = '', createDate) {
try {
console.log('parsing' + value);
const matches = value.match(DATE_FORMAT);
if (matches) {
return createDate(matches[3], matches[2], matches[1]);
}
} catch (err) {
console.log(err);
}
},
format(date) {
console.log('formatting: ' + date);
return `${date.getDate()}.${date.getMonth() + 1}.${date.getFullYear()}`;
},
};
}
I see lot’s of formatting...
statements, but never parsing...
and also no error in the console.
When I check with dev tools, I see updates to the value
attribute of <duet-date-picker>
, but the value
of the actual <input>
is not updated. Due to this, my server-side thinks that nothing was selected. For some reason, that does not seem to be an issue when not using the localization support. Am I doing something wrong?
Issue Analytics
- State:
- Created 3 years ago
- Comments:18 (9 by maintainers)
Top Results From Across the Web
Date formatting - Incorrect Locale - Power Platform Community
Solved: I have a form field, which is autopopulated by the variable 'd1', which is initialized this way: Set(d1,Text( Today(), "[$-en-US]dd ...
Read more >Wrong date format when submit Spring form - Stack Overflow
My problem is that the date input is in a form, and when I submit the form, it doesn't take the good format....
Read more ><input type="datetime-local"> - HTML - MDN Web Docs
The problem is with the client side of things: parsing of dates with more than 4 digits in the year. <!--midnight of January...
Read more >Date and time localization - Lokalise Blog
Date time localization is done different ways in different languages. Let's see how to do it in five popular programming languages.
Read more >Demystifying DateTime Manipulation in JavaScript - Toptal
You can then format it to extract only the date part as follows: ... "7/22/2016, 04:21 AM", Display localized date and time based...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I can confirm it works with version 1.1.0. Thanks for the bugfix!
Sorry, this fell through the net. I’ll see if i can get a PR together tomorrow