/** * システム時刻と同じ unix time をあらわす Timestamp オブジェクトを返すことを確認します. * * @covers Peach\DT\DefaultClock::getUnixTime * @covers Peach\DT\Clock::getTimestamp */ public function testGetTimestamp() { $obj = DefaultClock::getInstance(); $now = UnixTimeFormat::getInstance()->parseTimestamp(time()); $result = $obj->getTimestamp(); $this->assertEquals($now, $result); }
/** * コンストラクタの第 2 引数の Clock オブジェクトを基準として現在時刻が移動することを確認します. * * @covers Peach\DT\OffsetClock::__construct * @covers Peach\DT\OffsetClock::getUnixTime * @covers Peach\DT\Clock::getTimestamp */ public function testGetTimestamp() { $base = new FixedClock(1234567890); $obj = new OffsetClock(1800, $base); $date1 = $obj->getTimestamp(); $shift = 1234567890 + 1800; $date2 = UnixTimeFormat::getInstance()->parseTimestamp($shift); $this->assertEquals($date2, $date1); }
/** * その時刻の Unix time に等しくなることを確認します. * @covers Peach\DT\UnixTimeFormat::formatTimestamp */ public function testFormatTimestamp() { $this->assertSame($this->testTime, $this->object->formatTimestamp(new Timestamp(2009, 2, 14, 8, 31, 30))); }
/** * {@link Peach\DT\Clock::getUnixTime} で取得した値を使って * Timestamp インスタンスを生成します. * * @return Timestamp */ public function getTimestamp() { $ms = $this->getUnixTime(); return UnixTimeFormat::getInstance()->parseTimestamp($ms); }