-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
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
[DatePicker] Default to ISO-8601 DateTimeFormat & firstDayOfWeek #3417
Conversation
path.resolve(__dirname, '../src/svg-icons'), | ||
], | ||
}, | ||
|
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.
Yeah, let's kill this 😁.
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.
I couldn't find a way to just output warnings without blocking the build.
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.
I wanted to try to make it optional, but then I see it doesn't work well with docs either, so: npm start
!== npm run lint
. Let's kill it before it lays eggs 🙀
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.
Yeah, let's kill this 😁.
Oops! Must have git commit -am
after carefully adding the individual files.
If you;re serious about killing this though, I'll leave it. 👍
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.
Count me in 👿 🔫 😎
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.
I decided to put it back, and I'll kill it in a separate PR, as we reference it in contributing.md
, so a separate PR will be cleaner as I can edit that at the same time. When I do, should I remove the whole preloaders
section, or leave it empty for future reference?
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.
I'd say remove it. like how we should remove unused vars. less clutter = less confusion 👍
Okay, moved the ISO date formatter to DateTime.format, which also solves the docs issue. The linter is throwing a fit though... |
@mbrookes That looks good so far 👍. Side question. What are we going to do with the documentation? Is this ok to have |
Good point. Well, we no longer need to change the |
/> | ||
<DatePicker | ||
hintText="en-US version" | ||
formatDate={(date) => date.toLocaleDateString()} |
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.
While toLocaleDateString()
doesn't reliably convert the date to the user's locale across all browsers (some return US date format regardless), it should reliably show US date format for US users. Is that sufficient?
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.
I don't get it, why can't we use the default formatDate
?
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.
Because the default is ISO 8601? That's kind of the point of this PR. 😉
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.
Good point! So, what about
new DateTimeFormat('en-US', {
day: 'numeric',
month: 'numeric',
year: 'numeric',
}).format(date) // 2/25/2016
``
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.
But I can use your DateTimeFormat example as a safer alternative to date.toLocaleDateString()
.
What do you think about the idea of modifying Alternatively / additionally, what if we internalised that, so that |
I don't really mind. This has advantages and drawbacks. |
What drawbacks specifically? Also:
Any thoughts? |
This new
That sounds like an excellent idea. I wouldn't say it's a breaking changes, I see more this like an improvement. That would also make our i18n examples simpler 👍. |
Exactly! 👌 (I realised when I started to update the examples...) |
I've added localised formatting. I also coded up adding Does that make sense? |
// Use the native Intl if available | ||
/** | ||
* Use the native Intl.DateTimeFormat if available, or a polyfill if not. | ||
*/ | ||
if (areIntlLocalesSupported('fr')) { |
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.
if (areIntlLocalesSupported(['fr', 'en-US'])) {
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.
How did I miss that?! Although when I tested in Safari, which is the only mainstream desktop browser that doesn't support Intl
, it worked fine (presumably since it's a binary condition).
Anyway, good catch (as always!). Updating now.
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.
Well, that's not a big deal. I'm pretty sure that if fr
is available, en-US
is also available.
That's the complexity I was talking about 😁. @mbrookes Could you have a look at my comment? Otherwise, that looks awesome 👍! |
Updated. Thanks! |
Could you squash down? |
Done. 👍 |
This was a great work @mbrookes 👍 👍 Thanks a lot 😁 |
[DatePicker] Default to ISO-8601 DateTimeFormat & firstDayOfWeek
Closes #1839 #2980.