private function getProlepticYear() { return $this->isoDate->getYear() + ThaiBuddhistChronology::YEARS_DIFFERENCE; }
/** * @internal * @param LocalDate $date * @return int */ public static function getWeekBasedYear(LocalDate $date) { $year = $date->getYear(); $doy = $date->getDayOfYear(); if ($doy <= 3) { $dow = $date->getDayOfWeek()->getValue() - 1; if ($doy - $dow < -2) { $year--; } } else { if ($doy >= 363) { $dow = $date->getDayOfWeek()->getValue() - 1; $doy = $doy - 363 - ($date->isLeapYear() ? 1 : 0); if ($doy - $dow >= 0) { $year++; } } } return $year; }
private function next(LocalDate $date) { $newDayOfMonth = $date->getDayOfMonth() + 1; if ($newDayOfMonth <= $date->getMonth()->length(Year::isLeapYear($date->getYear()))) { return $date->withDayOfMonth($newDayOfMonth); } $date = $date->withDayOfMonth(1); if ($date->getMonth() == Month::DECEMBER()) { $date = $date->withYear($date->getYear() + 1); } return $date->adjust($date->getMonth()->plus(1)); }
/** * @dataProvider data_quarter */ public function test_parse_quarters_LENIENT(LocalDate $date, $doq, $qoy) { $f = (new DateTimeFormatterBuilder())->appendValue(CF::YEAR())->appendLiteral('-')->appendValue(IsoFields::QUARTER_OF_YEAR())->appendLiteral('-')->appendValue(IsoFields::DAY_OF_QUARTER())->toFormatter()->withResolverStyle(ResolverStyle::LENIENT()); $parsed = LocalDate::parseWith($date->getYear() . "-" . $qoy . "-" . $doq, $f); $this->assertEquals($parsed, $date); }
private function getProlepticYear() { return $this->isoDate->getYear() - MinguoChronology::YEARS_DIFFERENCE; }
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(); }
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())); } }
/** * @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); }