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

moment.HTML5_FMT.WEEK should be 'GGGG-[W]WW' #4698

Closed
jacquev6 opened this issue Jul 12, 2018 · 2 comments
Closed

moment.HTML5_FMT.WEEK should be 'GGGG-[W]WW' #4698

jacquev6 opened this issue Jul 12, 2018 · 2 comments

Comments

@jacquev6
Copy link

The current value of HTML5_FMT.WEEK is "YYYY-[W]WW" but this format is supposed to parse and format ISO weeks. It should be "GGGG-[W]WW".

When parsing, YYYY is equivalent to GGGG, but when formatting, it's not : for a year like 2004 when the first ISO week starts in the previous year, formatting with "YYYY" returns "2003":

moment("2004-W01", moment.HTML5_FMT.WEEK).format(moment.HTML5_FMT.WEEK) === "2003-W01"
moment("2004-W01", "GGGG-[W]WW").format("GGGG-[W]WW") === "2004-W01"
@ashsearle
Copy link
Contributor

@jacquev6 Well spotted! Thanks for logging the issue :-)

ashsearle added a commit to ashsearle/moment that referenced this issue Oct 31, 2018
ashsearle added a commit to ashsearle/moment that referenced this issue Oct 31, 2018
marwahaha pushed a commit that referenced this issue Dec 13, 2018
* [bugfix] Fix #4698: Use ISO WeekYear for HTML5_FMT.WEEK

* [bugfix] Fix #4698: Added regression tests
@Safirion
Copy link

Safirion commented Apr 19, 2020

Documentation is not up to date : https://momentjs.com/docs/#/parsing/string-format/

image

It indicate YYYY instead of GGGG

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

No branches or pull requests

4 participants