

JDateTime - Iranian (Shamsi) Date for PHP - sallar
https://github.com/sallar/jDateTime
jDateTime is a PHP wrapper for DateTime class enabling developers to use Iranian date/time in their projects.
======
amir
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.

~~~
sallar
Sure, but it's PHP 5 >= 5.3.0. jDateTime requires 5.2. IntlDateFormatter did
not exist at the time of writing this code.

------
revelation
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.

------
maxcan
not to be confused with JDate.com..

~~~
dfc
That was my reaction as well. Maybe it is because I am from New York, but when
I see JDateTime I did not think of Iranian time conversions.

~~~
chimeracoder
Are you from Great Neck[0]? That would be doubly confusing....!

[0] <http://en.wikipedia.org/wiki/Great_Neck,_New_York>

~~~
dfc
I dont get it?

~~~
chimeracoder
It's a joke - Great Neck has an extremely large population of Iranian Jews.

------
phishphood
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?

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

------
afshinmeh
upvote, you rock Sallar :)

