Last updated 7 August 2008. Created on 25 July 2008.
Edited by KarenS. Log in to edit this page.

The file date_api.module is basically a big collection of date utility functions. You can scan through the file and it should be pretty obvious what they are and what they do.

The files are files you can optionally include to do other things -- create cross-database date sql or work with ical. The date sql is implemented for views queries in, which should give you ideas on how to use it. The ical functions are implemented by the Calendar iCal module, which you can use as an example.

The basic date functions are the PHP 5.2 date functions -- date_create(), date_timezone_set(), date_format(), etc, all of which are documented on

The Date PHP4 module provides those 5.2 date functions for systems that don't have them (earlier than PHP 5.2).

The Date Repeat module has an API for creating and parsing iCal RRULEs. You can use it to add a form element that allows users to select repeat rules (a form with type => '#date_repeat') and the repeat_calc function will parse an iCal RRULE and return an array of the dates that fit that rule.

Looking for support? Visit the forums, or join #drupal-support in IRC.


endiku’s picture

Latest,v on line 208
-$subgroup['DTEND'] = $subgroup['DTSTART'];
As I understand it from the comment "//Many programs output DTEND for an all day event as the following day, reset this to the same day for internal use." - this sets DTEND to DTSTART when all_day is set in the VEVENT.

This does indeed happen for instance in MS Outlook where when you save an ical, a one day event has a DTSTART of 2009-07-01 and DTEND of 2009-07-02 which would then create a 2 day event instead of the correct one day event.

The problem arises when there is an actual multiple day event with a truly different DTEND. A week long event set at "all_day" will become a single day event and you will lose the valid extra days.

Instead try-
//$subgroup['DTEND'] = $subgroup['DTSTART'];
$subgroup['DTEND']['datetime'] = strtotime($subgroup['DTEND']['datetime'].'-1 day');
$subgroup['DTEND']['datetime'] = date('Y-m-d', $subgroup['DTEND']['datetime']);

This will subtract one day from the end of DTEND. In the cases where DTEND is the extraneous extra day in an all_day it will still equal DTSTART and where it is a valid multi-day it will be correct.