Non-Gregorian Dates and Calendars

You are viewing a wiki page. You are welcome to join the group and then edit it. Be bold!
public

There have been periodic requests to add support for non-Gregorian dates and calendars to Drupal. (See http://drupal.org/node/242965 and http://drupal.org/node/166234, for example) I've been doing a bit of thinking about this and have concluded that it could be possible but would require a big effort. The basic approach I'm thinking of now would be to create a wrapper class for date and calendar handling that will default to use Gregorian dates but would make it possible to plug in others. We could also look at ways to use the Drupal hook system, but in this case a wrapper class might work better.

So this wiki page is a place where anyone interested can start to post ideas and code. We need:

Aspects of other calendars that might be different

  • The number of days in a month
  • The number of months in a year??
  • The number of days in a year
  • The number of days in a week??
  • Day names -- can we use translation system if the number of days in a week is always 7??
  • Month names -- can we use translation system if the number of months in a year is always 12??
  • First day of week
  • First day of year
  • Uses daylight savings time?
  • Has timezones and needs timezone conversions?
  • Has leap year, leap month, leap day, etc.
  • Date formats, alternative ways to display a given date
  • Abbreviations for day and month names (hard to do with current translation system)
  • Date storage -- store as timestamp? store as datetime? other? How big does the field need to be?

List of Calendars

List of some of the calendars that are important to people now using Drupal who can make some kind of contribution to this effort.

How to Integrate

My initial thought is that we have a subdirectory called "calendars" under the module's directory, with several .inc files in it, one for each type of calendar, e.g. hijri.inc, chinese.inc, ...etc. Of course, all this needs to be done for dates (list all calendars, enable selected calendards only, convert dates between calendars, ...etc.). [Kahlid - 2bits]

I'm Agree with Khalid opinion, all of the calendar systems have simple text representation which means that there shouldn't be major problem with representing date in different calendar systems, and also think that calendar module should be responsible for creating date widget for forms. storing date as SQL standard calendar (Gregorian) or as timestamp in database would be good idea for preventing compatibility with other tools and modules [sinasalek]

There is a module started by sinasalek to accommodate different calendar systems. Check the calendar systems project.

Code snippets that will do conversions for various calendars

Islamic (Hijri) - http://drupal.org/node/242965
Iranian (Shamsi) - http://salek.ws/projects/drupal/datetime.class.inc.php.txt

List of popular calendar systems

Links to resources on this subject

  • A discussion with useful links - http://drupal.org/node/205500
  • Javascript implementation of popular calendar systems - at Fourmilab
  • PHP Multi calendar systems object (Good for inspiration) - at Codeigniter
  • Software implementation of almost all of the popular calendar systems (Good for demonstration and test) - at PCWorld.
  • Some background informations on Calendars - at Web Exhibits

Calendars are calculated based on astronomical phenomenon!

Marat - Fri, 2008-04-11 15:45

Hi Karen,

Thank you for opening this page. Also, many thanks to Kahlid - 2bits for supporting this project.

Regardless of all religious backgrounds of different existed calendars, the majority of dates and calendars are calculated based on some astronomical phenomenon, which include three systems:

  1. the cycle of the sun,
  2. the cycle the moon and/or
  3. the cycle the star.

Christian calendar (Gregorian) is solar calendar. Islamic calendar (Hijri) is lunisolar calendar. Samvat (Hindu) is sidereal calendar. “The Chinese calendar is a lunisolar calendar, incorporating elements of a lunar calendar with those of a solar calendar,” and so on for the rest of calenders.

This is the start point in my opinion. The calculation methods of date is what we should consider, either solar or lunar, and in advance stage, sidereal.

Drupal’s calendar calculation is based on the sun cycle regardless of its religious background. It will be a great idea to have another method of calculating date based on the moon cycle, which can be used for many other calendars. The way to convert from sun calendar system to moon calendar system is described in this page (http://drupal.org/node/242965).

Once we have these calendars based on calculation (solar, lunar and sidereal), everyone can add events or whatever to any calender.

In this way, I think Drupal can cover mostly all calenders.

Regards

Iranian (Shamsi)

alimosavi - Thu, 2008-05-15 04:05

hi.
thank you allot to open this group .

I am administrator of irdrupal.com . this site the firstly Persian community of drupal user.
I and my members need for Iranian (Shamsi) date. I have to edit common.inc file for this do.
I use jdate() function for change all system date.

It is work but I have to edit error function in the form.inc file in iclude folder for get not eror for valid date.
I know this way it in the risk but it was emergency for we .
It is better that create a modules to can do it .
I ready to share my information to all.

you cad download my project : http://www.irdrupal.com/project/irdate

Persian support of drupal : http://www.irdrupal.com

Jewish calendars

yhager@drupal.org's picture
yhager@drupal.org - Thu, 2008-05-15 08:20

The calculation of a jewish date from a gregorian date is well known, and can easily be integrated.

The jewish calendar is basically a lunar calendar, on a monthly basis, but solar on the yearly basis.

A few notes that need to be considered:
* The number of days in a month is not constant. The same month can have a different number of days in different years
* The number of months in a year is 12 or 13 (this is to adapt the solar calendar to the lunar one)
* The number of days in a year is different every year (not sure about this one)
* The number of days in a week is always 7, day names can be translated using the existing translation system
* The first day of the week is Sunday, the weekend is Fri-Sat.
* Month names cannot be translated since the number of months per year is not constant
* The most difficult point to understand is when the date is changing. In the jewish calendar, the date switches AT SUNSET, and not at midnight. This means that in order to know the date, one needs to know the time the sun sets.
* Timezones are treated in the same way as in gregorian calendar.
* I don't see a difficulty with date formats and aliases of days or months