Closed moses-seeq closed 8 years ago
+1
Sorry for the delay on this... changed my notification settings for my new job back in March and I've missed a lot of stuff on this project.
You're expecting to be able to convert from duration months to duration milliseconds and back again. It's not my plugin doint this; Moment.Duration itself doesn't work like that.
moment.duration(2 * (moment.duration(1, 'months').valueOf())).asMonths();
// 1.9712930450317254
Interesting to note, Moment itself has modified this behaviour. Back in Moment 2.4, moment.duration(2 * (moment.duration(1, 'months').valueOf())).asMonths();
returned 2
. The current Moment version returns 1.97...
I remember about a year ago helping with some issues around revamped Durations... pretty sure this change was a side-effect of their Duration revamp, and entirely intentional.
moment.duration(2 * (moment.duration(1, 'months').valueOf())).format('M d') resolves to: 1 30 00:00:00.000 instead of 2 0 00:00:00.000.
moment.duration(3 * (moment.duration(1, 'months').valueOf())).format('M d') resolves to: 2 29 00:00:00.000 instead of 3 0 00:00:00.000.
Months need to be calculated in the same way that they are in Moment for consistency.