Ejemplo n.º 1
0
 /**
  * Returns the day-of-year, from 1 to 365, or 366 in a leap year.
  *
  * @return integer
  */
 public function getDayOfYear()
 {
     return Month::of($this->month)->getFirstDayOfYear($this->isLeapYear()) + $this->day - 1;
 }
Ejemplo n.º 2
0
 /**
  * Returns the length of the month in days, taking account of the year.
  *
  * @return integer
  */
 public function getLengthOfMonth()
 {
     return Month::of($this->month)->getLength($this->isLeapYear());
 }
Ejemplo n.º 3
0
 /**
  * Returns the month that is the specified number of months after this one.
  *
  * The calculation rolls around the end of the year from December to January.
  * The specified period may be negative.
  *
  * @param integer $months
  *
  * @return Month
  */
 public function plus($months)
 {
     $months = Cast::toInteger($months);
     return Month::get((($this->month - 1 + $months) % 12 + 12) % 12 + 1);
 }
Ejemplo n.º 4
0
 /**
  * @dataProvider providerToString
  *
  * @param string  $month        The month number.
  * @param integer $expectedName The expected month name.
  */
 public function testToString($month, $expectedName)
 {
     $this->assertSame($expectedName, (string) Month::of($month));
 }
Ejemplo n.º 5
0
 /**
  * @param integer $monthValue The expected month-of-year value, from 1 to 12.
  * @param Month   $month      The Month instance to test.
  */
 protected function assertMonthIs($monthValue, Month $month)
 {
     $this->compare([$monthValue], [$month->getValue()]);
 }