diff --git a/booking.helper.inc b/booking.helper.inc index c5171cb..9a37c03 100644 --- a/booking.helper.inc +++ b/booking.helper.inc @@ -173,10 +173,11 @@ function _datearray_to_ts($date) date_default_timezone_set(date_default_timezone(FALSE)); $tz = new DateTimeZone(date_default_timezone(FALSE)); - if (empty($date) || ($date['month'] == '' && $date['day'] == '' && $date['year'] == '')) - return 0; - else - watchdog('booking', "Date array to timestamp: @info", array('@info' => var_export($date, TRUE))); + if (empty($date) || ($date['month'] == '' && $date['day'] == '' && $date['year'] == '')) { + return 0; + } + //else + // watchdog('booking', "Date array to timestamp: @info", array('@info' => var_export($date, TRUE))); $gmt_ts = mktime(0, 0, 0, $date['month'], $date['day'], $date['year']); $ts = new DateTime("@$gmt_ts"); @@ -192,8 +193,9 @@ function _datetime_array_to_ts($date) date_default_timezone_set(date_default_timezone(FALSE)); $tz = new DateTimeZone(date_default_timezone(FALSE)); - if (empty($date) || ($date['month'] == '' && $date['day'] == '' && $date['year'] == '')) + if (empty($date) || ($date['month'] == '' && $date['day'] == '' && $date['year'] == '')) { return 0; + } //else // watchdog('booking', "Date array to timestamp: @info", array('@info' => var_export($date, TRUE))); @@ -211,17 +213,16 @@ function _date_to_ts($date) { date_default_timezone_set(date_default_timezone(FALSE)); $tz = new DateTimeZone(date_default_timezone(FALSE)); - if ($date_split[0] == '-1' ) + if ($date_split[0] == '-1' ) { return 0; - else - { - $gmt_ts = mktime(0, 0, 0, $date_split[2], $date_split[3], $date_split[1]); - $ts = new DateTime("@$gmt_ts"); - $ts->setTimezone($tz); - - return $ts->format("U"); } - //return mktime($date_split[5], $date_split[6], 0, $date_split[2], $date_split[3], $date_split[1]); + + $gmt_ts = mktime(0, 0, 0, $date_split[2], $date_split[3], $date_split[1]); + $ts = new DateTime("@$gmt_ts"); + $ts->setTimezone($tz); + + return $ts->format("U"); + //return mktime($date_split[5], $date_split[6], 0, $date_split[2], $date_split[3], $date_split[1]); } function _datetime_to_ts($date) { @@ -232,14 +233,13 @@ function _datetime_to_ts($date) { if ($date_split[0] == '-1' ) return 0; - else - { - $gmt_ts = mktime($date_split[5], $date_split[6], 0, $date_split[2], $date_split[3], $date_split[1]); - $ts = new DateTime("@$gmt_ts"); - $ts->setTimezone($tz); + + $gmt_ts = mktime($date_split[5], $date_split[6], 0, $date_split[2], $date_split[3], $date_split[1]); + $ts = new DateTime("@$gmt_ts"); + $ts->setTimezone($tz); + + return $ts->format("U"); - return $ts->format("U"); - } //return mktime($date_split[5], $date_split[6], 0, $date_split[2], $date_split[3], $date_split[1]); }