Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parse logic doesn't match format logic #48

Closed
mdentremont opened this issue May 23, 2019 · 3 comments
Closed

Parse logic doesn't match format logic #48

mdentremont opened this issue May 23, 2019 · 3 comments

Comments

@mdentremont
Copy link

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
Copy link

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

@talal424
Copy link

#47

@soheils2
Copy link

hi can you add this to Readme? that can Help other people who dont want arabic numbers as default setup!
tnx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants