Hello,
First at all, i have to apologize for my bad english (I'm not a native speaker :( )...
I searched for some datetime element (not CCk) for Drupal, to get integrated to my custom module. Because I did not find any, I'm now working on a datetime.module. (First step on this was http://drupal.org/node/37405)
My first aim will be to get the module integrated in my own site (it only uses a single uncustomizable timezone).
If there was demand on further development, it would nice to get some feedback and/or help from you.
(The current developping status of datetime.module can be downloaded at http://derhasi.de.3.kunden-server.org/files/datetime.rar)
This datetime.module integrates a datetime element type. It extends the date element with a lot more features.
Some specification of that (plus excerpt of datetime process function description):
- Single child elements ('year','month','day','hour','minute','second') can be disabled
- Default values for each child element can be set
- Prefix and suffix for each child element can be set
- Output array is extended by timestamp, sql-date, sql_datetime and format_date values
- ...
Another possible extensions could be:
- child element: timezone selection field
- output value: timezone
/**
* Roll out a single datetime element.
*
* @param $element
* Form element with specific keys for influencing the datetime-form
*
* Each child-element (year,month,day,hour,minute,second) can be configured in its child-element-settings-array( #year,#month,...) via following keys:
* #default_value => Default value for child element (e.g. 2007), default: current time's value
* #start => start of range value is selected from
* #end => end of range value is selected from
* #prefix => prefix of element
* #suffix => suffix of element - e.g. t('hour')
* #weight => determines order for viewing field, default: via site's chosen date format.
* #hidden => TRUE if element shold not be viewed, default: FALSE
*
* The output of format_date can be influenced via #format_date with following keys:
* #type => short, medium, large or custom | default: short
* #format => custom format
* For more information look at drupal function format_date()
*
* The type of input value (for loading node the first time) can be set in '#input_type'
* its values can be 'timestamp'(default),'sql_date','sql_datetime'
* -only for non-array default_values-
*
*
* @return
* Form element that outputs different (formatted) datetime:
* return value is an array:
* array(
* 'year' => Value of selected year
* 'month' => Value of selected month
* 'day' => Value of selected day
* 'hour' => Value of selected hour
* 'minute' => Value of selected minute
* 'second' => Value of selected second
* 'timestamp' => timestamp value of selected datetime
* 'sql_datetime' => datetime value, like it is saved in sql-tables of selected datetime
* 'sql_date' => date value, like it is saved in sql-tables of selected date
* 'format_date' => formatted date of selected datetime, with properties of #format_date
* )
*/
Due to the timestamp problem not supporting dates greater 1970 to 2038, I integrated ADOdb Time Library to solve this problem. (http://phplens.com/phpeverywhere/adodb_date_library)
- Admin can select, whether the site shall use ADOdb extension or not.
- new functions are available, which either uses the drupal's default function or ADOdb's:
- datetime_getdate()
- datetime_date()
- datetime_gmdate()
- datetime_mktime()
- datetime_gmmktime()
- datetime_strftime()
- datetime_gmstrftime()
Due to ADOdb integration and timezone/DST compatibility i added some other functions:
- datetime_format_date()
- can replace format_date() - must replace format_date if ADOdb is activated and dates greater 1970 to 2038 are used
- integrates a timezone/dst detection function - datetime_getdrupaltimezone()
- is able to handle with datetime element's output values for previewing
- datetime_getdrupaltimezone()
- detects drupal's current timezone and may detect DST offset via dst detection function (dt_adodb_daylight_sv)
- datetime_convert($date,$mode='arr2ts',$arg='',$arg2='custom',$arg3=NULL)
- function to convert a date from one format to another
- supported format types:
- Array
- Timestamp
- SQL Date
- SQL Datetime
- format - for output using datetime_format_date
Hope it isn't too confusing.
Yours,
derHasi
Comments
Drupal 6.x support
Have you tried to port the module to drupal 6.x?