date-picker-svelte icon indicating copy to clipboard operation
date-picker-svelte copied to clipboard

[Feature request] Add more formats for the input

Open Foxeye-Rinx opened this issue 1 year ago • 5 comments

Hi, thank for the lovely library. I love it so much. Is there any way to add more formats for the input?

image

I got that format on the moment's doc

Foxeye-Rinx avatar Sep 05 '22 16:09 Foxeye-Rinx

Would happily accept a PR for it

probablykasper avatar Sep 05 '22 16:09 probablykasper

Also there is currently no support for single digit hours, only two digits.

Razunter avatar Jan 25 '23 17:01 Razunter

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.

Wtower avatar Jun 24 '23 05:06 Wtower

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?

probablykasper avatar Jun 24 '23 10:06 probablykasper

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)

probablykasper avatar Sep 23 '23 21:09 probablykasper