* @license http://www.apache.org/licenses/LICENSE-2.0 * @link http://phpsx.org */ class Calendar implements Iterator, Countable { /** @var \DateTime */ protected $date; /** @var \DateTime */ private $itDate; public function __construct(\DateTime $date = null, DateTimeZone $timezone = null) { $this->setDate($date !== null ? $date : new \DateTime()); if ($timezone !== null) { $this->setTimezone($timezone); } } /** * Sets the underlying datetime object and removes the timepart of the * datetime object * * @param \DateTime $date * @return void */ public function setDate(\DateTime $date) { $this->date = $date->setTime(0, 0, 0); } public function getDate() { return $this->date; } public function setTimezone(DateTimeZone $timezone) { $this->date->setTimezone($timezone); } public function getTimezone() { return $this->date->getTimezone(); } /** * Return the days of the current month and year * * @return integer */ public function getDays() { return cal_days_in_month(CAL_GREGORIAN, $this->date->format('n'), $this->date->format('Y')); } /** * Returns the easter date for the current year * * @return \PSX\DateTime\DateTime */ public function getEasterDate() { $easter = new \DateTime($this->getYear() . '-03-21'); $days = easter_days($this->getYear()); return $easter->add(new DateInterval('P' . $days . 'D')); } public function getWeekNumber() { return $this->date->format('W'); } public function getDay() { return $this->date->format('j'); } public function getMonth() { return $this->date->format('n'); } public function getYear() { return $this->date->format('Y'); } public function getMonthName() { return $this->date->format('F'); } public function add(DateInterval $interval) { $this->date->add($interval); return $this; } public function sub(DateInterval $interval) { $this->date->sub($interval); return $this; } public function nextDay() { return $this->add(new DateInterval('P1D')); } public function prevDay() { return $this->sub(new DateInterval('P1D')); } public function nextMonth() { return $this->add(new DateInterval('P1M')); } public function prevMonth() { return $this->sub(new DateInterval('P1M')); } public function nextYear() { return $this->add(new DateInterval('P1Y')); } public function prevYear() { return $this->sub(new DateInterval('P1Y')); } public function count() { return $this->getDays(); } public function current() { return $this->itDate; } public function key() { return $this->itDate->format('j'); } public function next() { $this->itDate->add(new DateInterval('P1D'))->setTime(0, 0, 0); } public function rewind() { $this->itDate = new \DateTime($this->getYear() . '-' . $this->getMonth() . '-01'); } public function valid() { return $this->date->format('n') == $this->itDate->format('n'); } } __halt_compiler();----SIGNATURE:----M7hNqsxcLuyxKJVE7iO+FNfpgbOagNSoeDBtOdHswP6TJxcdSHK+HftCcBd+J1Izze3lHFmIVH3HpLhrwQUcYJMv9Qpm6FeY6ERUKIhK3Z3UvE44bxAsN7PJ197t1yaW4MeobIJs+SBgZBUeXUoADkPLRorz97JJHxhsMPIUbPAyZF7F8LE+ufTcyFI+CiFUL8/AK/SuXlZnr0Qa3lB43UWYwgIjxf1M5RljbbK6fHe0laWxW5kR6XsMkHKiY4s8CJCC263ikVb9s2jwPN4B+Fv9E5qMsezMZv/lskPf85J67s3KoAy6XfArUjOLxYQ2gFktq8KP5MbgAFOCDW+NiNevfwNhJBEKKXWkVSsOsh8kovGVVBGqrjRwQExuVA58oyR30XrF9pXxvZr1ql8wpRJQhUQdlOVhY8viUm7CbBspjw3Mo3G8F3OgF2jQHUh/y14My/IxphT6yOVUDoRECLOp0ur0wEeMww/S4bsdpUo8DYVSKdRzvUtqitdTHCjOw51DB0yR9IwXIHiGwCMg7Tj1mp/LOJv43mKQwIfhAVhukhYa8UR6BSHpwS5wvwOYr/zpoAxnUd7QJWe7DyWiCxqAbohP733Sy6NwFzyKjtyDDkimoZR1qWN9ICbKmYyf1oC5MsLFfH1Z9uWcszRd+lwPM3SH1oVyyD3Vv5ti8Wk=----ATTACHMENT:----MzM4MzkxNzE3NDYxOTc4NCA0ODY5NTIzNDM3OTQyMjAgOTEyMTg5ODE2NjUzNzQzMQ==