Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- defined('BASEPATH') OR exit('No direct script access allowed');
- /**
- * Time Helper
- *
- * @package CodeIgniter
- * @subpackage Helpers
- * @category Time Helper
- * @author Kader Bouyakoub <bkader@mail.com>
- * @link @KaderBouyakoub
- */
- if ( ! function_exists('list_minutes'))
- {
- /**
- * List 60 minutes with optional limit
- *
- * @access public
- * @param integer
- * @return array
- */
- function list_minutes($limit = 60)
- {
- $minutes = array();
- if ($limit > 60) $limit = 60;
- for($m = 0; $m <= $limit; $m++)
- {
- $minute = str_pad($m, 2, '0', STR_PAD_LEFT);
- $minutes[$minute] = $minute;
- }
- return $minutes;
- }
- }
- // ------------------------------------------------------------------------
- if ( ! function_exists('list_hours'))
- {
- /**
- * List 24 hours with optional limit
- *
- * @access public
- * @param integer
- * @return array
- */
- function list_hours($limit = 24)
- {
- $hours = array();
- if ($limit > 24) $limit = 24;
- for($h = 1; $h <= $limit; $h++)
- {
- $hour = str_pad($h, 2, '0', STR_PAD_LEFT);
- $hours[$hour] = $hour;
- }
- return $hours;
- }
- }
- // ------------------------------------------------------------------------
- if ( ! function_exists('list_days'))
- {
- /**
- * List days with optional limit
- *
- * @access public
- * @param integer
- * @return array
- */
- function list_days($limit = 31)
- {
- $days = array();
- if ($limit > 31) $limit = 31;
- for($d = 1; $d <= $limit; $d++)
- {
- $day = str_pad($d, 2, '0', STR_PAD_LEFT);
- $days[$day] = $day;
- }
- return $days;
- }
- }
- // ------------------------------------------------------------------------
- if ( ! function_exists('list_months'))
- {
- function list_months($limit = 12)
- {
- /**
- * List months with optional limit
- *
- * @access public
- * @param void
- * @return array
- */
- $CI =& get_instance();
- $CI->load->helper('language');
- // As you can see below, I use my own I18n library
- // You can use the language you want or you can
- // simple add a new parameter to this function to
- // load your own language.
- $CI->lang->load('calendar', I18n::get_current('folder'));
- $months = array(
- '01' => lang('cal_jan'),
- '02' => lang('cal_feb'),
- '03' => lang('cal_mar'),
- '04' => lang('cal_apr'),
- '05' => lang('cal_may'),
- '06' => lang('cal_jun'),
- '07' => lang('cal_jul'),
- '08' => lang('cal_aug'),
- '09' => lang('cal_sep'),
- '10' => lang('cal_oct'),
- '11' => lang('cal_nov'),
- '12' => lang('cal_dec')
- );
- if ($limit > 12) $limit = 12;
- return array_slice($months, 0, $limit, TRUE);
- }
- }
- // ------------------------------------------------------------------------
- if ( ! function_exists('list_years'))
- {
- /**
- * List years with optional difference and quantity
- *
- * @access public
- * @param integer
- * @param integer
- * @return array
- */
- function list_years($diff = 0, $qty = 100)
- {
- $years = array();
- for ($y = date('Y') - $diff; $y >= date('Y') - $qty; $y--)
- {
- $years[$y] = $y;
- }
- return $years;
- }
- }
- /* End of file time_helper.php */
- /* Location: ./application/helpers/time_helper.php */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement