Example #1
0
 /**
  * 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);
 }
 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"]];
 }
Example #3
0
 /**
  * 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);
 }
 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_atOffset()
 {
     $t = LocalTime::of(11, 30);
     $this->assertEquals($t->atOffset(self::OFFSET_PTWO()), OffsetTime::ofLocalTime(LocalTime::of(11, 30), self::OFFSET_PTWO()));
 }
 function data_adjustInto()
 {
     return [[OffsetTime::ofLocalTime(LocalTime::of(23, 5), self::OFFSET_PONE()), OffsetTime::ofLocalTime(LocalTime::of(1, 1, 1, 100), ZoneOffset::UTC()), OffsetTime::ofLocalTime(LocalTime::of(23, 5), self::OFFSET_PONE()), null], [OffsetTime::ofLocalTime(LocalTime::of(23, 5), self::OFFSET_PONE()), OffsetTime::MAX(), OffsetTime::ofLocalTime(LocalTime::of(23, 5), self::OFFSET_PONE()), null], [OffsetTime::ofLocalTime(LocalTime::of(23, 5), self::OFFSET_PONE()), OffsetTime::MIN(), OffsetTime::ofLocalTime(LocalTime::of(23, 5), self::OFFSET_PONE()), null], [OffsetTime::MAX(), OffsetTime::ofLocalTime(LocalTime::of(23, 5), self::OFFSET_PONE()), OffsetTime::ofLocalTime(OffsetTime::MAX()->toLocalTime(), ZoneOffset::ofHours(-18)), null], [OffsetTime::MIN(), OffsetTime::ofLocalTime(LocalTime::of(23, 5), self::OFFSET_PONE()), OffsetTime::ofLocalTime(OffsetTime::MIN()->toLocalTime(), ZoneOffset::ofHours(18)), null], [OffsetTime::ofLocalTime(LocalTime::of(23, 5), self::OFFSET_PONE()), ZonedDateTime::ofDateTime(LocalDateTime::of(2012, 3, 4, 1, 1, 1, 100), self::ZONE_GAZA()), ZonedDateTime::ofDateTime(LocalDateTime::of(2012, 3, 4, 23, 5), self::ZONE_GAZA()), null], [OffsetTime::ofLocalTime(LocalTime::of(23, 5), self::OFFSET_PONE()), OffsetDateTime::ofDateTime(LocalDateTime::of(2012, 3, 4, 1, 1, 1, 100), ZoneOffset::UTC()), OffsetDateTime::ofDateTime(LocalDateTime::of(2012, 3, 4, 23, 5), self::OFFSET_PONE()), null], [OffsetTime::ofLocalTime(LocalTime::of(23, 5), self::OFFSET_PONE()), LocalDateTime::of(2012, 3, 4, 1, 1, 1, 100), null, DateTimeException::class], [OffsetTime::ofLocalTime(LocalTime::of(23, 5), self::OFFSET_PONE()), LocalDate::of(2210, 2, 2), null, DateTimeException::class], [OffsetTime::ofLocalTime(LocalTime::of(23, 5), self::OFFSET_PONE()), LocalTime::of(22, 3, 0), null, DateTimeException::class]];
 }