function data_format_withZone_withChronology() { $ym = YearMonth::of(2008, 6); $ld = LocalDate::of(2008, 6, 30); $lt = LocalTime::of(11, 30); $ldt = LocalDateTime::of(2008, 6, 30, 11, 30); $ot = OffsetTime::ofLocalTime(LocalTime::of(11, 30), self::OFFSET_PONE()); $odt = OffsetDateTime::ofDateTime(LocalDateTime::of(2008, 6, 30, 11, 30), self::OFFSET_PONE()); $zdt = ZonedDateTime::ofDateTime(LocalDateTime::of(2008, 6, 30, 11, 30), self::ZONE_PARIS()); $thaiZdt = ThaiBuddhistChronology::INSTANCE()->zonedDateTimeFrom($zdt); $instant = Instant::ofEpochSecond(3600); return [[null, null, DayOfWeek::MONDAY(), "::::"], [null, null, $ym, "2008::::ISO"], [null, null, $ld, "2008::::ISO"], [null, null, $lt, ":11:::"], [null, null, $ldt, "2008:11:::ISO"], [null, null, $ot, ":11:+01:00::"], [null, null, $odt, "2008:11:+01:00::ISO"], [null, null, $zdt, "2008:11:+02:00:Europe/Paris:ISO"], [null, null, $instant, "::::"], [IsoChronology::INSTANCE(), null, DayOfWeek::MONDAY(), "::::ISO"], [IsoChronology::INSTANCE(), null, $ym, "2008::::ISO"], [IsoChronology::INSTANCE(), null, $ld, "2008::::ISO"], [IsoChronology::INSTANCE(), null, $lt, ":11:::ISO"], [IsoChronology::INSTANCE(), null, $ldt, "2008:11:::ISO"], [IsoChronology::INSTANCE(), null, $ot, ":11:+01:00::ISO"], [IsoChronology::INSTANCE(), null, $odt, "2008:11:+01:00::ISO"], [IsoChronology::INSTANCE(), null, $zdt, "2008:11:+02:00:Europe/Paris:ISO"], [IsoChronology::INSTANCE(), null, $instant, "::::ISO"], [null, self::ZONE_PARIS(), DayOfWeek::MONDAY(), ":::Europe/Paris:"], [null, self::ZONE_PARIS(), $ym, "2008:::Europe/Paris:ISO"], [null, self::ZONE_PARIS(), $ld, "2008:::Europe/Paris:ISO"], [null, self::ZONE_PARIS(), $lt, ":11::Europe/Paris:"], [null, self::ZONE_PARIS(), $ldt, "2008:11::Europe/Paris:ISO"], [null, self::ZONE_PARIS(), $ot, ":11:+01:00:Europe/Paris:"], [null, self::ZONE_PARIS(), $odt, "2008:12:+02:00:Europe/Paris:ISO"], [null, self::ZONE_PARIS(), $zdt, "2008:11:+02:00:Europe/Paris:ISO"], [null, self::ZONE_PARIS(), $instant, "1970:02:+01:00:Europe/Paris:ISO"], [null, self::OFFSET_PTHREE(), DayOfWeek::MONDAY(), ":::+03:00:"], [null, self::OFFSET_PTHREE(), $ym, "2008:::+03:00:ISO"], [null, self::OFFSET_PTHREE(), $ld, "2008:::+03:00:ISO"], [null, self::OFFSET_PTHREE(), $lt, ":11::+03:00:"], [null, self::OFFSET_PTHREE(), $ldt, "2008:11::+03:00:ISO"], [null, self::OFFSET_PTHREE(), $ot, null], [null, self::OFFSET_PTHREE(), $odt, "2008:13:+03:00:+03:00:ISO"], [null, self::OFFSET_PTHREE(), $zdt, "2008:12:+03:00:+03:00:ISO"], [null, self::OFFSET_PTHREE(), $instant, "1970:04:+03:00:+03:00:ISO"], [ThaiBuddhistChronology::INSTANCE(), null, DayOfWeek::MONDAY(), null], [ThaiBuddhistChronology::INSTANCE(), null, $ym, null], [ThaiBuddhistChronology::INSTANCE(), null, $ld, "2551::::ThaiBuddhist"], [ThaiBuddhistChronology::INSTANCE(), null, $lt, ":11:::ThaiBuddhist"], [ThaiBuddhistChronology::INSTANCE(), null, $ldt, "2551:11:::ThaiBuddhist"], [ThaiBuddhistChronology::INSTANCE(), null, $ot, ":11:+01:00::ThaiBuddhist"], [ThaiBuddhistChronology::INSTANCE(), null, $odt, "2551:11:+01:00::ThaiBuddhist"], [ThaiBuddhistChronology::INSTANCE(), null, $zdt, "2551:11:+02:00:Europe/Paris:ThaiBuddhist"], [ThaiBuddhistChronology::INSTANCE(), null, $instant, "::::ThaiBuddhist"], [ThaiBuddhistChronology::INSTANCE(), null, DayOfWeek::MONDAY(), null], [ThaiBuddhistChronology::INSTANCE(), self::ZONE_PARIS(), $ym, null], [ThaiBuddhistChronology::INSTANCE(), self::ZONE_PARIS(), $ld, "2551:::Europe/Paris:ThaiBuddhist"], [ThaiBuddhistChronology::INSTANCE(), self::ZONE_PARIS(), $lt, ":11::Europe/Paris:ThaiBuddhist"], [ThaiBuddhistChronology::INSTANCE(), self::ZONE_PARIS(), $ldt, "2551:11::Europe/Paris:ThaiBuddhist"], [ThaiBuddhistChronology::INSTANCE(), self::ZONE_PARIS(), $ot, ":11:+01:00:Europe/Paris:ThaiBuddhist"], [ThaiBuddhistChronology::INSTANCE(), self::ZONE_PARIS(), $odt, "2551:12:+02:00:Europe/Paris:ThaiBuddhist"], [ThaiBuddhistChronology::INSTANCE(), self::ZONE_PARIS(), $zdt, "2551:11:+02:00:Europe/Paris:ThaiBuddhist"], [ThaiBuddhistChronology::INSTANCE(), self::ZONE_PARIS(), $instant, "2513:02:+01:00:Europe/Paris:ThaiBuddhist"], [null, self::ZONE_PARIS(), $thaiZdt, "2551:11:+02:00:Europe/Paris:ThaiBuddhist"], [ThaiBuddhistChronology::INSTANCE(), self::ZONE_PARIS(), $thaiZdt, "2551:11:+02:00:Europe/Paris:ThaiBuddhist"], [IsoChronology::INSTANCE(), self::ZONE_PARIS(), $thaiZdt, "2008:11:+02:00:Europe/Paris:ISO"]]; }
/** * Converts this date-time to an {@code OffsetTime}. * <p> * This returns an offset time with the same local time and offset. * * @return OffsetTime an OffsetTime representing the time and offset, not null */ public function toOffsetTime() { return OffsetTime::ofLocalTime($this->dateTime->toLocalTime(), $this->offset); }
/** * Combines this date with an offset time to create an {@code OffsetDateTime}. * <p> * This returns an {@code OffsetDateTime} formed from this date at the specified time. * All possible combinations of date and time are valid. * * @param OffsetTime $time the time to combine with, not null * @return OffsetDateTime the offset date-time formed from this date and the specified time, not null */ public function atOffsetTime(OffsetTime $time) { return OffsetDateTime::ofDateTime(LocalDateTime::ofDateAndTime($this, $time->toLocalTime()), $time->getOffset()); }
/** * Combines this time with an offset to create an {@code OffsetTime}. * <p> * This returns an {@code OffsetTime} formed from this time at the specified offset. * All possible combinations of time and offset are valid. * * @param ZoneOffset $offset the offset to combine with, not null * @return OffsetTime the offset time formed from this time and the specified offset, not null */ public function atOffset(ZoneOffset $offset) { return OffsetTime::ofLocalTime($this, $offset); }
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]]; }
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()); }
public function test_with_adjustment_OffsetTime() { $test = self::TEST_2008_6_30_11_30_59_000000500()->adjust(OffsetTime::ofLocalTime(LocalTime::of(19, 15), self::OFFSET_PTWO())); $this->assertEquals($test, OffsetDateTime::ofDateAndTime(LocalDate::of(2008, 6, 30), LocalTime::of(19, 15), self::OFFSET_PTWO())); }
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())); }
public function test_atOffset() { $t = LocalTime::of(11, 30); $this->assertEquals($t->atOffset(self::OFFSET_PTWO()), OffsetTime::ofLocalTime(LocalTime::of(11, 30), self::OFFSET_PTWO())); }
/** * @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); }
/** * Checks if the instant of this {@code OffsetTime} is equal to that of the * specified time applying both times to a common date. * <p> * This method differs from the comparison in {@link #compareTo} and {@link #equals} * in that it only compares the instant of the time. This is equivalent to converting both * times to an instant using the same date and comparing the instants. * * @param OffsetTime $other the other time to compare to, not null * @return bool true if this is equal to the instant of the specified time */ public function isEqual(OffsetTime $other) { return $this->toEpochNano() == $other->toEpochNano(); }