diff options
author | Andrey Andreev <narf@bofh.bg> | 2012-11-02 22:33:45 +0100 |
---|---|---|
committer | Andrey Andreev <narf@bofh.bg> | 2012-11-02 22:33:45 +0100 |
commit | e24eed7e4e410fabf7479a67d3a27e2596444505 (patch) | |
tree | b751d0553e2a72dc0dbe909b3c7db1fc0d4d2f5c /system/helpers/date_helper.php | |
parent | 533bf2dd5f36e277a9ee6629ccd667a32b05d154 (diff) |
Some micro-optimizations
Diffstat (limited to 'system/helpers/date_helper.php')
-rw-r--r-- | system/helpers/date_helper.php | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/system/helpers/date_helper.php b/system/helpers/date_helper.php index 5f05f0701..0fa400d7e 100644 --- a/system/helpers/date_helper.php +++ b/system/helpers/date_helper.php @@ -450,20 +450,13 @@ if ( ! function_exists('human_to_unix')) return FALSE; } - $split = explode(' ', $datestr); + sscanf($datestr, '%d-%d-%d %s %s', $year, $month, $day, $time, $ampm); + sscanf($time, '%d:%d:%d', $hour, $min, $sec); + isset($sec) OR $sec = 0; - list($year, $month, $day) = explode('-', $split[0]); - - $ex = explode(':', $split['1']); - - $hour = (int) $ex[0]; - $min = (int) $ex[1]; - $sec = ( ! empty($ex[2]) && preg_match('/[0-9]{1,2}/', $ex[2])) - ? (int) $ex[2] : 0; - - if (isset($split[2])) + if (isset($ampm)) { - $ampm = strtolower($split[2]); + $ampm = strtolower($ampm); if ($ampm[0] === 'p' && $hour < 12) { |