Ejemplo n.º 1
0
 private function getProlepticMonth()
 {
     return $this->getProlepticYear() * 12 + $this->isoDate->getMonthValue() - 1;
 }
 public function setFields(LocalDate $dt)
 {
     if ($dt !== null) {
         $this->fields->put(ChronoField::YEAR(), $dt->getYear());
         $this->fields->put(ChronoField::MONTH_OF_YEAR(), $dt->getMonthValue());
         $this->fields->put(ChronoField::DAY_OF_MONTH(), $dt->getDayOfMonth());
         $this->fields->put(ChronoField::DAY_OF_YEAR(), $dt->getDayOfYear());
         $this->fields->put(ChronoField::DAY_OF_WEEK(), $dt->getDayOfWeek()->getValue());
         $this->fields->put(IsoFields::WEEK_BASED_YEAR(), $dt->getLong(IsoFields::WEEK_BASED_YEAR()));
         $this->fields->put(IsoFields::WEEK_OF_WEEK_BASED_YEAR(), $dt->getLong(IsoFields::WEEK_OF_WEEK_BASED_YEAR()));
     }
 }
Ejemplo n.º 3
0
 public function serialize()
 {
     return $this->date->getYear() . ':' . $this->date->getMonthValue() . ':' . $this->date->getDayOfMonth() . ':' . $this->time->getHour() . ':' . $this->time->getMinute() . ':' . $this->time->getSecond() . ':' . $this->time->getNano();
 }
 /**
  * @dataProvider data_date
  */
 public function test_date_parse(LocalDate $date, FormatStyle $dateStyle, $dateStyleOld, Locale $locale)
 {
     $old = \IntlDateFormatter::create($locale->getLocale(), $dateStyleOld, \IntlDateFormatter::NONE, new \DateTimeZone('UTC'));
     $oldDate = new \DateTime($date->getYear() . '-' . $date->getMonthValue() . '-' . $date->getDayOfMonth(), new \DateTimeZone('UTC'));
     $text = $old->format($oldDate);
     $f = $this->builder->appendLocalized($dateStyle, null)->toFormatter2($locale);
     $parsed = $f->parsePos($text, $this->pos);
     $this->assertEquals($this->pos->getIndex(), strlen($text));
     $this->assertEquals($this->pos->getErrorIndex(), -1);
     $this->assertEquals(LocalDate::from($parsed), $date);
 }