Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Duration.php

function Duration::__construct

Same name in this branch
  1. 11.1.x vendor/phpunit/phpunit/src/Event/Value/Telemetry/Duration.php \PHPUnit\Event\Telemetry\Duration::__construct()
  2. 11.1.x vendor/google/protobuf/src/Google/Protobuf/Duration.php \Google\Protobuf\Duration::__construct()

File

vendor/phpunit/php-timer/src/Duration.php, line 36

Class

Duration
@psalm-immutable

Namespace

SebastianBergmann\Timer

Code

private function __construct(float $nanoseconds) {
    $this->nanoseconds = $nanoseconds;
    $timeInMilliseconds = $nanoseconds / 1000000;
    $hours = floor($timeInMilliseconds / 60 / 60 / 1000);
    $hoursInMilliseconds = $hours * 60 * 60 * 1000;
    $minutes = floor($timeInMilliseconds / 60 / 1000) % 60;
    $minutesInMilliseconds = $minutes * 60 * 1000;
    $seconds = floor(($timeInMilliseconds - $hoursInMilliseconds - $minutesInMilliseconds) / 1000);
    $secondsInMilliseconds = $seconds * 1000;
    $milliseconds = $timeInMilliseconds - $hoursInMilliseconds - $minutesInMilliseconds - $secondsInMilliseconds;
    $this->hours = (int) $hours;
    $this->minutes = $minutes;
    $this->seconds = (int) $seconds;
    $this->milliseconds = (int) $milliseconds;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal