Parse logic doesn't match format logic
mdentremont opened this issue · 3 comments
mdentremont commented
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.
talal424 commented
i don't think preparse()
has any effect on this situation
this should do trick if you don't need Arabic numerals
import * as momentHijri from 'moment-hijri'
momentHijri.locale('ar-SA')
momentHijri.updateLocale('ar-sa', {
postformat: string => string
})
momentHijri(momentHijri().format('iYYYY/iMM/iDD'), 'iYYYY/iMM/iDD').isValid() //true
soheils2 commented
hi can you add this to Readme? that can Help other people who dont want arabic numbers as default setup!
tnx