protected function makeRange($string) { if (strpos($string, ' - ') !== false) { list($first, $second) = explode(' - ', $string); return TimestampRange::create(new Timestamp(trim($first)), new Timestamp(trim($second))); } throw new WrongArgumentException(); }
public function testCountMonthsNotOverlapped() { $unit = IntervalUnit::create('month'); $this->assertEquals(4, $result = $unit->countInRange(TimestampRange::create($start = Timestamp::create('2008-12-31 23:59:58'), $end = Timestamp::create('2009-05-28 03:00:00')), false)); $this->assertLessThanOrEqual($end->toStamp(), $start->spawn($result . ' ' . $unit->getName())->toStamp()); }
/** * @return TimestampRange **/ public function toTimestampRange() { return TimestampRange::create($this->getStart()->toTimestamp(), $this->getEnd()->toTimestamp()); }