Changeset 3186
- Timestamp:
- 07/22/2008 12:39:15 AM (3 months ago)
- Files:
-
- 1 modified
-
trunk/system/libraries/Calendar.php (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/system/libraries/Calendar.php
r3185 r3186 12 12 class Calendar_Core extends Event_Subject { 13 13 14 // Start the calendar on Sunday by default 15 public static $start_monday = FALSE; 16 14 17 // Month and year to use for calendaring 15 18 protected $month; 16 19 protected $year; 17 20 18 // Start the calendar on Sunday by default19 p ublic$week_start = 0;21 // Week starts on Sunday 22 protected $week_start = 0; 20 23 21 24 // Observed data … … 34 37 35 38 // Days of the week 36 $headings = array('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'); 39 $days = array('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'); 40 41 if (Calendar::$start_monday === TRUE) 42 { 43 // Push Sunday to the end of the days 44 array_push($days, array_shift($days)); 45 } 37 46 38 47 if (strpos(Kohana::config('locale.language.0'), 'en') !== 0) 39 48 { 40 49 // This is a bit awkward, but it works properly and is reliable 41 foreach ($ headings as $i => $day)50 foreach ($days as $i => $day) 42 51 { 43 52 // Convert the English names to i18n names 44 $ headings[$i] = strftime($format, strtotime($day));53 $days[$i] = strftime($format, strtotime($day)); 45 54 } 46 55 } 47 56 elseif ($short == TRUE) 48 57 { 49 foreach ($ headings as $i => $day)58 foreach ($days as $i => $day) 50 59 { 51 60 // Shorten the day names to 3 letters 52 $ headings[$i] = substr($day, 0, 3);53 } 54 } 55 56 return $ headings;61 $days[$i] = substr($day, 0, 3); 62 } 63 } 64 65 return $days; 57 66 } 58 67 … … 63 72 * @param integer month number 64 73 * @param integer year number 65 * @param boolean start weeks on monday66 74 * @return object 67 75 */ 68 public static function factory($month = NULL, $year = NULL , $start_monday = NULL)69 { 70 return new Calendar($month, $year , $start_monday);76 public static function factory($month = NULL, $year = NULL) 77 { 78 return new Calendar($month, $year); 71 79 } 72 80 … … 77 85 * @param integer month number 78 86 * @param integer year number 79 * @param boolean start weeks on monday80 87 * @return void 81 88 */ 82 public function __construct($month = NULL, $year = NULL , $start_monday = NULL)89 public function __construct($month = NULL, $year = NULL) 83 90 { 84 91 empty($month) and $month = date('n'); // Current month … … 89 96 $this->year = (int) $year; 90 97 91 if ( $start_monday === TRUE)92 { 93 // Some locales start the week on Monday, not Sunday.98 if (Calendar::$start_monday === TRUE) 99 { 100 // Week starts on Monday 94 101 $this->week_start = 1; 95 102 }
