date-picker-svelte
date-picker-svelte copied to clipboard
[Feature request] Add more formats for the input
Hi, thank for the lovely library. I love it so much. Is there any way to add more formats for the input?
I got that format on the moment's doc
Would happily accept a PR for it
Also there is currently no support for single digit hours, only two digits.
I added several options in parse.ts
, but this does not seem to work: When entering any value, the date picker presents the format as value. For example, if I specify as format d/M/yy
, it displays this exact format rather than the value.
I am not familiar with the code of this component and have a trouble understanding its logic. If someone can point me to some direction that would be great, otherwise it is a dead end for my attempt to solve this.
There's two parts to it, createFormat()
which parses the format
into FormatToken[]
, and parse()
which parses dates using the FormatToken[]
s.
I'm not sure how variable-length format tokens should be handled. How would yymd
parse 23111
- 23-11-1
or 23-1-11
?
About the parsing of yymd
, I'd be ok with calling it undefined behavior and parsing it however is easiest (which is probably 23111
-> 23-11-1
)