|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace AlgoWeb\xsdTypes; |
|
4
|
|
|
|
|
5
|
|
|
use AlgoWeb\xsdTypes\AxillaryClasses\XMLDateInterval; |
|
6
|
|
|
use AlgoWeb\xsdTypes\Facets\MinMaxTrait; |
|
7
|
|
|
|
|
8
|
|
|
/** |
|
9
|
|
|
* The type xsd:duration represents a duration of time expressed as a number of years, months, days, hours, minutes, |
|
10
|
|
|
* and seconds. The format of xsd:duration is PnYnMnDTnHnMnS, where P is a literal value that starts the expression, |
|
11
|
|
|
* nY is the number of years followed by a literal Y, nM is the number of months followed by a literal M, nD is the |
|
12
|
|
|
* number of days followed by a literal D, T is a literal value that separates the date and time, nH is the number of |
|
13
|
|
|
* hours followed by a literal H, nM is the number of minutes followed by a literal M, and nS is the number of seconds |
|
14
|
|
|
* followed by a literal S. The following rules apply to xsd:duration values:. |
|
15
|
|
|
* |
|
16
|
|
|
* - Any of these numbers and corresponding designators may be absent if they are equal to 0, but at least one number |
|
17
|
|
|
* and designator must appear. |
|
18
|
|
|
* - The numbers may be any unsigned integer, with the exception of the number of seconds, which may be an unsigned |
|
19
|
|
|
* decimal number. |
|
20
|
|
|
* - If a decimal point appears in the number of seconds, there must be at least one digit after the decimal point. |
|
21
|
|
|
* - A minus sign may appear before the P to specify a negative duration. |
|
22
|
|
|
* - If no time items (hour, minute, second) are present, the letter T must not appear. |
|
23
|
|
|
* |
|
24
|
|
|
* @package AlgoWeb\xsdTypes |
|
25
|
|
|
*/ |
|
26
|
|
|
class xsDuration extends xsAnySimpleType |
|
27
|
|
|
{ |
|
28
|
|
|
use MinMaxTrait; |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* Construct. |
|
32
|
|
|
* |
|
33
|
|
|
* @param string $value |
|
34
|
|
|
*/ |
|
35
|
|
|
public function __construct($value) |
|
36
|
|
|
{ |
|
37
|
|
|
parent::__construct($value); |
|
38
|
|
|
$this->setWhiteSpaceFacet('collapse'); |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
public function fixValue() |
|
42
|
|
|
{ |
|
43
|
|
|
parent::fixValue(); |
|
44
|
|
|
$objectValue = new XMLDateInterval($this->value); |
|
45
|
|
|
$this->value = $objectValue->__toString(); |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
protected function isOK() |
|
49
|
|
|
{ |
|
50
|
|
|
$this->CheckMinMax(new XMLDateInterval($this->value)); |
|
51
|
|
|
} |
|
52
|
|
|
} |
|
53
|
|
|
|