public function test_with_adjuster_OffsetTime_validOffsetIntoOverlap2() { // OT has valid $offset for resulting time $ot = OffsetTime::of(2, 30, 30, 40, self::OFFSET_0200()); // valid $offset in overlap $zdt = $this->dateTimeZoned(2008, 10, 26, 0, 0, 0, 0, self::OFFSET_0200(), self::ZONE_PARIS()); // just $before overlap $test = $zdt->adjust($ot); $this->assertEquals($test->toLocalDateTime(), $this->dateTime(2008, 10, 26, 2, 30, 30, 40)); $this->assertEquals($test->getOffset(), self::OFFSET_0200()); }
function data_adjustInto() { return [[LocalDateTime::of(2012, 3, 4, 23, 5), LocalDateTime::of(2012, 3, 4, 1, 1, 1, 100), LocalDateTime::of(2012, 3, 4, 23, 5, 0, 0), null], [LocalDateTime::ofMonth(2012, Month::MARCH(), 4, 0, 0), LocalDateTime::of(2012, 3, 4, 1, 1, 1, 100), LocalDateTime::of(2012, 3, 4, 0, 0), null], [LocalDateTime::of(2012, 3, 4, 23, 5), LocalDateTime::MAX(), LocalDateTime::of(2012, 3, 4, 23, 5), null], [LocalDateTime::of(2012, 3, 4, 23, 5), LocalDateTime::MIN(), LocalDateTime::of(2012, 3, 4, 23, 5), null], [LocalDateTime::MAX(), LocalDateTime::of(2012, 3, 4, 23, 5), LocalDateTime::MAX(), null], [LocalDateTime::MIN(), LocalDateTime::of(2012, 3, 4, 23, 5), LocalDateTime::MIN(), null], [LocalDateTime::of(2012, 3, 4, 23, 5), OffsetDateTime::of(2210, 2, 2, 0, 0, 0, 0, ZoneOffset::UTC()), OffsetDateTime::of(2012, 3, 4, 23, 5, 0, 0, ZoneOffset::UTC()), null], [LocalDateTime::of(2012, 3, 4, 23, 5), OffsetDateTime::of(2210, 2, 2, 0, 0, 0, 0, self::OFFSET_PONE()), OffsetDateTime::of(2012, 3, 4, 23, 5, 0, 0, self::OFFSET_PONE()), null], [LocalDateTime::of(2012, 3, 4, 23, 5), ZonedDateTime::of(2210, 2, 2, 0, 0, 0, 0, self::ZONE_PARIS()), ZonedDateTime::of(2012, 3, 4, 23, 5, 0, 0, self::ZONE_PARIS()), null], [LocalDateTime::of(2012, 3, 4, 23, 5), LocalDate::of(2210, 2, 2), null, DateTimeException::class], [LocalDateTime::of(2012, 3, 4, 23, 5), LocalTime::of(22, 3, 0), null, DateTimeException::class], [LocalDateTime::of(2012, 3, 4, 23, 5), OffsetTime::of(22, 3, 0, 0, ZoneOffset::UTC()), null, DateTimeException::class]]; }
function data_adjustInto() { return [[OffsetDateTime::of(2012, 3, 4, 23, 5, 0, 0, self::OFFSET_PONE()), OffsetDateTime::of(2012, 3, 4, 1, 1, 1, 100, ZoneOffset::UTC()), OffsetDateTime::of(2012, 3, 4, 23, 5, 0, 0, self::OFFSET_PONE()), null], [OffsetDateTime::of(2012, 3, 4, 23, 5, 0, 0, self::OFFSET_PONE()), OffsetDateTime::MAX(), OffsetDateTime::of(2012, 3, 4, 23, 5, 0, 0, self::OFFSET_PONE()), null], [OffsetDateTime::of(2012, 3, 4, 23, 5, 0, 0, self::OFFSET_PONE()), OffsetDateTime::MIN(), OffsetDateTime::of(2012, 3, 4, 23, 5, 0, 0, self::OFFSET_PONE()), null], [OffsetDateTime::MAX(), OffsetDateTime::of(2012, 3, 4, 23, 5, 0, 0, self::OFFSET_PONE()), OffsetDateTime::ofDateTime(OffsetDateTime::MAX()->toLocalDateTime(), ZoneOffset::ofHours(-18)), null], [OffsetDateTime::MIN(), OffsetDateTime::of(2012, 3, 4, 23, 5, 0, 0, self::OFFSET_PONE()), OffsetDateTime::ofDateTime(OffsetDateTime::MIN()->toLocalDateTime(), ZoneOffset::ofHours(18)), null], [OffsetDateTime::of(2012, 3, 4, 23, 5, 0, 0, self::OFFSET_PONE()), ZonedDateTime::of(2012, 3, 4, 1, 1, 1, 100, self::ZONE_GAZA()), ZonedDateTime::of(2012, 3, 4, 23, 5, 0, 0, self::ZONE_GAZA()), null], [OffsetDateTime::of(2012, 3, 4, 23, 5, 0, 0, self::OFFSET_PONE()), LocalDateTime::of(2012, 3, 4, 1, 1, 1, 100), null, DateTimeException::class], [OffsetDateTime::of(2012, 3, 4, 23, 5, 0, 0, self::OFFSET_PONE()), LocalDate::of(2210, 2, 2), null, DateTimeException::class], [OffsetDateTime::of(2012, 3, 4, 23, 5, 0, 0, self::OFFSET_PONE()), LocalTime::of(22, 3, 0), null, DateTimeException::class], [OffsetDateTime::of(2012, 3, 4, 23, 5, 0, 0, self::OFFSET_PONE()), OffsetTime::of(22, 3, 0, 0, ZoneOffset::UTC()), null, DateTimeException::class]]; }
public function test_atTime_OffsetTime() { $t = LocalDate::of(2008, 6, 30); $this->assertEquals($t->atOffsetTime(OffsetTime::of(11, 30, 0, 0, self::OFFSET_PONE())), OffsetDateTime::of(2008, 6, 30, 11, 30, 0, 0, self::OFFSET_PONE())); }
function data_adjustInto() { return [[LocalTime::of(23, 5), LocalTime::of(4, 1, 1, 100), LocalTime::of(23, 5, 0, 0), null], [LocalTime::of(23, 5, 20), LocalTime::of(4, 1, 1, 100), LocalTime::of(23, 5, 20, 0), null], [LocalTime::of(23, 5, 20, 1000), LocalTime::of(4, 1, 1, 100), LocalTime::of(23, 5, 20, 1000), null], [LocalTime::of(23, 5, 20, 1000), LocalTime::MAX(), LocalTime::of(23, 5, 20, 1000), null], [LocalTime::of(23, 5, 20, 1000), LocalTime::MIN(), LocalTime::of(23, 5, 20, 1000), null], [LocalTime::of(23, 5, 20, 1000), LocalTime::NOON(), LocalTime::of(23, 5, 20, 1000), null], [LocalTime::of(23, 5, 20, 1000), LocalTime::MIDNIGHT(), LocalTime::of(23, 5, 20, 1000), null], [LocalTime::MAX(), LocalTime::of(23, 5, 20, 1000), LocalTime::of(23, 59, 59, 999999999), null], [LocalTime::MIN(), LocalTime::of(23, 5, 20, 1000), LocalTime::of(0, 0, 0), null], [LocalTime::NOON(), LocalTime::of(23, 5, 20, 1000), LocalTime::of(12, 0, 0), null], [LocalTime::MIDNIGHT(), LocalTime::of(23, 5, 20, 1000), LocalTime::of(0, 0, 0), null], [LocalTime::of(23, 5), LocalDateTime::of(2210, 2, 2, 1, 1), LocalDateTime::of(2210, 2, 2, 23, 5), null], [LocalTime::of(23, 5), OffsetTime::of(1, 1, 0, 0, self::OFFSET_PTWO()), OffsetTime::of(23, 5, 0, 0, self::OFFSET_PTWO()), null], [LocalTime::of(23, 5), OffsetDateTime::of(2210, 2, 2, 1, 1, 0, 0, self::OFFSET_PTWO()), OffsetDateTime::of(2210, 2, 2, 23, 5, 0, 0, self::OFFSET_PTWO()), null], [LocalTime::of(23, 5), ZonedDateTime::of(2210, 2, 2, 1, 1, 0, 0, self::ZONE_PARIS()), ZonedDateTime::of(2210, 2, 2, 23, 5, 0, 0, self::ZONE_PARIS()), null], [LocalTime::of(23, 5), LocalDate::of(2210, 2, 2), null, DateTimeException::class]]; }
/** * @dataProvider provider_sampleToString */ public function test_toString($h, $m, $s, $n, $offsetId, $expected) { $t = OffsetTime::of($h, $m, $s, $n, ZoneOffset::of($offsetId)); $str = $t->__toString(); $this->assertEquals($str, $expected); }