@@ 1333-1358 (lines=26) @@ | ||
1330 | * PHP DateTime object, or a standard time string |
|
1331 | * @return int Hour |
|
1332 | */ |
|
1333 | public static function HOUROFDAY($timeValue = 0) |
|
1334 | { |
|
1335 | $timeValue = Functions::flattenSingleValue($timeValue); |
|
1336 | ||
1337 | if (!is_numeric($timeValue)) { |
|
1338 | if (Functions::getCompatibilityMode() == Functions::COMPATIBILITY_GNUMERIC) { |
|
1339 | $testVal = strtok($timeValue, '/-: '); |
|
1340 | if (strlen($testVal) < strlen($timeValue)) { |
|
1341 | return Functions::VALUE(); |
|
1342 | } |
|
1343 | } |
|
1344 | $timeValue = self::getTimeValue($timeValue); |
|
1345 | if (is_string($timeValue)) { |
|
1346 | return Functions::VALUE(); |
|
1347 | } |
|
1348 | } |
|
1349 | // Execute function |
|
1350 | if ($timeValue >= 1) { |
|
1351 | $timeValue = fmod($timeValue, 1); |
|
1352 | } elseif ($timeValue < 0.0) { |
|
1353 | return Functions::NAN(); |
|
1354 | } |
|
1355 | $timeValue = \PhpOffice\PhpSpreadsheet\Shared\Date::excelToTimestamp($timeValue); |
|
1356 | ||
1357 | return (int) gmdate('G', $timeValue); |
|
1358 | } |
|
1359 | ||
1360 | /** |
|
1361 | * MINUTEOFHOUR |
|
@@ 1373-1398 (lines=26) @@ | ||
1370 | * PHP DateTime object, or a standard time string |
|
1371 | * @return int Minute |
|
1372 | */ |
|
1373 | public static function MINUTEOFHOUR($timeValue = 0) |
|
1374 | { |
|
1375 | $timeValue = $timeTester = Functions::flattenSingleValue($timeValue); |
|
1376 | ||
1377 | if (!is_numeric($timeValue)) { |
|
1378 | if (Functions::getCompatibilityMode() == Functions::COMPATIBILITY_GNUMERIC) { |
|
1379 | $testVal = strtok($timeValue, '/-: '); |
|
1380 | if (strlen($testVal) < strlen($timeValue)) { |
|
1381 | return Functions::VALUE(); |
|
1382 | } |
|
1383 | } |
|
1384 | $timeValue = self::getTimeValue($timeValue); |
|
1385 | if (is_string($timeValue)) { |
|
1386 | return Functions::VALUE(); |
|
1387 | } |
|
1388 | } |
|
1389 | // Execute function |
|
1390 | if ($timeValue >= 1) { |
|
1391 | $timeValue = fmod($timeValue, 1); |
|
1392 | } elseif ($timeValue < 0.0) { |
|
1393 | return Functions::NAN(); |
|
1394 | } |
|
1395 | $timeValue = \PhpOffice\PhpSpreadsheet\Shared\Date::excelToTimestamp($timeValue); |
|
1396 | ||
1397 | return (int) gmdate('i', $timeValue); |
|
1398 | } |
|
1399 | ||
1400 | /** |
|
1401 | * SECONDOFMINUTE |
|
@@ 1413-1438 (lines=26) @@ | ||
1410 | * PHP DateTime object, or a standard time string |
|
1411 | * @return int Second |
|
1412 | */ |
|
1413 | public static function SECONDOFMINUTE($timeValue = 0) |
|
1414 | { |
|
1415 | $timeValue = Functions::flattenSingleValue($timeValue); |
|
1416 | ||
1417 | if (!is_numeric($timeValue)) { |
|
1418 | if (Functions::getCompatibilityMode() == Functions::COMPATIBILITY_GNUMERIC) { |
|
1419 | $testVal = strtok($timeValue, '/-: '); |
|
1420 | if (strlen($testVal) < strlen($timeValue)) { |
|
1421 | return Functions::VALUE(); |
|
1422 | } |
|
1423 | } |
|
1424 | $timeValue = self::getTimeValue($timeValue); |
|
1425 | if (is_string($timeValue)) { |
|
1426 | return Functions::VALUE(); |
|
1427 | } |
|
1428 | } |
|
1429 | // Execute function |
|
1430 | if ($timeValue >= 1) { |
|
1431 | $timeValue = fmod($timeValue, 1); |
|
1432 | } elseif ($timeValue < 0.0) { |
|
1433 | return Functions::NAN(); |
|
1434 | } |
|
1435 | $timeValue = \PhpOffice\PhpSpreadsheet\Shared\Date::excelToTimestamp($timeValue); |
|
1436 | ||
1437 | return (int) gmdate('s', $timeValue); |
|
1438 | } |
|
1439 | ||
1440 | /** |
|
1441 | * EDATE |