SwiftMoment icon indicating copy to clipboard operation
SwiftMoment copied to clipboard

Unexpected value when adding months.

Open ghost opened this issue 8 years ago • 1 comments

When trying to add months to an instance of Moment I get an unexpected value. I would expect the following example to return an instance of Moment representing the 1st of June 2016 but instead it returns 31st of May 2016.

    let beginOfMonth = moment([2016, 5, 1, 0, 0, 0])!
    let nextMonth = beginOfMonth.add(1, .Months))

Wouldn't it make more sens to add value to the Month component of NSDate using NSDateComponents instead of simply adding 30 days?

ghost avatar Jun 04 '16 10:06 ghost

Valid point, but right now this is the behavior by design in the current version of the library. I will address this in a future release. Thanks!

akosma avatar Jun 06 '16 15:06 akosma