You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
That's the expected result. startOf('year') means the start of the calendar year, not the week year, so it's the same in every location (we don't support alternative calendars and en-gb would use a Gregorian calendar anyway). In fact, startOf('year') is redundant here because moment([2016]) already returns Jan 1.
You may know this, but what doy does is change how the weeks are numbered, because the week year doesn't start at the same time as the calendar year. The way it works is that week 1 is the week that includes the first instance of doy that's in the new calendar year. Jan 1, 2016 is a Friday, so in the US (doy = 6 = Saturday), we look for the first Saturday in the calendar year (Jan 2), and call the week that includes it week 1. So that's the week starting on the previous Sunday (because dow=0), which is Dec 27. Thus Jan 1 is in week 1. In the UK, doy = 4, so we look for the first Thursday of the calendar year (which is Jan 7), and call that the first week. So week 1 starts on Jan 4, because dow=1. Thus Jan 1 is in the final week of the previous week year.
It sounds like you may be looking for something like moment([2016]).startOf('week-year'), which doesn't exist.
Shouldn't be the second one result in
1
too?Or it's at least that, what i'm semantically expect from the code.
The text was updated successfully, but these errors were encountered: