From 5d1e32b2fbae74e6f9e1ab2bdb6a3635579ef13e Mon Sep 17 00:00:00 2001 From: Eric Barnes Date: Tue, 3 May 2011 22:28:59 -0400 Subject: Added unit tests for date helper. --- system/helpers/date_helper.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'system/helpers/date_helper.php') diff --git a/system/helpers/date_helper.php b/system/helpers/date_helper.php index f3f01f751..951181b8c 100644 --- a/system/helpers/date_helper.php +++ b/system/helpers/date_helper.php @@ -112,15 +112,16 @@ if ( ! function_exists('standard_date')) function standard_date($fmt = 'DATE_RFC822', $time = '') { $formats = array( - 'DATE_ATOM' => '%Y-%m-%dT%H:%i:%s%Q', + 'DATE_ATOM' => '%Y-%m-%dT%H:%i:%s%O', 'DATE_COOKIE' => '%l, %d-%M-%y %H:%i:%s UTC', - 'DATE_ISO8601' => '%Y-%m-%dT%H:%i:%s%Q', + 'DATE_ISO8601' => '%Y-%m-%dT%H:%i:%s%O', 'DATE_RFC822' => '%D, %d %M %y %H:%i:%s %O', - 'DATE_RFC850' => '%l, %d-%M-%y %H:%m:%i UTC', + 'DATE_RFC850' => '%l, %d-%M-%y %H:%i:%s UTC', 'DATE_RFC1036' => '%D, %d %M %y %H:%i:%s %O', 'DATE_RFC1123' => '%D, %d %M %Y %H:%i:%s %O', + 'DATE_RFC2822' => '%D, %d %M %Y %H:%i:%s %O', 'DATE_RSS' => '%D, %d %M %Y %H:%i:%s %O', - 'DATE_W3C' => '%Y-%m-%dT%H:%i:%s%Q' + 'DATE_W3C' => '%Y-%m-%dT%H:%i:%s%O' ); if ( ! isset($formats[$fmt])) -- cgit v1.2.3-24-g4f1b From 07c1ac830b4e98aa40f48baef3dd05fb68c0a836 Mon Sep 17 00:00:00 2001 From: Phil Sturgeon Date: Fri, 9 Mar 2012 17:03:37 +0000 Subject: Bumped CodeIgniter's PHP requirement to 5.2.4. Yes I know PHP 5.4 just came out, and yes I know PHP 5.3 has lovely features, but there are plenty of corporate systems running on CodeIgniter and PHP 5.3 still is not widely supported enough. CodeIgniter is great for distributed applications, and this is the highest we can reasonably go without breaking support. PHP 5.3 will most likely happen in another year or so. Fingers crossed on that one anyway... --- system/helpers/date_helper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/helpers/date_helper.php') diff --git a/system/helpers/date_helper.php b/system/helpers/date_helper.php index 9e58d8630..2a34cf93e 100644 --- a/system/helpers/date_helper.php +++ b/system/helpers/date_helper.php @@ -2,7 +2,7 @@ /** * CodeIgniter * - * An open source application development framework for PHP 5.1.6 or newer + * An open source application development framework for PHP 5.2.4 or newer * * NOTICE OF LICENSE * -- cgit v1.2.3-24-g4f1b From 03dbcf0669abdddf6bb459a423b99e7aed73e453 Mon Sep 17 00:00:00 2001 From: Roger Herbert Date: Sun, 11 Mar 2012 11:48:50 +0000 Subject: Make timespan() helper show fuzzier periods if required --- system/helpers/date_helper.php | 131 +++++++++++++++++++++++++++-------------- 1 file changed, 86 insertions(+), 45 deletions(-) (limited to 'system/helpers/date_helper.php') diff --git a/system/helpers/date_helper.php b/system/helpers/date_helper.php index 2a34cf93e..9f8e05bb9 100644 --- a/system/helpers/date_helper.php +++ b/system/helpers/date_helper.php @@ -163,7 +163,7 @@ if ( ! function_exists('standard_date')) */ if ( ! function_exists('timespan')) { - function timespan($seconds = 1, $time = '') + function timespan($seconds = 1, $time = '', $units = '') { $CI =& get_instance(); $CI->lang->load('date'); @@ -178,83 +178,124 @@ if ( ! function_exists('timespan')) $time = time(); } - $seconds = ($time <= $seconds) ? 1 : $time - $seconds; + if ( ! is_numeric($units)) + { + $units = 999; + } + + if ($time <= $seconds) + { + $seconds = 1; + } + else + { + $seconds = $time - $seconds; + } - $str = ''; - $years = floor($seconds / 31557600); + $str = array(); + + // years + + $years = floor($seconds / 31536000); if ($years > 0) { - $str .= $years.' '.$CI->lang->line((($years > 1) ? 'date_years' : 'date_year')).', '; + $str[] = $years.' '.$CI->lang->line((($years > 1) ? 'date_years' : 'date_year')); } - $seconds -= $years * 31557600; - $months = floor($seconds / 2629743); + $seconds -= $years * 31536000; - if ($years > 0 OR $months > 0) - { - if ($months > 0) + // months + + if (count($str) < $units) { + $months = floor($seconds / 2628000); + + if ($years > 0 OR $months > 0) { - $str .= $months.' '.$CI->lang->line((($months > 1) ? 'date_months' : 'date_month')).', '; - } + if ($months > 0) + { + $str[] = $months.' '.$CI->lang->line((($months > 1) ? 'date_months' : 'date_month')); + } - $seconds -= $months * 2629743; + $seconds -= $months * 2628000; + } } - $weeks = floor($seconds / 604800); + // weeks + + if (count($str) < $units) { + $weeks = floor($seconds / 604800); - if ($years > 0 OR $months > 0 OR $weeks > 0) - { - if ($weeks > 0) + if ($years > 0 OR $months > 0 OR $weeks > 0) { - $str .= $weeks.' '.$CI->lang->line((($weeks > 1) ? 'date_weeks' : 'date_week')).', '; - } + if ($weeks > 0) + { + $str[] = $weeks.' '.$CI->lang->line((($weeks > 1) ? 'date_weeks' : 'date_week')); + } - $seconds -= $weeks * 604800; + $seconds -= $weeks * 604800; + } } - $days = floor($seconds / 86400); + // days - if ($months > 0 OR $weeks > 0 OR $days > 0) - { - if ($days > 0) + if (count($str) < $units) { + $days = floor($seconds / 86400); + + if ($months > 0 OR $weeks > 0 OR $days > 0) { - $str .= $days.' '.$CI->lang->line((($days > 1) ? 'date_days' : 'date_day')).', '; - } + if ($days > 0) + { + $str[] = $days.' '.$CI->lang->line((($days > 1) ? 'date_days' : 'date_day')); + } - $seconds -= $days * 86400; + $seconds -= $days * 86400; + } } - $hours = floor($seconds / 3600); + // hours - if ($days > 0 OR $hours > 0) - { - if ($hours > 0) + if (count($str) < $units) { + + $hours = floor($seconds / 3600); + + if ($days > 0 OR $hours > 0) { - $str .= $hours.' '.$CI->lang->line((($hours > 1) ? 'date_hours' : 'date_hour')).', '; - } + if ($hours > 0) + { + $str[] = $hours.' '.$CI->lang->line((($hours > 1) ? 'date_hours' : 'date_hour')); + } - $seconds -= $hours * 3600; + $seconds -= $hours * 3600; + } } - $minutes = floor($seconds / 60); + // minutes - if ($days > 0 OR $hours > 0 OR $minutes > 0) - { - if ($minutes > 0) + if (count($str) < $units) { + + $minutes = floor($seconds / 60); + + if ($days > 0 OR $hours > 0 OR $minutes > 0) { - $str .= $minutes.' '.$CI->lang->line((($minutes > 1) ? 'date_minutes' : 'date_minute')).', '; - } + if ($minutes > 0) + { + $str[] = $minutes.' '.$CI->lang->line((($minutes > 1) ? 'date_minutes' : 'date_minute')); + } - $seconds -= $minutes * 60; + $seconds -= $minutes * 60; + } } - if ($str == '') - { - $str .= $seconds.' '.$CI->lang->line((($seconds > 1) ? 'date_seconds' : 'date_second')).', '; + // seconds + + if (count($str) == 0) { + { + $str[] = $seconds.' '.$CI->lang->line((($seconds > 1) ? 'date_seconds' : 'date_second')); + } } - return substr(trim($str), 0, -1); + return strtolower(implode(', ', $str)); } } -- cgit v1.2.3-24-g4f1b From 11f46f736b93529e8310135669196dec98e94d90 Mon Sep 17 00:00:00 2001 From: Roger Herbert Date: Sun, 11 Mar 2012 15:11:44 +0000 Subject: Revert "Make timespan() helper show fuzzier periods if required" This reverts commit 03dbcf0669abdddf6bb459a423b99e7aed73e453. --- system/helpers/date_helper.php | 131 ++++++++++++++--------------------------- 1 file changed, 45 insertions(+), 86 deletions(-) (limited to 'system/helpers/date_helper.php') diff --git a/system/helpers/date_helper.php b/system/helpers/date_helper.php index 9f8e05bb9..2a34cf93e 100644 --- a/system/helpers/date_helper.php +++ b/system/helpers/date_helper.php @@ -163,7 +163,7 @@ if ( ! function_exists('standard_date')) */ if ( ! function_exists('timespan')) { - function timespan($seconds = 1, $time = '', $units = '') + function timespan($seconds = 1, $time = '') { $CI =& get_instance(); $CI->lang->load('date'); @@ -178,124 +178,83 @@ if ( ! function_exists('timespan')) $time = time(); } - if ( ! is_numeric($units)) - { - $units = 999; - } - - if ($time <= $seconds) - { - $seconds = 1; - } - else - { - $seconds = $time - $seconds; - } + $seconds = ($time <= $seconds) ? 1 : $time - $seconds; - $str = array(); - - // years - - $years = floor($seconds / 31536000); + $str = ''; + $years = floor($seconds / 31557600); if ($years > 0) { - $str[] = $years.' '.$CI->lang->line((($years > 1) ? 'date_years' : 'date_year')); + $str .= $years.' '.$CI->lang->line((($years > 1) ? 'date_years' : 'date_year')).', '; } - $seconds -= $years * 31536000; + $seconds -= $years * 31557600; + $months = floor($seconds / 2629743); - // months - - if (count($str) < $units) { - $months = floor($seconds / 2628000); - - if ($years > 0 OR $months > 0) + if ($years > 0 OR $months > 0) + { + if ($months > 0) { - if ($months > 0) - { - $str[] = $months.' '.$CI->lang->line((($months > 1) ? 'date_months' : 'date_month')); - } - - $seconds -= $months * 2628000; + $str .= $months.' '.$CI->lang->line((($months > 1) ? 'date_months' : 'date_month')).', '; } + + $seconds -= $months * 2629743; } - // weeks - - if (count($str) < $units) { - $weeks = floor($seconds / 604800); + $weeks = floor($seconds / 604800); - if ($years > 0 OR $months > 0 OR $weeks > 0) + if ($years > 0 OR $months > 0 OR $weeks > 0) + { + if ($weeks > 0) { - if ($weeks > 0) - { - $str[] = $weeks.' '.$CI->lang->line((($weeks > 1) ? 'date_weeks' : 'date_week')); - } - - $seconds -= $weeks * 604800; + $str .= $weeks.' '.$CI->lang->line((($weeks > 1) ? 'date_weeks' : 'date_week')).', '; } - } - // days + $seconds -= $weeks * 604800; + } - if (count($str) < $units) { - $days = floor($seconds / 86400); + $days = floor($seconds / 86400); - if ($months > 0 OR $weeks > 0 OR $days > 0) + if ($months > 0 OR $weeks > 0 OR $days > 0) + { + if ($days > 0) { - if ($days > 0) - { - $str[] = $days.' '.$CI->lang->line((($days > 1) ? 'date_days' : 'date_day')); - } - - $seconds -= $days * 86400; + $str .= $days.' '.$CI->lang->line((($days > 1) ? 'date_days' : 'date_day')).', '; } - } - // hours - - if (count($str) < $units) { + $seconds -= $days * 86400; + } - $hours = floor($seconds / 3600); + $hours = floor($seconds / 3600); - if ($days > 0 OR $hours > 0) + if ($days > 0 OR $hours > 0) + { + if ($hours > 0) { - if ($hours > 0) - { - $str[] = $hours.' '.$CI->lang->line((($hours > 1) ? 'date_hours' : 'date_hour')); - } - - $seconds -= $hours * 3600; + $str .= $hours.' '.$CI->lang->line((($hours > 1) ? 'date_hours' : 'date_hour')).', '; } - } - - // minutes - if (count($str) < $units) { + $seconds -= $hours * 3600; + } - $minutes = floor($seconds / 60); + $minutes = floor($seconds / 60); - if ($days > 0 OR $hours > 0 OR $minutes > 0) + if ($days > 0 OR $hours > 0 OR $minutes > 0) + { + if ($minutes > 0) { - if ($minutes > 0) - { - $str[] = $minutes.' '.$CI->lang->line((($minutes > 1) ? 'date_minutes' : 'date_minute')); - } - - $seconds -= $minutes * 60; + $str .= $minutes.' '.$CI->lang->line((($minutes > 1) ? 'date_minutes' : 'date_minute')).', '; } - } - // seconds + $seconds -= $minutes * 60; + } - if (count($str) == 0) { - { - $str[] = $seconds.' '.$CI->lang->line((($seconds > 1) ? 'date_seconds' : 'date_second')); - } + if ($str == '') + { + $str .= $seconds.' '.$CI->lang->line((($seconds > 1) ? 'date_seconds' : 'date_second')).', '; } - return strtolower(implode(', ', $str)); + return substr(trim($str), 0, -1); } } -- cgit v1.2.3-24-g4f1b From 04c146d95dbc1c86e477bd27798d3234f74833e0 Mon Sep 17 00:00:00 2001 From: Roger Herbert Date: Sun, 11 Mar 2012 15:31:01 +0000 Subject: refactored to start from latest version, also less diff pain --- system/helpers/date_helper.php | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) (limited to 'system/helpers/date_helper.php') diff --git a/system/helpers/date_helper.php b/system/helpers/date_helper.php index 2a34cf93e..70b01e348 100644 --- a/system/helpers/date_helper.php +++ b/system/helpers/date_helper.php @@ -163,7 +163,7 @@ if ( ! function_exists('standard_date')) */ if ( ! function_exists('timespan')) { - function timespan($seconds = 1, $time = '') + function timespan($seconds = 1, $time = '', $units = '') { $CI =& get_instance(); $CI->lang->load('date'); @@ -178,24 +178,29 @@ if ( ! function_exists('timespan')) $time = time(); } + if ( ! is_numeric($units)) + { + $units = 999; + } + $seconds = ($time <= $seconds) ? 1 : $time - $seconds; - $str = ''; + $str = array(); $years = floor($seconds / 31557600); if ($years > 0) { - $str .= $years.' '.$CI->lang->line((($years > 1) ? 'date_years' : 'date_year')).', '; + $str[] = $years.' '.$CI->lang->line((($years > 1) ? 'date_years' : 'date_year')); } $seconds -= $years * 31557600; $months = floor($seconds / 2629743); - if ($years > 0 OR $months > 0) + if (count($str) < $units AND ($years > 0 OR $months > 0)) { if ($months > 0) { - $str .= $months.' '.$CI->lang->line((($months > 1) ? 'date_months' : 'date_month')).', '; + $str[] = $months.' '.$CI->lang->line((($months > 1) ? 'date_months' : 'date_month')); } $seconds -= $months * 2629743; @@ -203,11 +208,11 @@ if ( ! function_exists('timespan')) $weeks = floor($seconds / 604800); - if ($years > 0 OR $months > 0 OR $weeks > 0) + if (count($str) < $units AND ($years > 0 OR $months > 0 OR $weeks > 0)) { if ($weeks > 0) { - $str .= $weeks.' '.$CI->lang->line((($weeks > 1) ? 'date_weeks' : 'date_week')).', '; + $str[] = $weeks.' '.$CI->lang->line((($weeks > 1) ? 'date_weeks' : 'date_week')); } $seconds -= $weeks * 604800; @@ -215,11 +220,11 @@ if ( ! function_exists('timespan')) $days = floor($seconds / 86400); - if ($months > 0 OR $weeks > 0 OR $days > 0) + if (count($str) < $units AND ($months > 0 OR $weeks > 0 OR $days > 0)) { if ($days > 0) { - $str .= $days.' '.$CI->lang->line((($days > 1) ? 'date_days' : 'date_day')).', '; + $str[] = $days.' '.$CI->lang->line((($days > 1) ? 'date_days' : 'date_day')); } $seconds -= $days * 86400; @@ -227,11 +232,11 @@ if ( ! function_exists('timespan')) $hours = floor($seconds / 3600); - if ($days > 0 OR $hours > 0) + if (count($str) < $units AND ($days > 0 OR $hours > 0)) { if ($hours > 0) { - $str .= $hours.' '.$CI->lang->line((($hours > 1) ? 'date_hours' : 'date_hour')).', '; + $str[] = $hours.' '.$CI->lang->line((($hours > 1) ? 'date_hours' : 'date_hour')); } $seconds -= $hours * 3600; @@ -239,11 +244,11 @@ if ( ! function_exists('timespan')) $minutes = floor($seconds / 60); - if ($days > 0 OR $hours > 0 OR $minutes > 0) + if (count($str) < $units AND ($days > 0 OR $hours > 0 OR $minutes > 0)) { if ($minutes > 0) { - $str .= $minutes.' '.$CI->lang->line((($minutes > 1) ? 'date_minutes' : 'date_minute')).', '; + $str[] = $minutes.' '.$CI->lang->line((($minutes > 1) ? 'date_minutes' : 'date_minute')); } $seconds -= $minutes * 60; @@ -251,10 +256,10 @@ if ( ! function_exists('timespan')) if ($str == '') { - $str .= $seconds.' '.$CI->lang->line((($seconds > 1) ? 'date_seconds' : 'date_second')).', '; + $str[] = $seconds.' '.$CI->lang->line((($seconds > 1) ? 'date_seconds' : 'date_second')); } - return substr(trim($str), 0, -1); + return implode(', ', $str); } } -- cgit v1.2.3-24-g4f1b From b8fb66b38e233c82f0116f9bdb0fdfd4ee074b30 Mon Sep 17 00:00:00 2001 From: Roger Herbert Date: Sun, 11 Mar 2012 16:15:15 +0000 Subject: AND -> && --- system/helpers/date_helper.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'system/helpers/date_helper.php') diff --git a/system/helpers/date_helper.php b/system/helpers/date_helper.php index 70b01e348..e792ecc43 100644 --- a/system/helpers/date_helper.php +++ b/system/helpers/date_helper.php @@ -196,7 +196,7 @@ if ( ! function_exists('timespan')) $seconds -= $years * 31557600; $months = floor($seconds / 2629743); - if (count($str) < $units AND ($years > 0 OR $months > 0)) + if (count($str) < $units && ($years > 0 OR $months > 0)) { if ($months > 0) { @@ -208,7 +208,7 @@ if ( ! function_exists('timespan')) $weeks = floor($seconds / 604800); - if (count($str) < $units AND ($years > 0 OR $months > 0 OR $weeks > 0)) + if (count($str) < $units && ($years > 0 OR $months > 0 OR $weeks > 0)) { if ($weeks > 0) { @@ -220,7 +220,7 @@ if ( ! function_exists('timespan')) $days = floor($seconds / 86400); - if (count($str) < $units AND ($months > 0 OR $weeks > 0 OR $days > 0)) + if (count($str) < $units && ($months > 0 OR $weeks > 0 OR $days > 0)) { if ($days > 0) { @@ -232,7 +232,7 @@ if ( ! function_exists('timespan')) $hours = floor($seconds / 3600); - if (count($str) < $units AND ($days > 0 OR $hours > 0)) + if (count($str) < $units && ($days > 0 OR $hours > 0)) { if ($hours > 0) { @@ -244,7 +244,7 @@ if ( ! function_exists('timespan')) $minutes = floor($seconds / 60); - if (count($str) < $units AND ($days > 0 OR $hours > 0 OR $minutes > 0)) + if (count($str) < $units && ($days > 0 OR $hours > 0 OR $minutes > 0)) { if ($minutes > 0) { -- cgit v1.2.3-24-g4f1b From b81f909f8aaa3bedc3820c0d4c9056b57113b46e Mon Sep 17 00:00:00 2001 From: Roger Herbert Date: Mon, 12 Mar 2012 12:46:02 +0000 Subject: updated docs & changelog --- system/helpers/date_helper.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'system/helpers/date_helper.php') diff --git a/system/helpers/date_helper.php b/system/helpers/date_helper.php index e792ecc43..2ad287b4a 100644 --- a/system/helpers/date_helper.php +++ b/system/helpers/date_helper.php @@ -159,7 +159,8 @@ if ( ! function_exists('standard_date')) * @access public * @param integer a number of seconds * @param integer Unix timestamp - * @return integer + * @param integer a number of display units + * @return string */ if ( ! function_exists('timespan')) { -- cgit v1.2.3-24-g4f1b From 8d69aa166ca642cbbaed561878e22470720ecb78 Mon Sep 17 00:00:00 2001 From: Roger Herbert Date: Wed, 14 Mar 2012 08:44:55 +0000 Subject: changed default value for $units to 7 --- system/helpers/date_helper.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'system/helpers/date_helper.php') diff --git a/system/helpers/date_helper.php b/system/helpers/date_helper.php index 2ad287b4a..9eea02561 100644 --- a/system/helpers/date_helper.php +++ b/system/helpers/date_helper.php @@ -164,7 +164,7 @@ if ( ! function_exists('standard_date')) */ if ( ! function_exists('timespan')) { - function timespan($seconds = 1, $time = '', $units = '') + function timespan($seconds = 1, $time = '', $units = 7) { $CI =& get_instance(); $CI->lang->load('date'); @@ -181,7 +181,7 @@ if ( ! function_exists('timespan')) if ( ! is_numeric($units)) { - $units = 999; + $units = 7; } $seconds = ($time <= $seconds) ? 1 : $time - $seconds; -- cgit v1.2.3-24-g4f1b From 597eb2178a0e51c105ea1d15717a9912450eb110 Mon Sep 17 00:00:00 2001 From: Roger Herbert Date: Wed, 14 Mar 2012 09:06:17 +0000 Subject: check array count for seconds unit too --- system/helpers/date_helper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/helpers/date_helper.php') diff --git a/system/helpers/date_helper.php b/system/helpers/date_helper.php index 9eea02561..2cbfd5a92 100644 --- a/system/helpers/date_helper.php +++ b/system/helpers/date_helper.php @@ -255,7 +255,7 @@ if ( ! function_exists('timespan')) $seconds -= $minutes * 60; } - if ($str == '') + if (count($str) === 0) { $str[] = $seconds.' '.$CI->lang->line((($seconds > 1) ? 'date_seconds' : 'date_second')); } -- cgit v1.2.3-24-g4f1b From e684bdac2d6282e3b9a5c57e1006d5ed1664f647 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 26 Mar 2012 13:47:29 +0300 Subject: Clear some spaces and fix some inconsistencies in the Zip library and system/helpers/ files --- system/helpers/date_helper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/helpers/date_helper.php') diff --git a/system/helpers/date_helper.php b/system/helpers/date_helper.php index d54553292..66f21c1f5 100644 --- a/system/helpers/date_helper.php +++ b/system/helpers/date_helper.php @@ -1,4 +1,4 @@ - Date: Mon, 26 Mar 2012 22:44:20 +0300 Subject: Remove remaining access description lines from helpers + some style fixes --- system/helpers/date_helper.php | 67 ++++++++++++++++-------------------------- 1 file changed, 26 insertions(+), 41 deletions(-) (limited to 'system/helpers/date_helper.php') diff --git a/system/helpers/date_helper.php b/system/helpers/date_helper.php index 66f21c1f5..f1ba364f5 100644 --- a/system/helpers/date_helper.php +++ b/system/helpers/date_helper.php @@ -25,8 +25,6 @@ * @filesource */ -// ------------------------------------------------------------------------ - /** * CodeIgniter Date Helpers * @@ -44,8 +42,7 @@ * * Returns time() or its GMT equivalent based on the config file preference * - * @access public - * @return integer + * @return int */ if ( ! function_exists('now')) { @@ -85,10 +82,9 @@ if ( ! function_exists('now')) * have to worry about escaping your text letters that * match the date codes. * - * @access public * @param string - * @param integer - * @return integer + * @param int + * @return int */ if ( ! function_exists('mdate')) { @@ -118,9 +114,8 @@ if ( ! function_exists('mdate')) * * Returns a date formatted according to the submitted standard. * - * @access public * @param string the chosen format - * @param integer Unix timestamp + * @param int Unix timestamp * @return string */ if ( ! function_exists('standard_date')) @@ -157,10 +152,9 @@ if ( ! function_exists('standard_date')) * Returns a span of seconds in this format: * 10 days 14 hours 36 minutes 47 seconds * - * @access public - * @param integer a number of seconds - * @param integer Unix timestamp - * @param integer a number of display units + * @param int a number of seconds + * @param int Unix timestamp + * @param int a number of display units * @return string */ if ( ! function_exists('timespan')) @@ -273,10 +267,9 @@ if ( ! function_exists('timespan')) * Takes a month/year as input and returns the number of days * for the given month/year. Takes leap years into consideration. * - * @access public - * @param integer a numeric month - * @param integer a numeric year - * @return integer + * @param int a numeric month + * @param int a numeric year + * @return int */ if ( ! function_exists('days_in_month')) { @@ -294,7 +287,7 @@ if ( ! function_exists('days_in_month')) if ($month == 2) { - if ($year % 400 == 0 OR ($year % 4 == 0 AND $year % 100 != 0)) + if ($year % 400 == 0 OR ($year % 4 == 0 && $year % 100 != 0)) { return 29; } @@ -310,9 +303,8 @@ if ( ! function_exists('days_in_month')) /** * Converts a local Unix timestamp to GMT * - * @access public - * @param integer Unix timestamp - * @return integer + * @param int Unix timestamp + * @return int */ if ( ! function_exists('local_to_gmt')) { @@ -343,11 +335,10 @@ if ( ! function_exists('local_to_gmt')) * at the local value based on the timezone and DST setting * submitted * - * @access public - * @param integer Unix timestamp + * @param int Unix timestamp * @param string timezone * @param bool whether DST is active - * @return integer + * @return int */ if ( ! function_exists('gmt_to_local')) { @@ -374,9 +365,8 @@ if ( ! function_exists('gmt_to_local')) /** * Converts a MySQL Timestamp to Unix * - * @access public - * @param integer Unix timestamp - * @return integer + * @param int Unix timestamp + * @return int */ if ( ! function_exists('mysql_to_unix')) { @@ -409,8 +399,7 @@ if ( ! function_exists('mysql_to_unix')) * * Formats Unix timestamp to the following prototype: 2006-08-21 11:35 PM * - * @access public - * @param integer Unix timestamp + * @param int Unix timestamp * @param bool whether to show seconds * @param string format: us or euro * @return string @@ -451,9 +440,8 @@ if ( ! function_exists('unix_to_human')) * * Reverses the above process * - * @access public * @param string format: us or euro - * @return integer + * @return int */ if ( ! function_exists('human_to_unix')) { @@ -499,12 +487,12 @@ if ( ! function_exists('human_to_unix')) { $ampm = strtolower($split['2']); - if (substr($ampm, 0, 1) == 'p' AND $hour < 12) + if (substr($ampm, 0, 1) === 'p' && $hour < 12) { $hour = $hour + 12; } - if (substr($ampm, 0, 1) == 'a' AND $hour == 12) + if (substr($ampm, 0, 1) === 'a' && $hour == 12) { $hour = '00'; } @@ -525,10 +513,9 @@ if ( ! function_exists('human_to_unix')) * Turns many "reasonably-date-like" strings into something * that is actually useful. This only works for dates after unix epoch. * - * @access public - * @param string The terribly formatted date-like string - * @param string Date format to return (same as php date function) - * @return string + * @param string The terribly formatted date-like string + * @param string Date format to return (same as php date function) + * @return string */ if ( ! function_exists('nice_date')) { @@ -593,7 +580,6 @@ if ( ! function_exists('nice_date')) * * Generates a drop-down menu of timezones. * - * @access public * @param string timezone * @param string classname * @param string menu name @@ -634,10 +620,9 @@ if ( ! function_exists('timezone_menu')) /** * Timezones * - * Returns an array of timezones. This is a helper function + * Returns an array of timezones. This is a helper function * for various other ones in this library * - * @access public * @param string timezone * @return string */ @@ -698,7 +683,7 @@ if ( ! function_exists('timezones')) $tz = ($tz == 'GMT') ? 'UTC' : $tz; - return ( ! isset($zones[$tz])) ? 0 : $zones[$tz]; + return isset($zones[$tz]) ? $zones[$tz] : 0; } } -- cgit v1.2.3-24-g4f1b