public function test_with_adjustment() { $sample = LocalDateTime::of(2012, 3, 4, 23, 5); $adjuster = TemporalAdjusters::fromCallable(function ($s) use($sample) { return $sample; }); $this->assertEquals(self::TEST_200707_15_12_30_40_987654321()->adjust($adjuster), $sample); }
public function test_with_adjustment() { $sample = OffsetDateTime::ofDateAndTime(LocalDate::of(2012, 3, 4), LocalTime::of(23, 5), self::OFFSET_PONE()); $adjuster = TemporalAdjusters::fromCallable(function () use($sample) { return $sample; }); $this->assertEquals(self::TEST_2008_6_30_11_30_59_000000500()->adjust($adjuster), $sample); }
public function test_with_adjustment() { $sample = LocalDate::of(2012, 3, 4); $adjuster = TemporalAdjusters::fromCallable(function () use($sample) { return $sample; }); $this->assertEquals(self::TEST_2007_07_15()->adjust($adjuster), $sample); }
/** * Obtains a {@code TemporalAdjuster} that wraps a date adjuster. * <p> * The {@code TemporalAdjuster} is based on the low level {@code Temporal} interface. * This method allows an adjustment from {@code LocalDate} to {@code LocalDate} * to be wrapped to match the temporal-based interface. * This is provided for convenience to make user-written adjusters simpler. * <p> * In general, user-written adjusters should be static constants: * <pre>{@code * static TemporalAdjuster TWO_DAYS_LATER = * TemporalAdjusters.ofDateAdjuster(date -> date.plusDays(2)); * }</pre> * * @param $dateBasedAdjuster callable the date-based adjuster, not null * @return TemporalAdjuster the temporal adjuster wrapping on the date adjuster, not null */ public static function ofDateAdjuster(callable $dateBasedAdjuster) { return TemporalAdjusters::fromCallable(function (Temporal $temporal) use($dateBasedAdjuster) { $input = LocalDate::from($temporal); $output = $dateBasedAdjuster($input); return $temporal->adjust($output); }); }
public function test_with_adjustment() { $sample = LocalTime::of(23, 5); $adjuster = TemporalAdjusters::fromCallable(function (Temporal $dateTime) use($sample) { return $sample; }); $this->assertEquals(self::TEST_123040987654321()->adjust($adjuster), $sample); }
public function test_with_adjustment_AmPm() { $adjuster = TemporalAdjusters::fromCallable(function (Temporal $dateTime) { return $dateTime->with(CF::HOUR_OF_DAY(), 23); }); $test = self::TEST_11_30_59_500_PONE()->adjust($adjuster); $this->assertEquals($test, OffsetTime::of(23, 30, 59, 500, self::OFFSET_PONE())); }