| [ Index ] |
PHP Cross Reference of Limb3 |
[Summary view] [Print] [Text view]
1 <?php 2 /* 3 * Limb PHP Framework 4 * 5 * @link http://limb-project.com 6 * @copyright Copyright © 2004-2007 BIT(http://bit-creative.com) 7 * @license LGPL http://www.gnu.org/copyleft/lesser.html 8 */ 9 lmb_require('limb/datetime/src/lmbDate.class.php'); 10 11 /** 12 * class lmbMonth. 13 * 14 * @package datetime 15 * @version $Id$ 16 */ 17 class lmbMonth 18 { 19 protected $start_date; 20 protected $end_date; 21 22 function __construct($year_or_date = null, $month = null) 23 { 24 if($year_or_date && $month) 25 $tmp_date = new lmbDate($year_or_date, $month, 1); 26 elseif($year_or_date && !$month) 27 $tmp_date = new lmbDate($year_or_date); 28 else 29 $tmp_date = new lmbDate(); 30 31 $this->start_date = $tmp_date->getBeginOfMonth(); 32 $this->end_date = $tmp_date->getEndOfMonth(); 33 } 34 35 function getMonth() 36 { 37 return $this->start_date->getMonth(); 38 } 39 40 function getMonthName() 41 { 42 return $this->start_date->date('M'); 43 } 44 45 function getMonthShortName() 46 { 47 return $this->start_date->date('F'); 48 } 49 50 function getYear() 51 { 52 return $this->start_date->getYear(); 53 } 54 55 function getStartDate() 56 { 57 return $this->start_date; 58 } 59 60 function getEndDate() 61 { 62 return $this->end_date; 63 } 64 65 function getNumberOfDays() 66 { 67 return $this->end_date->getDay(); 68 } 69 70 function getNumberOfWeeks() 71 { 72 $dow = $this->start_date->getPhpDayOfWeek(); 73 74 if(lmbDate :: getWeekStartsAt() == 1 && $dow == 0) 75 { 76 $first_week_days = 7 - $dow + lmbDate :: getWeekStartsAt(); 77 $weeks = 1; 78 } 79 elseif(lmbDate :: getWeekStartsAt() == 0 && $dow == 6) 80 { 81 $first_week_days = 7 - $dow + lmbDate :: getWeekStartsAt(); 82 $weeks = 1; 83 } 84 else 85 { 86 $first_week_days = lmbDate :: getWeekStartsAt() - $dow; 87 $weeks = 0; 88 } 89 90 $first_week_days %= 7; 91 return ceil(($this->getNumberOfDays() - $first_week_days) / 7) + $weeks; 92 } 93 94 function getWeek($n) 95 { 96 if($n < 0 || $n > $this->getNumberOfWeeks()-1) 97 return null; 98 99 $week_array = array(); 100 $curr_day = ($n * 7) + $this->start_date->getBeginOfWeek()->getDateDays(); 101 102 for($i=0;$i<=6;$i++) 103 { 104 $week_array[$i] = lmbDate :: createByDays($curr_day); 105 $curr_day++; 106 } 107 return $week_array; 108 } 109 110 function getAllWeeks() 111 { 112 $weeks = array(); 113 for($i = 0; $i < $this->getNumberOfWeeks(); $i++) 114 $weeks[$i] = $this->getWeek($i); 115 return $weeks; 116 } 117 118 function getNextMonth() 119 { 120 $date = $this->end_date->addDay(1); 121 return new lmbMonth($date->getYear(), $date->getMonth()); 122 } 123 124 function getPrevMonth() 125 { 126 $date = $this->start_date->addDay(-1); 127 return new lmbMonth($date->getYear(), $date->getMonth()); 128 } 129 } 130 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Fri Dec 5 04:05:07 2008 | Cross-referenced by PHPXref 0.7 |