Overview

This module provides date and time fields that allows any individual component to be left blank, while still providing a sortable listing of the fields. Useful if you need to handle dates like "8:46 a.m Sep 11, 2001 EST", "12 noon 25 May, Early 16th Century" or "May 20000 BC" in the one field.

  • A date / time field and a date / time range field
  • One master widget.
    This includes:
    • Individual date components
      Select lists and a text field for years
    • Optional estimate range lists
      For example, "18th Century" for years between 1700 and 1799
    • Ability to select all or none of any of the above fields
    • Two label override fields
  • There are three built in formatters that allow you to assign supported PHP date() like components to a date. The formatter settings can be used to customise any individual field.
  • One FAPI element that supports a singular date time values and the corresponding range approximation lists.

Important outstanding issues:

  • Timestamp creation. This is used for sorting, but it is not generating the correct values. Some dates are significantly wrong.
  • Individual Time and Date fields. Currently there is a database column for each level of granularity.
  • Implement missing PHP formatters
  • Date validation. Currently there is none.
  • Timezone implementation. Hoping to implement all of the supported Date module options.
    For values outside of 1900 / 2038, the offset at 1905 will be generated and the timestamp will be calculated. Modern daylight savings started in 1908.
  • Massive tidy up in the code

Note that there is no practical limit on the values that it can handle, so you could mix astrological ages with dates of recent discoveries.

Internals

This module attempts to bypass PHP / SQL limitations by using multiple fields to store the date in the database. An approximate timestamp FLOAT is used in views for sorting and searching. The other fields are used by the field formatters.

PHP on 32 bit machines have a limitation of only being able to handle dates between 1900 and 2038. Prior to PHP 5.1, window and some unix boxes would only support 1970 to 2038 dates.

MySQL native DATE is also limited, from 0AD to 9999AD.

Fuzzy date support is provided by reducing missing time granularity components to the minimal or maximum values that would otherwise be allowed.

The minimal granularity values for singular or from dates are:

Component Single / From date To date
Year 999999999999BC 999999999999AD
Month 1 12
Day 1 28-31 (Month dependent)
Hour 0 23
Minute / Second 0 59

Since standard date formatters are useless with dates such as 2000BC to 12PM Sun 6rd, Nov 11, three formatters are provided to handle the theming of these values. On top of these functions, the module also allows for two textfields to allow users to enter a more readable text value (limit 255 characters), for example, "The stone age" or "Jurassic period". These are optional and can be disabled.

Lastly, another optional year selector widget is provided. This has a drop down list that contains multiple ranges. The default value is for Australia and represents the following periods:

30,000BC to 1600: Pre-colonial period / Dreamtime
1500-1599: 16th Century
1600-1699: 17th Century
1700-1799: 18th Century
etc

Singular / From dates are assigned the starting year of the range and the To date gets assigned the finishing year when calculating the internal timestamp.

Dependencies

Date module: http://drupal.org/project/date

Beta Release!

This release involved a couple intense days of development after a long hiatus. This should resolve a lot of the outstanding issues and introduces some new features.

Run update (no script) or flush your caches to ensure that the new theming functions are picked up.

Some fields may need to be edited to resolve any notices and warnings, the new field and widget settings were not added using any update scripts, but simply edit and save these to make any warnings to go away. Most are checked in code, so I do not foresee any issues.

Please report any issues.

Acknowledgments

Some of the core logic was taken from the Zend_Date project, however this was significantly optimised to prevent excessive computation during the timestamp calculation.

Sponsorship

Initial module development was sponsored by Glo Digital

Project Information

Downloads