Skip to content
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

Add format of ISO week-numbering year #38739

Open
wenqi73 opened this issue Sep 8, 2020 · 7 comments
Open

Add format of ISO week-numbering year #38739

wenqi73 opened this issue Sep 8, 2020 · 7 comments

Comments

@wenqi73
Copy link

@wenqi73 wenqi73 commented Sep 8, 2020

🚀 feature request

Relevant Package

This feature request is for @angular/common

Description

formatDate(new Date(2018, 11, 31), 'yyyy-ww', 'en-US')
// 2018-01

Week is right but year is wrong.

Describe the solution you'd like

Add an ISO week-numbering year like rrrr.

formatDate(new Date(2018, 11, 31), 'rrrr-ww', 'en-US')
// 2019-01

Here is the reference of date-fns.

Describe alternatives you've considered

@wenqi73 wenqi73 changed the title Add ISO week-numbering year Add format of ISO week-numbering year Sep 8, 2020
@ngbot ngbot bot added this to the Backlog milestone Sep 8, 2020
@petebacondarwin
Copy link
Member

@petebacondarwin petebacondarwin commented Sep 8, 2020

Normally I am cautious about adding new functionality but I think that this case could be an exception. Since we are already doing the calculations for the week numbering, it is probably not too much more to compute the "week year".

This might be a good first time PR for someone... 🤔

@prashanttholia
Copy link
Contributor

@prashanttholia prashanttholia commented Sep 10, 2020

Hi, I'd like to work on this issue.

@petebacondarwin
Copy link
Member

@petebacondarwin petebacondarwin commented Sep 10, 2020

@prashant-tholia - great! Please make sure you have read https://github.com/angular/angular/blob/master/CONTRIBUTING.md.
The PR will need to include unit tests and documentation before it can be merged.

Let me know if you need help getting started.

@prashanttholia
Copy link
Contributor

@prashanttholia prashanttholia commented Sep 10, 2020

Thanks @petebacondarwin! I'll make sure to fulfill all mentioned guidelines and requirements.

@irzakamran
Copy link

@irzakamran irzakamran commented Sep 10, 2020

Hello, can I also be work on this issue with @prashant-tholia since this is a good first issue and I am an open source beginner.

orab added a commit to orab/angular that referenced this issue Sep 12, 2020
Add support to format iso week-numbering year with 'r' in dateFormat
string template.

PR angular#38739
@orab orab mentioned this issue Sep 12, 2020
5 of 14 tasks complete
orab added a commit to orab/angular that referenced this issue Sep 12, 2020
Add support to format iso week-numbering year with 'r' in dateFormat
string template.

PR angular#38739
prashanttholia added a commit to prashanttholia/angular that referenced this issue Sep 12, 2020
Add ISO 8601 week-numbering year formats ('r', 'rr', 'rrr', 'rrrr') support for formatDate function.

Issue:angular#38739
prashanttholia added a commit to prashanttholia/angular that referenced this issue Sep 15, 2020
Add ISO 8601 week-numbering year formats ('r', 'rr', 'rrr', 'rrrr') support for formatDate function.

Issue:angular#38739
prashanttholia added a commit to prashanttholia/angular that referenced this issue Sep 15, 2020
Add ISO 8601 week-numbering year formats ('r', 'rr', 'rrr', 'rrrr') support for formatDate function.

Issue:angular#38739
prashanttholia added a commit to prashanttholia/angular that referenced this issue Sep 18, 2020
Add ISO 8601 week-numbering year formats ('r', 'rr', 'rrr', 'rrrr') support for formatDate function.

Issue:angular#38739
prashanttholia added a commit to prashanttholia/angular that referenced this issue Sep 18, 2020
Add ISO 8601 week-numbering year formats ('r', 'rr', 'rrr', 'rrrr') support for formatDate function.

Issue:angular#38739
prashanttholia added a commit to prashanttholia/angular that referenced this issue Sep 19, 2020
Add ISO 8601 week-numbering year formats ('r', 'rr', 'rrr', 'rrrr') support for formatDate function.

Issue:angular#38739
prashanttholia added a commit to prashanttholia/angular that referenced this issue Sep 19, 2020
Add ISO 8601 week-numbering year formats ('r', 'rr', 'rrr', 'rrrr') support for formatDate function.

Issue:angular#38739
prashanttholia added a commit to prashanttholia/angular that referenced this issue Sep 19, 2020
Add ISO 8601 week-numbering year formats ('r', 'rr', 'rrr', 'rrrr') support for formatDate function.

Issue:angular#38739
mhevery added a commit that referenced this issue Sep 21, 2020
…te (#38828)

Add ISO 8601 week-numbering year formats ('r', 'rr', 'rrr', 'rrrr') support for formatDate function.

Issue:#38739

PR Close #38828
@rubenprins
Copy link

@rubenprins rubenprins commented Oct 2, 2020

@prashanttholia, Not to be pedantic or anything, but I think the 'r' placeholder is a mistake here. CLDR/Unicode defines this in http://www.unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table as

Related Gregorian year (numeric). For non-Gregorian calendars, this corresponds to the extended Gregorian year in which the calendar’s year begins. Related Gregorian years are often displayed, for example, when formatting dates in the Japanese calendar — e.g. “2012(平成24)年1月15日” — or in the Chinese calendar — e.g. “2012壬辰年腊月初四”. The related Gregorian year is usually displayed using the "latn" numbering system, regardless of what numbering systems may be used for other parts of the formatted date. If the calendar’s year is linked to the solar year (perhaps using leap months), then for that calendar the ‘r’ year will always be at a fixed offset from the ‘u’ year. For the Gregorian calendar, the ‘r’ year is the same as the ‘u’ year. For ‘r’, all field lengths specify a minimum number of digits; there is no special interpretation for “rr”.

The ISO week year is actually 'Y', 'YY', 'YYY', 'YYYY', etc.:

Year in “Week of Year” based calendars in which the year transition occurs on a week boundary; may differ from calendar year ‘y’ near a year transition. This numeric year designation is used in conjunction with pattern character ‘w’ in the ISO year-week calendar as defined by ISO 8601, but can be used in non-Gregorian based calendar systems where week date processing is desired. The field length is interpreted in the same was as for ‘y’; that is, “yy” specifies use of the two low-order year digits, while any other field length specifies a minimum number of digits to display.

@prashanttholia
Copy link
Contributor

@prashanttholia prashanttholia commented Oct 5, 2020

@rubenprins, I apologize for the late response. I think that formats should be consistent with or as close as possible to the standard. I agree that 'Y' would be a more appropriate choice to represent week numbering year.

@petebacondarwin, please let us know what you think and whether it needs to be updated?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
6 participants
You can’t perform that action at this time.