/** * @return Instant */ public static function now() { return Clock::getDefault()->getTime(); }
/** * @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); }
/** * {@inheritdoc} */ public function getTime() { return $this->default->getTime()->plus($this->offset); }
/** * @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()); }
/** * @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); }
/** * @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))); }