globalizejs / globalize

A JavaScript library for internationalization and localization that leverages the official Unicode CLDR JSON data
https://globalizejs.com
MIT License
4.8k stars 603 forks source link

parseDate() doesn't accept its own formatDate() output in all the formats of "ar" locale/culture #844

Open manikumarnnss opened 6 years ago

manikumarnnss commented 6 years ago

Generally Globalize library's parseDate() should always accept the output of its own formatDate(). But this fails for globalize.culture.ar.js.

Globalize.formatDate(new Date(), { 'raw': 'yyyy-MM-dd HH:mm:ss' }) return "٢٠١٨-١١-٠١ ١٣،٢٧،١٧"

Even if we pass the return value from above to parseDate it cant be accepted and retruns 'null'-

Globalize.parseDate("٢٠١٨-١١-٠١ ١٣،٢٧،١٧", { 'raw': 'yyyy-MM-dd HH:mm:ss' }) return nulll

manikumarnnss commented 6 years ago

Anyone please help me here...

rxaviers commented 6 years ago

Please, which version of globalize and cldr are you using? Using latest, it works fine for me. I noticed in your output you have comma ، instead of colon : separating hour digits...

I get this instead:

Globalize("ar").formatDate(new Date(2018,10,1,13,27,17), { 'raw': 'yyyy-MM-dd HH:mm:ss' })
// > '٢٠١٨-١١-٠١ ١٣:٢٧:١٧'

Globalize("ar").parseDate('٢٠١٨-١١-٠١ ١٣:٢٧:١٧', { 'raw': 'yyyy-MM-dd HH:mm:ss' })
// > 2018-11-01T16:27:17.000Z
rxaviers commented 6 years ago

I will reopen when I can reproduce...

rxaviers commented 6 years ago

By the way, why are you using raw format like that? I disencourage using raw for localization purposes, instead use skeleton or datetime.

rxaviers commented 6 years ago

If you want ISO string, use plain JavaScript, e.g., new Date().toISOString().

rxaviers commented 6 years ago

Ok, this is an issue using CLDR 27, because timeSeparator is ، instead of : as in CLDR 28 and up.

Legends commented 5 years ago

Is this lib dead or why is this issue still open? Just a kind question.