[development] Date Calc and ADODB date library

Karen Stevenson karen at elderweb.com
Fri Jun 22 14:05:38 UTC 2007

I have decided that it would be really useful to add the PEAR Date Calc and the ADODB date library to the Date API by reworking the original code to use Drupal coding conventions and styles and making them available as natively-available Drupal include files.  Both have BSD licenses, so my understanding is that it is OK to do this. Anyone know for sure if that is true? And does anyone know exactly what parts of the original license info should be retained in the reworked code or how I should attribute the original modules/authors?

Also, as I work through them, it occurs to me that once they're 'Drupalized' they might potentially be nice additions to Drupal core. They could then be used by a wide variety of core and contrib modules that do things with dates and schedules and calendars without the need to duplicate all that code.

For those not familiar with them, ADODB date library makes it possible to handle date ranges from the year 100 to the year 3000 (a bigger range even than that allowed by php 5). The library checks to see if native php date handling will work on the date being manipulated and if so, uses it, which keeps overhead to a minimum. The PEAR Date Calc library has functions you can use to find things like the last day of February in 1950, or the first Tuesday in the second week of 1965, or the day of the week that October 29, 1929 fell on. Both work with both php4 and php5 on either Windows or NIX systems.

PEAR Date Calc is a class that requires PEAR Date, but it is actually
works fine reworked into a stand-alone collection of date functions
with no need for PEAR or PEAR Date. The ADODB library has its own
versions of some of the PEAR Date Calc functions which can be
eliminated in the Drupalized version since they'll already be available.
By creating Drupal versions of both, I may be able to find other ways
to tweak them to better match the way Drupal does things, like replacing the PEAR Date Calc's DATE_CALC_BEGIN_WEEKDAY constant with Drupal's variable_get('date_first_day', 1).

I'm not finished with them yet, but preliminarily it would be about 20
KB for the Drupalized ADODB library and 45 KB for the Drupalized PEAR
Date Calc library, so they would add some size to the download, but
maybe not enough to be a problem. Some of that might be offset by using the new functions in core (i.e. there will be a date_calc_get_week_days() to return the translated days of the week and date_calc_get_month_days() to return translated months of the year).

The risk of doing this is that someone needs to keep up with the original code in case there are bug fixes that need to be ported to our fork, but both of these libraries are very stable and haven't changed much.

Together they would make many things possible, or at least make them easier. 



More information about the development mailing list