Renamed function _split_date, added average age calculation to summary report

This commit is contained in:
2013-10-02 15:29:25 +10:00
parent e135ef9883
commit bb5dc7322e
3 changed files with 54 additions and 33 deletions

View File

@@ -185,7 +185,7 @@ function _datetime_array_to_ts($date)
function _date_to_ts($date) {
$date_split = _split_date($date);
$date_split = _booking_split_date($date);
date_default_timezone_set(TIMEZONE);
$tz = new DateTimeZone(TIMEZONE);
@@ -204,7 +204,7 @@ function _date_to_ts($date) {
}
function _datetime_to_ts($date) {
$date_split = _split_date($date);
$date_split = _booking_split_date($date);
date_default_timezone_set(TIMEZONE);
$tz = new DateTimeZone(TIMEZONE);
@@ -228,7 +228,7 @@ function _datetime_to_ts($date) {
* @param $date in format YYYY-MM-DD
* @return array containing Year, Month, Day
*/
function _split_date($date) {
function _booking_split_date($date) {
$pattern = '/^(\d{4})-(\d{2})-(\d{2})(\s(\d{2})\:(\d{2}))?/';
if (preg_match($pattern, $date, $matches)) {
return $matches;
@@ -267,9 +267,20 @@ function _booking_convert_ts($timestamp)
return $date;
}
/**
* Helper function to ensure timestamp is converted to correct local time
*/
function _booking_max_dob_ts()
{
//calculate DOB limit as defined by configuration
$max_dob_matches = _booking_split_date(variable_get('booking_max_dob','0'));
return mktime(12, 0, 0, $max_dob_matches[2], $max_dob_matches[3], $max_dob_matches[1]);
}
function _date_range_to_string($date_start, $date_end) {
$start = _split_date($date_start);
$end = _split_date($date_end);
$start = _booking_split_date($date_start);
$end = _booking_split_date($date_end);
$final_string = '';
//check for correctly formatted dates