-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Docs: Confusion in parse around YYYY vs yyyy #760
Comments
Thank you for the feedback! That is a valid point, that's very confusing. We migrated to the Unicode format as we believe that is better to follow a standard rather than a convention used in a (currently) popular library. |
Glad I found this. Did not understand why parse('17.07.2018, 'DD.MM.YYY') gave me => 17.07.2017 |
This also causes an issue when needing to manually format a date with a format string to get it to display in ISO format. You need to now escape the literal "T" in the ISO string format by wrapping it in single quotes (to escape it). Thus to get an ISO String out of format: yyyy-MM-dd'T'HH:mm:ss.sssX Edit: Would still be nice to have an 'ISO' format that spits out an ISO formatted string now that Unicode is what's used for format. The above is kinda messy. Yes, normally you'd want to just call .toISOFormat() but that's not possible with some React UI libraries, which only support a format string. |
There is what we're going to do to address the confusion about tokens:
|
Please see the PR that addresses the issue: #920 |
Hi all, great project.
I wanted to point out some behavior I found a bit confusing when checking out this library (specifically the latest 2.0.0-alpha.8).
ISO 8601 dates are generally referred to as
YYYY-MM-DD
. Here it is in the toISOString MDN docs. This is also the moment.js syntax for years, months, days.However I was confused, when doing:
With
YYYY-MM-DD
we get2017-01-18
With
yyyy-MM-DD
,yyyy-mm-dd
andyyyy-mm-DD
we seem to get2018-01-18
(not sure why)With
yyyy-MM-dd
we get the correct2018-05-18
I did a little reading up on the specs to try to understand what was going on where / the difference between YYYY & yyyy. This is the best source I came across.
I'm not sure if there's anything to change here, other than to point out it can be very confusing for folks unfamiliar with the unicode format, and it'd be worth putting in bold somewhere that if you aren't sure, you probably don't want YYYY, as it's of little use outside of the context of weeks of a year, e.g. Week 1 of 2018.
A console warning might even be nice for
YYYY-MM-DD
specifically, as it's quite common elsewhere.The text was updated successfully, but these errors were encountered: