1 | <?php |
||
5 | class XMLDateInterval extends \DateInterval |
||
6 | { |
||
7 | /** |
||
8 | * formating string like ISO 8601 (PnYnMnDTnHnMnS). |
||
9 | */ |
||
10 | const INTERVAL_ISO8601 = 'P%yY%mM%dDT%hH%iM%sS'; |
||
11 | private $pattern; |
||
12 | private $patternLen; |
||
13 | |||
14 | private $fractionOfSecond; |
||
15 | |||
16 | public function __construct($intervalSpec, $pattern = 'PnYnMnDTnHnMnS') |
||
28 | |||
29 | private function handleFractionOfSecond($intervalSpec) |
||
39 | |||
40 | /** |
||
41 | * formating the interval like ISO 8601 (PnYnMnDTnHnMnS). |
||
42 | * |
||
43 | * @return string|null |
||
44 | */ |
||
45 | public function __toString() |
||
54 | |||
55 | /** |
||
56 | * @return string |
||
57 | */ |
||
58 | private function handleSign() |
||
65 | |||
66 | /** |
||
67 | * @param int $i |
||
68 | * @param bool $tSeen |
||
69 | * |
||
70 | * @return string |
||
71 | */ |
||
72 | private function handleChar($i, &$tSeen) |
||
83 | |||
84 | /** |
||
85 | * @param int $i |
||
86 | * @param bool $tSeen |
||
87 | * |
||
88 | * @return string |
||
89 | */ |
||
90 | private function handleN($i, $tSeen) |
||
91 | { |
||
92 | $componentProperty = ($this->pattern[$i + 1] == 'M' && $tSeen) ? 'i' : strtolower($this->pattern[$i + 1]); |
||
93 | if ('s' === $componentProperty) { |
||
94 | return $this->f === 0 ? $this->$componentProperty : trim($this->$componentProperty . '.' . $this->f, '.'); |
||
95 | } |
||
96 | return $this->$componentProperty; |
||
97 | } |
||
98 | |||
99 | /** |
||
100 | * @param bool $tSeen |
||
101 | * |
||
102 | * @return string |
||
103 | */ |
||
104 | private function handleT(&$tSeen) |
||
109 | |||
110 | /** |
||
111 | * @param int $i |
||
112 | * |
||
113 | * @return string |
||
114 | */ |
||
115 | private function handleOther($i) |
||
119 | |||
120 | public function __get($name) |
||
126 | } |
||
127 |