You are here

public static function PHPExcel_Calculation_DateTime::HOUROFDAY in Loft Data Grids 6.2

Same name and namespace in other branches
  1. 7.2 vendor/phpoffice/phpexcel/Classes/PHPExcel/Calculation/DateTime.php \PHPExcel_Calculation_DateTime::HOUROFDAY()

* HOUROFDAY * * Returns the hour of a time value. * The hour is given as an integer, ranging from 0 (12:00 A.M.) to 23 (11:00 P.M.). * * Excel Function: * HOUR(timeValue) * *

Parameters

mixed $timeValue Excel date serial value (float), PHP date timestamp (integer),: * PHP DateTime object, or a standard time string * @return int Hour

File

vendor/phpoffice/phpexcel/Classes/PHPExcel/Calculation/DateTime.php, line 1284

Class

PHPExcel_Calculation_DateTime
PHPExcel_Calculation_DateTime

Code

public static function HOUROFDAY($timeValue = 0) {
  $timeValue = PHPExcel_Calculation_Functions::flattenSingleValue($timeValue);
  if (!is_numeric($timeValue)) {
    if (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_GNUMERIC) {
      $testVal = strtok($timeValue, '/-: ');
      if (strlen($testVal) < strlen($timeValue)) {
        return PHPExcel_Calculation_Functions::VALUE();
      }
    }
    $timeValue = self::_getTimeValue($timeValue);
    if (is_string($timeValue)) {
      return PHPExcel_Calculation_Functions::VALUE();
    }
  }

  // Execute function
  if ($timeValue >= 1) {
    $timeValue = fmod($timeValue, 1);
  }
  elseif ($timeValue < 0.0) {
    return PHPExcel_Calculation_Functions::NaN();
  }
  $timeValue = PHPExcel_Shared_Date::ExcelToPHP($timeValue);
  return (int) gmdate('G', $timeValue);
}