[feature] Support add(n, 'isoweek') and subtract(n, 'isoweek') #4518
Closed
Description
Description of the Issue and Steps to Reproduce:
Currently adding or subtracting 'isoweek' from a moment returns the same moment:
> m = moment()
moment("2018-03-28T13:12:35.901")
> m.add(1, 'isoweek')
moment("2018-03-28T13:12:35.901")
It would be convenient if isoweek was aliased to week in this use case so that the following would be returned:
> m = moment()
moment("2018-03-28T13:12:35.901")
> m.add(1, 'isoweek')
moment("2018-04-04T13:12:35.901")
The reason behind the request is that frequently have to "chunk" time series data by a user provided period (such as a week). moment.js makes it very simple to find the start of a chunk by doing something like moment(timestamp).startOf(period)
. However, if the period is isoweek, I can not simply calculate the next chunk as usual via moment.add(1, period)
since this will return the same timestamp and not a timestamp 1 week in the future.
Environment:
Node.JS 8.9.4 on Ubuntu 16.0.4