shortTime parser not working in Chinese language
Opened this issue · 3 comments
timeString : 上午12:00
on calling the below line with the time return invalid time
$dateParser(timeString, 'shortTime')
@tkarthick81 can you post a jsfiddle or a plnkr so I can test this out?
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
@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.