Beispiel #1
0
 /**
  * @covers Mce\Date\Math\Month::getNWeekday
  */
 public function testGetNWeekday()
 {
     // test the basic functionality
     $n = 3;
     $weekday = 3;
     $month = new DateTime('2013-04-01');
     $expected = new DateTime('2013-04-17');
     $actual = Month::getNWeekday($n, $weekday, $month);
     $this->assertEquals($actual, $expected);
     // out of bounds
     $n = 5;
     $this->setExpectedException('\\RangeException');
     Month::getNWeekday(5, $weekday, $month);
 }
Beispiel #2
0
 /**
  * Gets the number of weeks that exist in a given month.
  * 
  * @param \DateTime $month
  * @param int $weekStart ISO-8601 numeric representation of the day of the 
  *                       week (1 = Monday,..., 7 = Sunday)
  * @return int 
  */
 public static function getMaxNumber(\DateTime $month, $weekStart = 1)
 {
     $firstWeekdayOfMonth = Month::getFirstWeekday($weekStart, $month);
     $firstDay = intval($firstWeekdayOfMonth->format("j"));
     $lastDay = intval($month->format("t"));
     return (int) floor(($lastDay - $firstDay) / 7) + 1;
 }