/** * Does this interval contain our time * @return Bond\Entity\T */ public function contains(DateTime $datetime) { $lower = $this->lower->toUnixTimestamp(); $upper = $this->upper->toUnixTimestamp(); $working = $datetime->toUnixTimestamp(); $lowerCompare = bccomp($lower, $working); $upperCompare = bccomp($upper, $working); // echo "\n{$lower} {$upper} {$working} {$lowerCompare} {$upperCompare}"; // f*****g hell, this was much more annoying than it should be if ($lowerCompare === 1 || ($this->bounds & self::LOWER_CONTAIN_NOT and $lowerCompare === 0)) { return false; } if ($upperCompare === -1 || ($this->bounds & self::UPPER_CONTAIN_NOT and $upperCompare === 0)) { return false; } return true; }
public function testToUnixTimestamp() { $ts = "1234567890.002001"; $datetime = new DateTime($ts); $this->assertSame($ts, $datetime->toUnixTimestamp()); }
/** * http://www.php.net/manual/en/datetime.add.php * @inheritDoc */ public function setTimestamp($unixtimestamp) { if ($this->isInfinity()) { return $this; } return parent::add($interval); }