/** * Gets the nano-of-second field. * * @return int the nano-of-second, from 0 to 999,999,999 */ public function getNano() { return $this->dateTime->getNano(); }
/** * Obtains an instance defining a transition between two offsets. * <p> * Applications should normally obtain an instance from {@link ZoneRules}. * This factory is only intended for use when creating {@link ZoneRules}. * * @param LocalDateTime $transition the transition date-time at the transition, which never * actually occurs, expressed local to the before offset, not null * @param ZoneOffset $offsetBefore the offset before the transition, not null * @param ZoneOffset $offsetAfter the offset at and after the transition, not null * @return ZoneOffsetTransition the transition, not null * @throws IllegalArgumentException if {@code offsetBefore} and {@code offsetAfter} * are equal, or {@code transition.getNano()} returns non-zero value */ public static function of(LocalDateTime $transition, ZoneOffset $offsetBefore, ZoneOffset $offsetAfter) { if ($offsetBefore->equals($offsetAfter)) { throw new IllegalArgumentException("Offsets must not be equal"); } if ($transition->getNano() != 0) { throw new IllegalArgumentException("Nano-of-second must be zero"); } return new ZoneOffsetTransition($transition, $offsetBefore, $offsetAfter); }
private function check(LocalDateTime $test, $y, $m, $d, $h, $mi, $s, $n) { $this->assertEquals($test->getYear(), $y); $this->assertEquals($test->getMonth()->getValue(), $m); $this->assertEquals($test->getDayOfMonth(), $d); $this->assertEquals($test->getHour(), $h); $this->assertEquals($test->getMinute(), $mi); $this->assertEquals($test->getSecond(), $s); $this->assertEquals($test->getNano(), $n); $this->assertEquals($test, $test); //$this->assertEquals($test->hashCode(), $test->hashCode()); $this->assertEquals(LocalDateTime::of($y, $m, $d, $h, $mi, $s, $n), $test); }
public function setFieldsDateTime(LocalDateTime $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())); $this->fields->put(ChronoField::HOUR_OF_DAY(), $dt->getHour()); $this->fields->put(ChronoField::MINUTE_OF_HOUR(), $dt->getMinute()); $this->fields->put(ChronoField::SECOND_OF_MINUTE(), $dt->getSecond()); $this->fields->put(ChronoField::NANO_OF_SECOND(), $dt->getNano()); } }