File tree Expand file tree Collapse file tree 2 files changed +5
-15
lines changed Expand file tree Collapse file tree 2 files changed +5
-15
lines changed Original file line number Diff line number Diff line change @@ -1049,20 +1049,8 @@ public function getAbsoluteTime(?string $time_string): float|int|string|null
1049
1049
{
1050
1050
if ($ time_string === null ) {
1051
1051
return null ;
1052
- } elseif (preg_match ('/^[+-][0-9]+:[0-9]{2}(:[0-9]{2}(\.[0-9]{0,6})?)?$/ ' , $ time_string )) {
1053
- $ sign = ($ time_string [0 ] == '- ' ? -1 : +1 );
1054
- $ time_string [0 ] = 0 ;
1055
- $ times = explode (': ' , $ time_string , 3 );
1056
- $ hours = (int )$ times [0 ];
1057
- $ minutes = (int )$ times [1 ];
1058
- if (count ($ times ) == 2 ) {
1059
- $ seconds = 0 ;
1060
- } else {
1061
- $ seconds = (float )$ times [2 ];
1062
- }
1063
- $ seconds = $ seconds + 60 * ($ minutes + 60 * $ hours );
1064
- $ seconds *= $ sign ;
1065
- $ absoluteTime = $ this ->starttime + $ seconds ;
1052
+ } elseif (Utils::isRelTime ($ time_string )) {
1053
+ $ absoluteTime = $ this ->starttime + Utils::relTimeToSeconds ($ time_string );
1066
1054
1067
1055
// Take into account the removed intervals.
1068
1056
/** @var RemovedInterval[] $removedIntervals */
Original file line number Diff line number Diff line change @@ -167,7 +167,9 @@ class Utils
167
167
168
168
final public const DAY_IN_SECONDS = 60 *60 *24 ;
169
169
170
- final public const RELTIME_REGEX = '/^([+-])?(\d+):(\d{2})(?::(\d{2})(?:\.(\d{3}))?)?$/ ' ;
170
+ // Regex to parse relative times. Note that these are our own relative times, which allows
171
+ // more than the CLICS spec does
172
+ final public const RELTIME_REGEX = '/^([+-])?(\d+):(\d{2})(?::(\d{2})(?:\.(\d+))?)?$/ ' ;
171
173
172
174
/**
173
175
* Returns the milliseconds part of a time stamp truncated at three digits.
You can’t perform that action at this time.
0 commit comments