odontech/localdate

function addYears() should check isValid date

Opened this issue · 0 comments

LocalDate.prototype.addYears = function (years) { return new LocalDate(this.year + years, this.month, this.day); }

For example, new LocalDate(2000,2,29).addYears(1) will be 2001-02-29 which is not a valid date(2001 is not a leap year). It may be 2001-02-28 which is compared with adding months function.

When adding months, if the original day of the month is greater than the number of days in the final month, the day will become the last day in the calculated month.

Thanks for the excellent js lib.