Hi Karen,

Good to meet with you for those few minutes at Drupalcon DC.

I just wanted to record some thoughts somewhere about how much work would need to be done in order to display Jewish, Islamic, Chinese date and calendar information using your Date API/Date/Calendar modules. You said it would be quite a lot of work to get there. I got the impression that it would take a leap in date storage format, and then a lot of work on the presentation layer to build the interface and display. Does that sound accurate?

I'm not a developer by any means so take this train of thought FWIW. A fast google suggests that PHP started including date transformation functions in PHP3 in order to change the state of the date from Julian to many others. This is kind of neat but only offers translation to Gregorian, French Republican, Jewish and Unix (what a collection, eh?): http://www.w3schools.com/php/php_ref_calendar.

From a data storage POV, does Date API write dates as Julians?

If your Date API module is doing its work in Julians then it is conceivable that Jewish Date/Calendar versions are possible already. I mean, its clear that it would be a lot of work and nearly a rewrite of your modules, but possible for another intrepid developer to maintain separately from your Gregorian Date/Calendar modules, right? In theory, those date systems could be interchangeable since the data is originally written in Julian?

Anyway, just wanted to open the conversation for the future. Any thoughts?

Comments

seaneffel’s picture

karens’s picture

The calendar library in PHP is disabled by default, so most systems don't have it and you can't count on it being there. So that's no much help.

Basically this will take a whole lot of thought, which is just a TODO for now. My vague idea is that the whole method of handling dates has to be re-worked into OO so there is a class that can be extended to handle the peculiarities of each calendar.

There is another issue about this somewhere, but it's old and probably pretty well buried.

Doing a simple conversion (Tues, Mar 5, 2009 is the same as XXXX, XX, XX in some other calendar) is the most do-able thing, but could still be challenging. Each system has a different idea of how many hours there are in a day, how many days in a week, how many weeks in a month, etc., so basically every assumption in date handling has to have a setting that can be overridden.

ebeyrent’s picture

I'm not an expert by any stretch of the imagination. Should dates always be stored in the same format and simply translated on output?

For example, you could do something like this to translate a gregorian date into a Hebrew date:

$gregorianMonth = date(n);
$gregorianDay = date(j);
$gregorianYear = date(Y);

$jdDate = gregoriantojd($gregorianMonth,$gregorianDay,$gregorianYear);

$hebrewMonthName = jdmonthname($jdDate,4);

$hebrewDate = jdtojewish($jdDate);

list($hebrewMonth, $hebrewDay, $hebrewYear) = split('/',$hebrewDate);

echo "$hebrewDay $hebrewMonthName $hebrewYear";

Maybe it's far more complicated than that.

seaneffel’s picture

Thank you for that. The method is there to change the format of one date value into another without a lot of work.

Then we've got to talk about translating the names of the days of the week, names of the months of the year, renumbering the months and days of the year to suit calendars that are more or less than 365.25 days long, and a total redesign or companion method of displaying these date values on differently formatted calendars.

So it's just the tip of the iceberg.

mohamadaliakbari’s picture

there is another module named "Calendar System" that convert dates between Calendars "Gregorian, Arabic and Jalali", Conversion completely involve days in month, days in year, days name, months name, number conversion and other feature needed by date_api. other calendar will be added, why you and this module developer don't integrate your modules into one.
I hardly worked on reading Date_api and trying to hack it's core to use Calendar System for converting befor each output, but this make other functions down.

damienmckenna’s picture

Status: Active » Closed (won't fix)

Unfortunately the Drupal 6 version of the Date module is no longer supported. That said, we appreciate that you took time to work on this issue. Should this request still be relevant for Drupal 7 please feel free to reopen it. Thank you.