xsoh / moment-hijri

A Hijri calendar (Based on Umm al-Qura calculations) plugin for moment.js
http://momentjs.com/docs/#/plugins/hijri/
MIT License
200 stars 82 forks source link

Parsing using iMMM returns incorrect date (off by one month) #60

Open smartphonedesign opened 3 years ago

smartphonedesign commented 3 years ago

When parsing the month from iMMM format it uses a one-based index. So, Shw is month 10, but then it converts it to the Gregorian equivalent using zero-based index and so it is off by one month.

    const input = '22 Shw 1440';
    const output = moment(input, 'iDD iMMM iYYYY').format('iDD iMMM iYYYY');
    if (input !== output) {
        console.log(`${input} returned ${output}`);
    }

output is "22 Shw 1440 returned 22 Dhu-Q 1440"