function microtime($_asFloat = false)
{
    return \TimeDilation\TimeMachine::microtime($_asFloat);
}
예제 #2
0
 /**
  * Replacement for php's native microtime() method.
  * Should work exaclty as php's microtime() but be constrained to the time-machine.
  *
  * @param bool $_asFloat
  * @return float|null|string
  */
 static function microtime($_asFloat = false)
 {
     if ($_asFloat == true) {
         if (self::$timeAnchor) {
             //calculate relative time
             $timePassed = \microtime(true) - self::$timeAnchor;
             return self::$now + $timePassed;
         } else {
             $mt = (double) \TimeDilation\TimeMachine::now();
             return $mt;
         }
     } else {
         //we have to return the microtime as string
         $mt = explode(".", self::microtime(true));
         if (!isset($mt[1])) {
             return "0.0 {$mt['0']}";
         }
         $fraction = str_pad("0." . $mt[1], 10, "0");
         return $fraction . " " . $mt[0];
     }
 }