12 comments

[ 1.8 ms ] story [ 23.8 ms ] thread
Thank god they finally introduced all this classes and inheritance kerfuffle in PHP, so we can now manually handle Iranian dates by calling "toJalali" on a pseudo-singleton "jDateTime" class.

In all seriousness, I wanted to punch myself in the face when I had to instantiate a "GregorianCalendar" in Java, but the general idea has a lot of merit, even if the implementation is terrible.

not to be confused with JDate.com..
I've never seen JDate.com, I'm sorry for the confusion.
You know you can do this:

    $idf = new IntlDateFormatter('fa_IR@calendar=persian',
        IntlDateFormatter::FULL,
        IntlDateFormatter::FULL,"Asia/Tehran",
        IntlDateFormatter::TRADITIONAL);
right?

PHP has a wrapper for ICU.

Sure, but it's PHP 5 >= 5.3.0. jDateTime requires 5.2. IntlDateFormatter did not exist at the time of writing this code.
don't know much about how Iranian dates work so I peeked inside the code to see the actual conversion.

Line 482 - $g_days_in_month = array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);

Umm, what about leap years, you know the ones that have 29 days in February?

Looks as if lines 489 onwards are for detecting leap years.