Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upfeat(common): Add ISO week-numbering year formats support to formatDate #38828
Conversation
…r formats support to formatDate' Merged similar code.
|
@prashant-tholia Can you also fix the linting issues? The file is not formatted. You can format the file using:
|
…ng year formats support to formatDate' Fix formatting issues
|
Done. |
|
Great work thanks @prashanttholia. Can you squash all the commits into one? Normally one does add additional commits to update after a review but they need to be "fixup" commits, which our merge script will automatically squash. But since your commits are not fixups then you might as well do the squashing too. |
Fix comment formatting
|
Thanks a lot, @petebacondarwin! I have a query - At present, for 'r' formats, I have passed useISOFormat parameter as true to the getThursdayThisWeek function, making it an ISO 8601 implementation. Wheras, the implementation for the formats 'w' & 'W' is a non-ISO one. This could give results which are in themselves inconsistent for format patterns such as 'rrrr ww'. I request you to let me know whether I should change implementation for 'r' format to use non-ISO as well? I also wanted to mention that I had worked on ISO implementation of 'w' & 'W' formats as well. So, in case you choose to make the implementation consistent using ISO 8601, I can commit it right away. |
|
Thanks for additional changes @prashanttholia |
Hmm, If I understand correctly the difference is that our current algorithm assumes that the week starts on Sunday, whereas the ISO spec (?) has it starting on Monday. Correct? I think that perhaps what we should have is a backward compatible consistent mode (i.e. But in the meantime, I "think" that for consistency we should start with the backward compatible mode for both |
I think we may consider introducing a new token (similar to
Agree, I think we should have the version that'd be consistent with the current implementation and introduce ISO-based transformation later as a new feature. |
…plementation to use non ISO week by default Week numbering year implementation update
ba74534
to
a336319
|
@petebacondarwin @AndrewKushnir , updated to make it backward compatible and consistent. |
|
Hi, I'm not able to figure out what is causing the check failure. I request for help. |
|
It looks like a couple of ngcc workers crashed, which then probably caused the later failure. I've restarted the job. |
|
Thanks. |
2a781cf
to
a33de4c
|
Thanks for the updates @prashanttholia The changes look good, I've also started tests in Google's codebase and will keep this thread updated. |
|
Thanks, @AndrewKushnir. I'll look forward to the updates. |
|
Hi @prashanttholia, the tests in Google's codebase went well and this PR has the necessary approvals now, so I'm adding this PR to the merge queue. Thanks for contributing to Angular framework! |
|
Thanks @AndrewKushnir! I'm glad to know that the PR is being added to the merge queue. Thanks @petebacondarwin for the opportunity to contribute! |


Add ISO 8601 week-numbering year formats ('r', 'rr', 'rrr', 'rrrr') support for formatDate function.
Issue:#38739
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
No current behavior. New feature.
Issue Number: 38739
What is the new behavior?
Examples -
formatDate('2013-06-14', 'rrrr', 'en') //'2013'
formatDate('2013-12-29', 'rrrr', 'en') //'2013'
formatDate('2013-12-31', 'rrrr', 'en') //'2014'
formatDate('2010-08-04', 'rrrr', 'en') //'2010'
formatDate('2010-01-02', 'rrrr', 'en') //'2009'
formatDate('2010-01-04', 'rrrr', 'en') //'2010'
Does this PR introduce a breaking change?