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 605 forks source link

Issue Converting Hijri date to gregorian #142

Closed tmcconechy closed 11 years ago

tmcconechy commented 11 years ago

I am trying to convert a Hijri date back to gregorian with the internal function in the ar-SA calendar (other calendars seem to have the same toGregorian function). For example:

Globalize.cultures["ar-SA"].calendars.standard.convert.toGregorian("1434", "03", "11");

According to sites I've seen like: http://www.islamicity.com/prayertimes/defaulthijriconv.asp

"1434", "03", "11" should be 1/23/2013.

However, each date seems to be off by 2 days and this function returns.. 1/21/2013.. Is there a problem with this function? Or some other issue I could be having by using it?

jzaefferer commented 11 years ago

This project is currently somewhat on ice. It'll get more attention sometime soon, when we get back to the jQuery UI datepicker rewrite, but right now there's no one around who knows enough about issues like yours. You might be better off getting help on StackOverflow, for now.

tmcconechy commented 11 years ago

Thanks for the info I created: http://stackoverflow.com/questions/14483312/converting-hijri-date-to-gregorian-with-jquery-globalize..

Is there something preferred now for localization (it works well for me)...?

jzaefferer commented 11 years ago

Globalize is used by jQuery UI for localizing numbers and currencies in the spinner widget. There's plenty stuff that works well, its just edgy casy issues like this that need a lot of time to resolve, which we currently focus elsewhere.

tmcconechy commented 11 years ago

I figured out the problem it is because Month is expected as zero based so the above code should be:

Globalize.cultures["ar-SA"].calendars.standard.convert.toGregorian("1434", "02", "11");

For todays date. So it seems to work correctly...