예제 #1
0
파일: Instant.php 프로젝트: brick/date-time
 /**
  * @return Instant
  */
 public static function now()
 {
     return Clock::getDefault()->getTime();
 }
예제 #2
0
 /**
  * @dataProvider providerNow
  *
  * @param integer $epochSecond The epoch second.
  * @param string  $timeZone    The time-zone.
  * @param integer $year        The expected year.
  * @param integer $month       The expected month.
  */
 public function testNow($epochSecond, $timeZone, $year, $month)
 {
     $previousClock = Clock::setDefault(new FixedClock(Instant::of($epochSecond)));
     $this->assertYearMonthIs($year, $month, YearMonth::now(TimeZone::parse($timeZone)));
     Clock::setDefault($previousClock);
 }
예제 #3
0
 /**
  * {@inheritdoc}
  */
 public function getTime()
 {
     return $this->default->getTime()->plus($this->offset);
 }
예제 #4
0
 /**
  * @dataProvider providerCompareTo
  *
  * @param integer $testSecond The second of the test instant.
  * @param integer $testNano   The nanosecond adjustment to the test instant.
  * @param integer $nowSecond  The second of the current time.
  * @param integer $nowNano    The nanosecond adjustment to the current time.
  * @param integer $cmp        The comparison value.
  */
 public function testIsPast($testSecond, $testNano, $nowSecond, $nowNano, $cmp)
 {
     Clock::setDefault(new FixedClock(Instant::of($nowSecond, $nowNano)));
     $this->assertSame($cmp === -1, Instant::of($testSecond, $testNano)->isPast());
 }
예제 #5
0
 /**
  * @dataProvider providerNow
  *
  * @param integer $epochSecond The epoch second.
  * @param string  $timeZone    The time-zone.
  * @param integer $month       The expected month.
  * @param integer $day         The expected day.
  */
 public function testNow($epochSecond, $timeZone, $month, $day)
 {
     $previousClock = Clock::setDefault(new FixedClock(Instant::of($epochSecond)));
     $this->assertMonthDayIs($month, $day, MonthDay::now(TimeZone::parse($timeZone)));
     Clock::setDefault($previousClock);
 }
예제 #6
0
 /**
  * @param integer $epochSecond    The epoch second.
  * @param integer $nanoAdjustment The nanosecond adjustment to the epoch second.
  */
 protected function setClockTime($epochSecond, $nanoAdjustment = 0)
 {
     Clock::setDefault(new FixedClock(Instant::of($epochSecond, $nanoAdjustment)));
 }