Closed barneycarroll closed 9 years ago
I'm sorta surprised it doesn't work, actually. The way it should work is to use
moment("2014-01-01").twix("2015-01-01").iterate("W");
It doesn't work, though; it just gets stuck at the beginning of the first 2014 ISO week (Dec 30, 2013) and stays there. The proximal reason is this:
> moment("2014-01-01").startOf("W").format()
'2013-12-30T00:00:00-05:00'
> moment("2014-01-01").startOf("W").add(1, "W").format()
'2013-12-30T00:00:00-05:00'
In other words, adding a week has no effect, and under the covers, that's all next()
does: repeatedly add the time unit. I'm not really involved in the day-to-day of the Moment project, but if you can get it fixed in Moment itself, I suspect it will Just Work in Twix.
I also noticed that iterateInner
doesn't work with "W" either. This is because Moment's durations don't support it:
> moment.duration(100).get("W")
TypeError: Property 'isoweeks' of object PT0.1S is not a function
So again, upstream Moment issue.
I suspected as much. I'll go and pester Moment and comment here when I get a resolution. Thanks for looking in!
I'd like to be able to iterate by ISO week. How non-trivial is this, given moment's isoWeek support?