Beispiel #1
0
 public function testFromNativeDateTime()
 {
     $nativeDateTime = new \DateTime();
     $nativeDateTime->setDate(2013, 12, 1);
     $month = Month::fromNativeDateTime($nativeDateTime);
     $this->assertEquals('December', $month->toNative());
 }
Beispiel #2
0
 /**
  * Returns a new Date from a native PHP \DateTime
  *
  * @param  \DateTime $date
  * @return Date
  */
 public static function fromNativeDateTime(\DateTime $date)
 {
     $year = \intval($date->format('Y'));
     $month = Month::fromNativeDateTime($date);
     $day = \intval($date->format('d'));
     return new static(new Year($year), $month, new MonthDay($day));
 }