xsoh/moment-hijri

moment().endOf('hUnit') is not working ..

MhdSyrwan opened this issue ยท 3 comments

Hi,
Thank you very much for making this plugin ๐Ÿ‘ .
I'm trying to execute this line (from the readme)

moment('2014-11-28 16:40:00', 'YYYY-M-D HH:mm:ss').endOf('hMonth').format('hYYYY/hM/hD HH:mm:ss'); // 1436/2/30 23:59:59

it doesn't give the result mentioned in the comment 1436/2/30 23:59:59 and also tried many variants, it looks like endOf method is not affecting the date if given hmounth or hyear or anything outside the standard moment units.

Any thoughts about this ?

After looking at the original code of moment here i tried doing it manually like

moment('2014-11-28 16:40:00', 'YYYY-M-D HH:mm:ss').startOf('hmonth').add(1, 'hmonth').subtract(1, 'milliseconds').format('hYYYY/hM/hD HH:mm:ss'); // 1436/2/30 23:59:59

And it worked ! ๐Ÿ˜„

It seems that there's a problem running normalizeUnits or it could be solved by adding a definition for the method endOf in this repo just like what have you done for the startOf here

Issue fixed!
Thanks!

Thanks for your quick response ๐Ÿ‘