@@ 64-72 (lines=9) @@ | ||
61 | * |
|
62 | * @return Calender |
|
63 | */ |
|
64 | public static function fromDay($day) |
|
65 | { |
|
66 | $re = '/----(0[1-9]|1[0-9]|2[0-9]|3[0-1]|[1-9])([-+][0-1]\d:[0-6]\d|Z*)/'; |
|
67 | preg_match_all($re, $day, $matches, PREG_SET_ORDER, 0); |
|
68 | if (count($matches) != 1 && count($matches[0]) != 3) { |
|
69 | throw new \InvalidArgumentException('Unable to extract day from input string'); |
|
70 | } |
|
71 | return new self(null, null, $matches[0][1], $matches[0][2]); |
|
72 | } |
|
73 | ||
74 | public static function FromMonthDay($monthDay) |
|
75 | { |
|
@@ 84-92 (lines=9) @@ | ||
81 | return new self(null, $matches[0][1], $matches[0][2], $matches[0][3]); |
|
82 | } |
|
83 | ||
84 | public static function fromMonth($month) |
|
85 | { |
|
86 | $re = '/--(1[0-2]|0[1-9]|[1-9])([-+][0-1]\d:[0-6]\d|Z*)/'; |
|
87 | preg_match_all($re, $month, $matches, PREG_SET_ORDER, 0); |
|
88 | if (count($matches) != 1 && count($matches[0]) != 3) { |
|
89 | throw new \InvalidArgumentException('Unable to extract month from input string'); |
|
90 | } |
|
91 | return new self(null, $matches[0][1], null, $matches[0][2]); |
|
92 | } |
|
93 | ||
94 | public static function fromYearMonth($yearMonth) |
|
95 | { |
|
@@ 104-112 (lines=9) @@ | ||
101 | return new self($matches[0][1], null, $matches[0][2], $matches[0][3]); |
|
102 | } |
|
103 | ||
104 | public static function fromYear($year) |
|
105 | { |
|
106 | $re = '/(\d{4})([-+][0-1]\d:[0-6]\d|Z*)/'; |
|
107 | preg_match_all($re, $year, $matches, PREG_SET_ORDER, 0); |
|
108 | if (count($matches) != 1 && count($matches[0]) != 3) { |
|
109 | throw new \InvalidArgumentException('Unable to extract month from input string'); |
|
110 | } |
|
111 | return new self($matches[0][1], null, null, $matches[0][2]); |
|
112 | } |
|
113 | } |
|
114 |