Example #1
0
 /**
  * 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;
 }
Example #2
0
 public function testToUnixTimestamp()
 {
     $ts = "1234567890.002001";
     $datetime = new DateTime($ts);
     $this->assertSame($ts, $datetime->toUnixTimestamp());
 }