ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
TimeParts.php
Go to the documentation of this file.
1<?php
2
4
7use PhpOffice\PhpSpreadsheet\Shared\Date as SharedDateHelper;
8
10{
25 public static function hour($timeValue)
26 {
27 try {
28 $timeValue = Functions::flattenSingleValue($timeValue);
30 if (!is_numeric($timeValue)) {
31 $timeValue = Helpers::getTimeValue($timeValue);
32 }
34 } catch (Exception $e) {
35 return $e->getMessage();
36 }
37
38 // Execute function
39 $timeValue = fmod($timeValue, 1);
40 $timeValue = SharedDateHelper::excelToDateTimeObject($timeValue);
41
42 return (int) $timeValue->format('H');
43 }
44
59 public static function minute($timeValue)
60 {
61 try {
62 $timeValue = Functions::flattenSingleValue($timeValue);
64 if (!is_numeric($timeValue)) {
65 $timeValue = Helpers::getTimeValue($timeValue);
66 }
68 } catch (Exception $e) {
69 return $e->getMessage();
70 }
71
72 // Execute function
73 $timeValue = fmod($timeValue, 1);
74 $timeValue = SharedDateHelper::excelToDateTimeObject($timeValue);
75
76 return (int) $timeValue->format('i');
77 }
78
93 public static function second($timeValue)
94 {
95 try {
96 $timeValue = Functions::flattenSingleValue($timeValue);
98 if (!is_numeric($timeValue)) {
99 $timeValue = Helpers::getTimeValue($timeValue);
100 }
102 } catch (Exception $e) {
103 return $e->getMessage();
104 }
105
106 // Execute function
107 $timeValue = fmod($timeValue, 1);
108 $timeValue = SharedDateHelper::excelToDateTimeObject($timeValue);
109
110 return (int) $timeValue->format('s');
111 }
112}
An exception for terminatinating execution or to throw for unit testing.
static validateNotNegative($number)
Many functions accept null/false/true argument treated as 0/0/1.
Definition: Helpers.php:266
static nullFalseTrueToNumber(&$number, bool $allowBool=true)
Many functions accept null/false/true argument treated as 0/0/1.
Definition: Helpers.php:225
static flattenSingleValue($value='')
Convert an array to a single scalar value by extracting the first element.
Definition: Functions.php:649