Returns time associative array of unit length.

@return array unit length in seconds => string unit name.
516302
public function get_units() {
        if (is_null($this->_units)) {
            $this->_units = array(
                604800 => get_string('weeks'),
                86400 => get_string('days'),
                3600 => get_string('hours'),
                60 => get_string('minutes'),
                1 => get_string('seconds'),
            );
        }
        return $this->_units;
    }
529413
public function timeTaken()
    {
        $timeStop = microtime(true);
        $timeTaken = (float) substr(-($this->timeStarted - $timeStop), 0, 5);
        return $timeTaken;
    }
289849
private static function getSeconds(): array
    {
        $seconds = [-1 => static::getConstant('TXT_DATETIME_SS', 'TXT_DATETIME_SS')];
        for ($i = 0; $i <= 59; $i++) {
            $seconds[$i] = \sprintf('%02s', $i);
        }
        return $seconds;
    }
614350
public function toArray()
    {
        if ($this->timer !== null) {
            $this->values['elapsed-time'] = $this->timer->getElapsedTime(true);
        }

        return $this->values;
    }
835127
public function getQueriesTime()
  {
    $res = array_reduce($this->getQueries(), function($result, $arr){
      if (isset($arr['time'])) {
        $result[] = $arr['time'];
      }

      return $result;
    }, array());

    return array_sum($res);
  }
115557
def _seconds_as_string(seconds):
    
    TIME_UNITS = [('s', 60), ('m', 60), ('h', 24), ('d', None)]
    unit_strings = []
    cur = max(int(seconds), 1)
    for suffix, size in TIME_UNITS:
        if size is not None:
            cur, rest = divmod(cur, size)
        else:
            rest = cur
        if rest > 0:
            unit_strings.insert(0, '%d%s' % (rest, suffix))
    return ' '.join(unit_strings)
859998
protected static function times() {
        return array(
            self::DURING            => get_string('reviewduring', 'quiz'),
            self::IMMEDIATELY_AFTER => get_string('reviewimmediately', 'quiz'),
            self::LATER_WHILE_OPEN  => get_string('reviewopen', 'quiz'),
            self::AFTER_CLOSE       => get_string('reviewclosed', 'quiz'),
        );
    }
174289
public function toSeconds()
    {
        $seconds = $this->s;
        $seconds += $this->i * 60;
        $seconds += $this->h * 3600;
        
        if ($this->days) {
            $seconds += $this->days * 86400;
        } else {
            if ($this->d) {
                $seconds += $this->d * 86400;
            }
            if ($this->m) {
                trigger_error('Calculating seconds for interval with months property. Result may not be accurate.', E_USER_WARNING);
                $seconds += 2629800;
            }
            if ($this->y) {
                trigger_error('Calculating seconds for interval with years property. Result may not be accurate.', E_USER_WARNING);
                $seconds += $this->y * 31557600;
            }
        }
        return $seconds;
    }
202291
public function getUnitOptions()
    {
        $unitGroup = [
            'speed' => ['bps', 'kbps', 'mbps', 'gbps', 'tbps'],
            'size' => ['mb', 'mb10', 'mb100', 'gb', 'tb'],
        ];

        $availableUnitsByPriceType = [
            'overuse,ip_num' => ['items'],
            'overuse,support_time' => ['hour'],
            'overuse,backup_du' => $unitGroup['size'],
            'overuse,server_traf_max' => $unitGroup['size'],
            'overuse,server_traf95_max' => $unitGroup['speed'],
            'overuse,server_du' => $unitGroup['size'],
            'overuse,server_ssd' => $unitGroup['size'],
            'overuse,server_sata' => $unitGroup['size'],
            'overuse,backup_traf' => $unitGroup['size'],
            'overuse,domain_traf' => $unitGroup['size'],
            'overuse,domain_num' => ['items'],
            'overuse,ip_traf_max' => $unitGroup['size'],
            'overuse,account_traf' => $unitGroup['size'],
            'overuse,account_du' => $unitGroup['size'],
            'overuse,mail_num' => ['items'],
            'overuse,mail_du' => $unitGroup['size'],
            'overuse,db_num' => ['items'],
        ];

        $units = Ref::getList('type,unit', 'hipanel.finance.units', [
            'with_recursive' => 1,
            'select' => 'oname_label',
            'mapOptions' => ['from' => 'oname'],
        ]);

        $possibleTypes = $availableUnitsByPriceType[$this->type] ?? [];

        return array_intersect_key($units, array_combine($possibleTypes, $possibleTypes));
    }
191672
protected function getTimearray()
    {
        $intSeconds = abs($this->intSeconds);

        $intYears = floor($intSeconds / DateTimeSpan::SECONDS_PER_YEAR);
        $intSeconds = $intSeconds - ($intYears * DateTimeSpan::SECONDS_PER_YEAR);

        $intMonths = floor($intSeconds / DateTimeSpan::SECONDS_PER_MONTH);
        $intSeconds = $intSeconds - ($intMonths * DateTimeSpan::SECONDS_PER_MONTH);

        $intDays = floor($intSeconds / DateTimeSpan::SECONDS_PER_DAY);
        $intSeconds = $intSeconds - ($intDays * DateTimeSpan::SECONDS_PER_DAY);

        $intHours = floor($intSeconds / DateTimeSpan::SECONDS_PER_HOUR);
        $intSeconds = $intSeconds - ($intHours * DateTimeSpan::SECONDS_PER_HOUR);

        $intMinutes = floor($intSeconds / DateTimeSpan::SECONDS_PER_MINUTE);
        $intSeconds = $intSeconds - ($intMinutes * DateTimeSpan::SECONDS_PER_MINUTE);

        if ($this->isNegative()) {
            // Turn values to negative
            $intYears = ((-1) * $intYears);
            $intMonths = ((-1) * $intMonths);
            $intDays = ((-1) * $intDays);
            $intHours = ((-1) * $intHours);
            $intMinutes = ((-1) * $intMinutes);
            $intSeconds = ((-1) * $intSeconds);
        }

        return array(
            'Years' => $intYears,
            'Months' => $intMonths,
            'Days' => $intDays,
            'Hours' => $intHours,
            'Minutes' => $intMinutes,
            'Seconds' => $intSeconds
        );
    }
740801
public function getUnits()
    {
        $headers = $this->__getLastResponseHeaders();

        if (!empty($headers) && preg_match('@^Units: (\d+)/(\d+)/(\d+)@m', $headers, $m)) {
            return new Units($m[1], $m[2], $m[3]);
        }

        return new Units(-1, -1, -1);
    }
348323
protected function _readTimestamp()
    {
        $data = array();
        if (empty($data) && file_exists($this->path . static::BUILD_TIME_FILE)) {
            $data = file_get_contents($this->path . static::BUILD_TIME_FILE);
            if ($data) {
                $data = unserialize($data);
            }
        }
        return $data;
    }
793727
public function getDateUnitsList()
    {
        return array(
            'S' => $this->translate->_('Seconds'),
            'N' => $this->translate->_('Minutes'),
            'H' => $this->translate->_('Hours'),
            'D' => $this->translate->_('Days'),
            'W' => $this->translate->_('Weeks'),
            'M' => $this->translate->_('Months'),
            'Q' => $this->translate->_('Quarters'),
            'Y' => $this->translate->_('Years')
        );
    }
953086
public function getExecutionTime()
    {
        $seconds = $this->getTime() - $this->startTime;

        $seconds = round($seconds);
        if ($seconds < 60) {
            return $seconds . ' sec';
        }
        $minutes = round($seconds / 60);
        $seconds = $seconds % 60;

        return $minutes . ' min ' . $seconds . ' sec';
    }
1058395
public static function getIsoUnits()
    {
        static $units = null;

        if ($units === null) {
            $units = [
                'OD' => ['getAltNumber', ['day']],
                'OM' => ['getAltNumber', ['month']],
                'OY' => ['getAltNumber', ['year']],
                'OH' => ['getAltNumber', ['hour']],
                'Oh' => ['getAltNumber', ['h']],
                'Om' => ['getAltNumber', ['minute']],
                'Os' => ['getAltNumber', ['second']],
                'D' => 'day',
                'DD' => ['rawFormat', ['d']],
                'Do' => ['ordinal', ['day', 'D']],
                'd' => 'dayOfWeek',
                'dd' => function (CarbonInterface $date, $originalFormat = null) {
                    return $date->getTranslatedMinDayName($originalFormat);
                },
                'ddd' => function (CarbonInterface $date, $originalFormat = null) {
                    return $date->getTranslatedShortDayName($originalFormat);
                },
                'dddd' => function (CarbonInterface $date, $originalFormat = null) {
                    return $date->getTranslatedDayName($originalFormat);
                },
                'DDD' => 'dayOfYear',
                'DDDD' => ['getPaddedUnit', ['dayOfYear', 3]],
                'DDDo' => ['ordinal', ['dayOfYear', 'DDD']],
                'e' => ['weekday', []],
                'E' => 'dayOfWeekIso',
                'H' => ['rawFormat', ['G']],
                'HH' => ['rawFormat', ['H']],
                'h' => ['rawFormat', ['g']],
                'hh' => ['rawFormat', ['h']],
                'k' => 'noZeroHour',
                'kk' => ['getPaddedUnit', ['noZeroHour']],
                'hmm' => ['rawFormat', ['gi']],
                'hmmss' => ['rawFormat', ['gis']],
                'Hmm' => ['rawFormat', ['Gi']],
                'Hmmss' => ['rawFormat', ['Gis']],
                'm' => 'minute',
                'mm' => ['rawFormat', ['i']],
                'a' => 'meridiem',
                'A' => 'upperMeridiem',
                's' => 'second',
                'ss' => ['getPaddedUnit', ['second']],
                'S' => function (CarbonInterface $date) {
                    return strval(floor($date->micro / 100000));
                },
                'SS' => function (CarbonInterface $date) {
                    return str_pad(floor($date->micro / 10000), 2, '0', STR_PAD_LEFT);
                },
                'SSS' => function (CarbonInterface $date) {
                    return str_pad(floor($date->micro / 1000), 3, '0', STR_PAD_LEFT);
                },
                'SSSS' => function (CarbonInterface $date) {
                    return str_pad(floor($date->micro / 100), 4, '0', STR_PAD_LEFT);
                },
                'SSSSS' => function (CarbonInterface $date) {
                    return str_pad(floor($date->micro / 10), 5, '0', STR_PAD_LEFT);
                },
                'SSSSSS' => ['getPaddedUnit', ['micro', 6]],
                'SSSSSSS' => function (CarbonInterface $date) {
                    return str_pad(floor($date->micro * 10), 7, '0', STR_PAD_LEFT);
                },
                'SSSSSSSS' => function (CarbonInterface $date) {
                    return str_pad(floor($date->micro * 100), 8, '0', STR_PAD_LEFT);
                },
                'SSSSSSSSS' => function (CarbonInterface $date) {
                    return str_pad(floor($date->micro * 1000), 9, '0', STR_PAD_LEFT);
                },
                'M' => 'month',
                'MM' => ['rawFormat', ['m']],
                'MMM' => function (CarbonInterface $date, $originalFormat = null) {
                    $month = $date->getTranslatedShortMonthName($originalFormat);
                    $suffix = $date->getTranslationMessage('mmm_suffix');
                    if ($suffix && $month !== $date->monthName) {
                        $month .= $suffix;
                    }

                    return $month;
                },
                'MMMM' => function (CarbonInterface $date, $originalFormat = null) {
                    return $date->getTranslatedMonthName($originalFormat);
                },
                'Mo' => ['ordinal', ['month', 'M']],
                'Q' => 'quarter',
                'Qo' => ['ordinal', ['quarter', 'M']],
                'G' => 'isoWeekYear',
                'GG' => ['getPaddedUnit', ['isoWeekYear']],
                'GGG' => ['getPaddedUnit', ['isoWeekYear', 3]],
                'GGGG' => ['getPaddedUnit', ['isoWeekYear', 4]],
                'GGGGG' => ['getPaddedUnit', ['isoWeekYear', 5]],
                'g' => 'weekYear',
                'gg' => ['getPaddedUnit', ['weekYear']],
                'ggg' => ['getPaddedUnit', ['weekYear', 3]],
                'gggg' => ['getPaddedUnit', ['weekYear', 4]],
                'ggggg' => ['getPaddedUnit', ['weekYear', 5]],
                'W' => 'isoWeek',
                'WW' => ['getPaddedUnit', ['isoWeek']],
                'Wo' => ['ordinal', ['isoWeek', 'W']],
                'w' => 'week',
                'ww' => ['getPaddedUnit', ['week']],
                'wo' => ['ordinal', ['week', 'w']],
                'x' => ['valueOf', []],
                'X' => 'timestamp',
                'Y' => 'year',
                'YY' => ['rawFormat', ['y']],
                'YYYY' => ['getPaddedUnit', ['year', 4]],
                'YYYYY' => ['getPaddedUnit', ['year', 5]],
                'YYYYYY' => function (CarbonInterface $date) {
                    return ($date->year < 0 ? '' : '+').$date->getPaddedUnit('year', 6);
                },
                'z' => 'tzAbbrName',
                'zz' => 'tzName',
                'Z' => ['getOffsetString', []],
                'ZZ' => ['getOffsetString', ['']],
            ];
        }

        return $units;
    }
801388
public function getAsArray()
    {
        $openingHours = [
            DayOfTheWeek::MONDAY => $this->getMonday(),
            DayOfTheWeek::TUESDAY => $this->getTuesday(),
            DayOfTheWeek::WEDNESDAY => $this->getWednesday(),
            DayOfTheWeek::THURSDAY => $this->getThursday(),
            DayOfTheWeek::FRIDAY => $this->getFriday(),
            DayOfTheWeek::SATURDAY => $this->getSaturday(),
            DayOfTheWeek::SUNDAY => $this->getSunday(),
        ];
        return $openingHours;
    }
65841
final private function getMicrotime() {
	
		list ($msec, $sec) = explode(' ', microtime());
		$time = ((float)$msec + (float)$sec);
		return $time;
		 
	}