src/Converter/UnixTimeConverter/Time.php
public function convertTimeToMicroseconds(TimeObject $time)
    {
        $meaningfull = $time->countMeaningfull() > 0;

        // IF time had no meaningfull informations, fallback to a day ratio.
        if (!$meaningfull && null !== $ratio = $time->getRatio()) {
            return $ratio * $this->dayLengthInSeconds;
        }

        // IF time had no meaningfull informations, use internel swatch time.
        // May not work properly on non-earth systems. Whatever, who uses this
        // anyway ? ANd who will use this on other planets ?
        if (!$meaningfull && null !== $swatch = $time->getTransversal(0)) {
            return $swatch * 1000 * 86400
                - 3600 * 1000000 // minus fixed time offset
            ;
        }

        $len = count($this->ranges);
        $res = 0;
   
        for ($i=0; $i < $len; $i++) {
            $res = $res * $this->ranges[$i] + (int)$time->get($i);
        }

        // If using a different time format, apply ratio
        $timeScale = array_product($this->ranges);
        if ($this->dayLengthInMicroSeconds !== $timeScale) {
            return intval(($res * $this->dayLengthInMicroSeconds) / $timeScale);
        }

        return $res;
    }
public function convertTimeToMicroseconds(TimeObject $time)
    {
        $meaningfull = $time->countMeaningfull() > 0;

        // IF time had no meaningfull informations, fallback to a day ratio.
        if (!$meaningfull && null !== $ratio = $time->getRatio()) {
            return $ratio * $this->dayLengthInSeconds;
        }

        // IF time had no meaningfull informations, use internel swatch time.
        // May not work properly on non-earth systems. Whatever, who uses this
        // anyway ? ANd who will use this on other planets ?
        if (!$meaningfull && null !== $swatch = $time->getTransversal(0)) {
            return $swatch * 1000 * 86400
                - 3600 * 1000000 // minus fixed time offset
            ;
        }

        $len = count($this->ranges);
        $res = 0;
   
        for ($i=0; $i < $len; $i++) {
            $res = $res * $this->ranges[$i] + (int)$time->get($i);
        }

        // If using a different time format, apply ratio
        $timeScale = array_product($this->ranges);
        if ($this->dayLengthInMicroSeconds !== $timeScale) {
            return intval(($res * $this->dayLengthInMicroSeconds) / $timeScale);
        }

        return $res;
    }
public function convertTimeToMicroseconds ( TimeObject $ time ) { $ meaningfull = $ time -> countMeaningfull ( ) > 0 ; // IF time had no meaningfull informations, fallback to a day ratio. if ( ! $ meaningfull && null !== $ ratio = $ time -> getRatio ( ) ) { return $ ratio * $ this -> dayLengthInSeconds ; } // IF time had no meaningfull informations, use internel swatch time. // May not work properly on non-earth systems. Whatever, who uses this // anyway ? ANd who will use this on other planets ? if ( ! $ meaningfull && null !== $ swatch = $ time -> getTransversal ( 0 ) ) { return $ swatch * 1000 * 86400 - 3600 * 1000000 // minus fixed time offset ; } $ len = count ( $ this -> ranges ) ; $ res = 0 ; for ( $ i = 0 ; $ i < $ len ; $ i ++ ) { $ res = $ res * $ this -> ranges [ $ i ] + ( int ) $ time -> get ( $ i ) ; } // If using a different time format, apply ratio $ timeScale = array_product ( $ this -> ranges ) ; if ( $ this -> dayLengthInMicroSeconds !== $ timeScale ) { return intval ( ( $ res * $ this -> dayLengthInMicroSeconds ) / $ timeScale ) ; } return $ res ; }
Converts a "Time" into its value in its lower unit.

@param TimeObject $time

@return integer
Converts a Time into its value in its lower unit .