Changeset 948

Show
Ignore:
Timestamp:
11/01/2007 03:41:30 PM (13 months ago)
Author:
zombor
Message:

Update hours function. 24 hour time goes from 0 to 23 and regular time goes from 1 to 12.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/system/helpers/date.php

    r919 r948  
    107107         *  step - amount to increment each step by 
    108108         *  long - use 24-hour time 
    109          * 
    110          * Returns: 
    111          *  A mirrored (foo => foo) array from 1-12 or 1-24. 
    112          */ 
    113         public static function hours($step = 1, $long = FALSE, $start = 0) 
     109         *  start - the hour to start at (24-hour time probably wants a 0 here) 
     110         * 
     111         * Returns: 
     112         *  A mirrored (foo => foo) array from start-12 or start-23. 
     113         */ 
     114        public static function hours($step = 1, $long = FALSE, $start = 1) 
    114115        { 
    115116                static $hours; 
     
    127128 
    128129                        // 24-hour time has 24 hours, instead of 12 
    129                         $size = ($long == TRUE) ? 24 : 12; 
    130  
    131                         for ($i = $start; $i < $size; $i += $step) 
     130                        $size = ($long == TRUE) ? 23 : 12; 
     131 
     132                        for ($i = $start; $i <= $size; $i += $step) 
    132133                        { 
    133134                                $hours[$cache][$step][$i] = $i; 
     
    204205        public static function months() 
    205206        { 
    206                 return self::hours(1, FALSE); 
     207                return self::hours(1, FALSE, 1); 
    207208        } 
    208209