Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
682 views
in Technique[技术] by (71.8m points)

momentjs - Difference between week of year and week of year ISO tokens (moment.js)

I was studying date formating in moment.js and I came across these tokens: Is there any significant difference between WoY and WoY ISO?

Week of Year

w - 1 2 ... 52 53  
wo - 1st 2nd ... 52nd 53rd  
ww - 01 02 ... 52 53

Week of Year (ISO)

W - 1 2 ... 52 53  
Wo - 1st 2nd ... 52nd 53rd  
WW - 01 02 ... 52 53
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

According to Wikipedia, the ISO week counter starts the first thursday of the year; so, if the first day of the year is saturday, the first thursday will be in the next week.

Thus, the ISO week of the first thursday will be the first, but the standard week of the first thursday will be the second, e.g.

moment('2005-01-02').isoWeek(); // 53
moment('2005-01-02').week(); // 1
moment('2005-01-03').isoWeek(); // 1
moment('2005-01-03').week(); // 2

Regards!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...