Skip to content
This repository has been archived by the owner on May 21, 2019. It is now read-only.

shortTime parser not working in Chinese language #49

Open
tkarthick81 opened this issue Apr 24, 2017 · 3 comments
Open

shortTime parser not working in Chinese language #49

tkarthick81 opened this issue Apr 24, 2017 · 3 comments
Labels

Comments

@tkarthick81
Copy link

timeString : 上午12:00
on calling the below line with the time return invalid time
$dateParser(timeString, 'shortTime')

@dnasir
Copy link
Owner

dnasir commented Apr 24, 2017

@tkarthick81 can you post a jsfiddle or a plnkr so I can test this out?

@tkarthick81
Copy link
Author

Hello @dnasir

Find below the plnkr sample.
https://plnkr.co/edit/BaAkwKsVwesmpLhu5Gnf

In this first text box is the sample Chinese time format,
Second one is verifying time in English time format
Third is verifying time in Chinese time format, which returns undefined

@dnasir
Copy link
Owner

dnasir commented Apr 28, 2017

@tkarthick81 I realised there is a small bug that needs fixing. But one issue with your code is that you're trying to use a locale that hasn't been loaded when you called the $dateParser() method. It takes some time to load and the best thing to do here is to simply load the locale file up front.

Another thing to consider is that $dateParser will use whatever locale is currently set within the scope it's loaded in. So trying to use the 'en' locale when you've already loaded the 'zh-cn' locale will return undefined simply because the 'shortTime' format for 'zh-cn' doesn't match the one for 'en'.

See my updated plunk: https://plnkr.co/edit/ZqFxQWbPrIUcmySWyblh

I'll release the fix as soon as I can.

@dnasir dnasir added the bug label Apr 28, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants