/** * @param LocalTime|null $expectedTime * @dataProvider data_resolveFourToTime */ public function test_resolveThreeToTime($style, $hour, $min, $sec, $nano, $expectedTime, $excessPeriod) { $f = (new DateTimeFormatterBuilder())->parseDefaulting(ChronoField::HOUR_OF_DAY(), $hour)->parseDefaulting(ChronoField::MINUTE_OF_HOUR(), $min)->parseDefaulting(ChronoField::SECOND_OF_MINUTE(), $sec)->toFormatter(); $styles = $style !== null ? [$style] : ResolverStyle::values(); foreach ($styles as $s) { if ($expectedTime !== null) { $accessor = $f->withResolverStyle($s)->parse(""); $this->assertEquals($accessor->query(TemporalQueries::localDate()), null, "ResolverStyle: " . $s); $this->assertEquals($accessor->query(TemporalQueries::localTime()), $expectedTime->minusNanos($nano), "ResolverStyle: " . $s); $this->assertEquals($accessor->query(DateTimeFormatter::parsedExcessDays()), $excessPeriod, "ResolverStyle: " . $s); } else { try { $f->withResolverStyle($style)->parse(""); $this->fail(); } catch (DateTimeParseException $ex) { // $expected } } } }
/** * Returns a copy of this {@code OffsetTime} with the specified number of nanoseconds subtracted. * <p> * This subtracts the specified number of nanoseconds from this time, returning a new time. * The calculation wraps around midnight. * <p> * This instance is immutable and unaffected by this method call. * * @param int $nanos the nanos to subtract, may be negative * @return OffsetTime an {@code OffsetTime} based on this time with the nanoseconds subtracted, not null */ public function minusNanos($nanos) { return $this->_with($this->time->minusNanos($nanos), $this->offset); }