コード例 #1
0
ファイル: ZonedDateTimeTest.php プロジェクト: brick/date-time
 /**
  * @dataProvider providerOf
  *
  * @param string  $localDateTime The local date-time as a string.
  * @param string  $timeZone      The time-zone as a string.
  * @param string  $offset        The expected time-zone offset of the result zoned date-time.
  * @param integer $shift         The expected shift applied to the date-time (when in a gap), in seconds.
  * @param integer $epochSecond   The expected epoch-second the result zoned date-time resolves to.
  * @param integer $nanoOfSecond  The expected nano-of-second of the result zoned date-time.
  */
 public function testOf($localDateTime, $timeZone, $offset, $shift, $epochSecond, $nanoOfSecond)
 {
     $localDateTime = LocalDateTime::parse($localDateTime);
     $timeZone = TimeZone::parse($timeZone);
     $offset = TimeZoneOffset::parse($offset);
     $expectedDateTime = $localDateTime->plusSeconds($shift);
     $zonedDateTime = ZonedDateTime::of($localDateTime, $timeZone);
     $this->assertInstanceOf(ZonedDateTime::class, $zonedDateTime);
     $this->assertLocalDateTimeEquals($expectedDateTime, $zonedDateTime->getDateTime());
     $this->assertTimeZoneEquals($timeZone, $zonedDateTime->getTimeZone());
     $this->assertTimeZoneEquals($offset, $zonedDateTime->getTimeZoneOffset());
     $this->assertSame($epochSecond, $zonedDateTime->getEpochSecond());
     $this->assertSame($nanoOfSecond, $zonedDateTime->getNano());
 }
コード例 #2
0
ファイル: LocalDateTime.php プロジェクト: brick/date-time
 /**
  * Returns a zoned date-time formed from this date-time and the specified time-zone.
  *
  * @param TimeZone $zone The zime-zone to use.
  *
  * @return ZonedDateTime The zoned date-time formed from this date-time.
  */
 public function atTimeZone(TimeZone $zone)
 {
     return ZonedDateTime::of($this, $zone);
 }
コード例 #3
0
ファイル: ZonedDateTime.php プロジェクト: brick/date-time
 /**
  * Returns a copy of this ZonedDateTime with the specified period in seconds added.
  *
  * @param integer $seconds
  *
  * @return ZonedDateTime
  */
 public function plusSeconds($seconds)
 {
     return ZonedDateTime::of($this->localDateTime->plusSeconds($seconds), $this->timeZone);
 }