xsoh / moment-hijri

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

Parse logic doesn't match format logic #49

Closed mdentremont closed 2 years ago

mdentremont commented 5 years ago
import * as momentHijri from 'moment-hijri'

momentHijri.locale('ar-SA')
momentHijri(momentHijri().format('iYYYY/iMM/iDD'), 'iYYYY/iMM/iDD').isValid()

Running this code returns false for me --- I would expect to be able to parse a value using the same format string used to generate it. Looking at the code, it might be because the parse logic isn't handling the Arabic numerals, ie: with my above format string, the parse would only handle '1111-11-11' format.

SalahAdDin commented 2 years ago

@mdentremont How did you fix this bug?

mdentremont commented 2 years ago

I have since left the company which used this code, so given the age and also that I can't test I closed it :(