This site is archived.

Drupal Dates -- We Can Do Better!

Platinum and gold sponsors

KarenS's picture
KarenS - Sun, 01/20/2008 - 11:09am
Presenters: 
Karen Stevenson
Track: 
birds of a feather
Session Description: 

Note! This has been changed from a session to a BOF to make room for more sessions, so look for this in the BOF room.

This session will introduce the new, completely rewritten Date API. Both Drupal core and dozens of contributed modules manipulate dates and times, each in their own way, and all limited by the poor date handling available in PHP 4. The 5.2 version of the Date API is a complete re-write of that module to create a consolidated library of date functions and date elements that can be used by any other module, taking full advantage of the superior PHP 5.2 date handling wherever it’s available.

AGENDA
We’ll review the features available in the new API, including:

  • Use of the PHP 5.2 date functions for all date and time handling, with a wrapper class to provide emulations of those functions that will work in earlier versions of PHP.
  • Overloading the site and user timezone selection forms to select and store timezone names instead of offsets.
  • Provision of several configurable, self-validating FAPI date selection elements that can be used by other modules to create form elements that contain collections of drop-down selectors and textfields for all the date parts.
  • A Date Popup module that creates a configurable FAPI date_popup form element that uses jQuery calendar and time pickers to select dates and times.
  • A Date Repeat API that can be used by any module with a form element that will allow users to select repeat rules for dates and times, and a calculator function that will return a list of all the dates and times that match those rules.
  • A library of functions create option lists for various date parts (years, months, days, days of the week, timezones, etc.)
  • Functions to do date modification using strtotime-like strings (+1 month, -90 days, etc.)
  • Lots more…

GOALS
I hope to create an API that is flexible enough and general enough that it can be used by any other module that does date and time handling. If we can get consensus on this API, this improved date handling could hopefully make its way into core in Drupal 7.

Average: 4.9 (20 votes)