-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
lib: Always use ISO format for date picker manual input #20668
lib: Always use ISO format for date picker manual input #20668
Conversation
Matrix conversation:
wrt. this PR:
This isn't just a bug, more of a mis-design. If both are invalid, we show it like this: Presumably to avoid the strings becoming too long and not fitting next to each other? So let's do this as a follow-up, see issue #20669 |
PatternFly's DatePicker's textual date input defaults to ISO format (YYYY-MM-DD), for a good reason: it's unambiguous, and localized date input is really hard and brittle. This is also broken for e.g. en-UK: British date format is DD/MM/YY, while US date format is MM/DD/YY, but we don't have UI to switch between English countries. It was also broken for the manual time setting dialog, where the initial formatting of the date resulted in a format that the dialog didn't accept. So give up, and use the default (i.e. ISO) format and parser. Also drop the custom time/date format function in serverTime.js, and use our standard `timeformat.dateTime()` (which has the same output format). Fixes cockpit-project#19091 [1] https://www.patternfly.org/components/date-and-time/date-picker
Nothing uses this any more, and that's the date-fns API which is really hard to replace (see issue cockpit-project#20653)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice cleanup, thanks!
PatternFly's DatePicker's textual date input defaults to ISO format
(YYYY-MM-DD), for a good reason: it's unambiguous, and localized date
input is really hard and brittle.
This is also broken for e.g. en-UK: British date format is DD/MM/YY,
while US date format is MM/DD/YY, but we don't have UI to switch between
English countries.
It was also broken for the manual time setting dialog, where the initial
formatting of the date resulted in a format that the dialog didn't
accept.
So give up, and use the default (i.e. ISO) format and parser. Also drop
the custom time/date format function in serverTime.js, and use our
standard
timeformat.dateTime()
(which has the same output format).Fixes #19091
[1] https://www.patternfly.org/components/date-and-time/date-picker
It previously looked like this in English (scheduled shutdown time):
And now like this, in all languages (it's not an off-by-one, I changed the day to tomorrow):
When emptying the input you see the corresponding input helper:
And for the LOLz, the buggy default dialog value for manually setting the server date on main. With this PR, it's the same ISO format as above:
I suppose this only didn't get a bug report because nobody actually does that..
When people say "hard times" I didn't realize what they mean.. 😅