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
week number is not compliant with ISO standard #613
Comments
Check out #503. We are adding |
You guys rule, thanks |
Reopening this issue because v2.0.0 still doesn't have it quite right. The ISO standard is to include the ISO week year. The above code example, ported to v2.0.0, looks like:
this now produces:
Notice, there are two bugs here. 1) An extra "W" is emitted. 2) the Year is not correct. It should be:
|
So you suggest we find a iso-week format token and modify an year token in the same string to match iso-week-related year? I guess we need iso-week-year to go in hand with the week number for all this to make sense. |
For the 'W' issue, use |
Regarding the ISO week year, we should probably add iso week year and iso week day. What about the following for the api? moment.fn.weekday // like moment.fn.day, but with the locale based week start
moment.fn.isoWeekday // like moment.fn.day, but with iso based week start
moment.fn.weekYear // locale based week year
moment.fn.isoWeekYear // iso based week year As for the tokens, that's where it gets messy. LDML uses For reference, strftime uses Maybe we could use For the day of the week, what about So the format that the OP would need would be |
@timrwood love the proposal for adding iso week year api methods. I figure if someone wants the week year in a formatted string, its likely that they will be building the entire ISO week-year format. Therefore, perhaps a single token for the ISO standard week-year format is enough? |
Hmm, adding a single token to mirror Additionally, if I'm reading the ISO standard correctly, the ISO week representation could be any of the following.
If you want, you could always add a method to the moment.fn.isoWeekFormat = function () {
return this.format('GGGG-[W]WW-E');
} |
@timrwood so you suggest we keep |
Just posting here in case my hack is useful to anybody. I'm working on a projects that uses the YYYY-WWW format, so have shoe-horned a fix for that into the latest moment.js that works with all the examples on the wiki page: http://en.wikipedia.org/wiki/ISO_week_date. And Is a pretty blunt hack onto the constructor and an additional output format, but does the trick for this specific case/format. |
The new release 2.1.0 supports (iso)?(week|weekday|weekyear) tokens/getters/setters. |
this is done |
Here is the the solution, for the correct week days order, since the last version of moment.js moment.weekdays(true); |
I found a bug today, assuming that
moment('Jan 1, 2005').format('YYYY-\\Www-d')
would follow the ISO 8601 standard. The code sample would return:but this is the expected output:
http://en.wikipedia.org/wiki/ISO_week_date#Examples
The text was updated successfully, but these errors were encountered: