moment-hijri icon indicating copy to clipboard operation
moment-hijri copied to clipboard

Add month wrong date

Open Dejmek opened this issue 7 years ago • 2 comments

Sometimes changing month returns wrong date. It happens only if current date is first day in month.

moment.format("iYYYY/iMM/iDD"); // "1438/05/01"
moment.iMonth(5);
moment.format("iYYYY/iMM/iDD"); // "1438/06/29"

Next same event is in 1441

Dejmek avatar Oct 28 '16 12:10 Dejmek

Also happens when calling "endOf('iMonth')".

ronrother avatar Nov 23 '16 16:11 ronrother

Also when subtracting month

const moment = require("moment-hijri");
moment.locale('en-EN')
const today = moment("2018-03-29"); 
console.log("Today:", today.format("iDD/iMM/iYYYY")); // Today: 12/07/1439
const monthAgo = today.add(-1, "iMonth");
console.log("Month ago:", monthAgo.format("iDD/iMM/iYYYY")); // Month ago: 11/07/1439

Seems that happens with non leap years

antikh avatar Mar 29 '18 12:03 antikh