1 | <?php |
||
50 | class TDateFormat extends TI18NControl implements \Prado\IDataRenderer |
||
51 | { |
||
52 | /** |
||
53 | * Cached IntlDateFormatter set to the application culture. |
||
54 | * @var IntlDateFormatter |
||
55 | */ |
||
56 | protected static $formatters; |
||
57 | |||
58 | /** |
||
59 | * A set of pattern presets and their respective formatting shorthand. |
||
60 | * @var array |
||
61 | */ |
||
62 | private static $_patternPresets = [ |
||
63 | 'fulldate' => \IntlDateFormatter::FULL, |
||
64 | 'full' => \IntlDateFormatter::FULL, |
||
65 | 'fulltime' => \IntlDateFormatter::FULL, |
||
66 | 'longdate' => \IntlDateFormatter::LONG, |
||
67 | 'long' => \IntlDateFormatter::LONG, |
||
68 | 'longtime' => \IntlDateFormatter::LONG, |
||
69 | 'mediumdate' => \IntlDateFormatter::MEDIUM, |
||
70 | 'medium' => \IntlDateFormatter::MEDIUM, |
||
71 | 'mediumtime' => \IntlDateFormatter::MEDIUM, |
||
72 | 'shortdate' => \IntlDateFormatter::SHORT, |
||
73 | 'short' => \IntlDateFormatter::SHORT, |
||
74 | 'shorttime' => \IntlDateFormatter::SHORT, |
||
75 | 'none' => \IntlDateFormatter::NONE, |
||
76 | ]; |
||
77 | |||
78 | /** |
||
79 | * Sets the date time formatting pattern. |
||
80 | * @param string $value format pattern. |
||
81 | */ |
||
82 | public function setPattern($value) |
||
87 | |||
88 | /** |
||
89 | * Gets the date time format pattern. |
||
90 | * @return string format pattern. |
||
91 | */ |
||
92 | public function getPattern() |
||
96 | |||
97 | /** |
||
98 | * For a given string, try and find a preset pattern. |
||
99 | * @param string $string the preset pattern name |
||
100 | * @return string a preset pattern if found, null otherwise. |
||
101 | */ |
||
102 | protected function getPreset($string) |
||
112 | |||
113 | /** |
||
114 | * Get the date-time value for this control. |
||
115 | * @return string date time value. |
||
116 | */ |
||
117 | public function getValue() |
||
128 | |||
129 | /** |
||
130 | * Set the date-time value for this control. |
||
131 | * @param string $value the date-time value. |
||
132 | */ |
||
133 | public function setValue($value) |
||
137 | |||
138 | /** |
||
139 | * Get the default text value for this control. |
||
140 | * @return string default text value |
||
141 | */ |
||
142 | public function getDefaultText() |
||
146 | |||
147 | /** |
||
148 | * Set the default text value for this control. |
||
149 | * @param string $value default text value |
||
150 | */ |
||
151 | public function setDefaultText($value) |
||
155 | |||
156 | /** |
||
157 | * Get the date-time value for this control. |
||
158 | * This method is required by {@link \Prado\IDataRenderer}. |
||
159 | * It is the same as {@link getValue()}. |
||
160 | * @return string date time value. |
||
161 | * @see getValue |
||
162 | * @since 3.1.2 |
||
163 | */ |
||
164 | public function getData() |
||
168 | |||
169 | /** |
||
170 | * Set the date-time value for this control. |
||
171 | * This method is required by {@link \Prado\IDataRenderer}. |
||
172 | * It is the same as {@link setValue()}. |
||
173 | * @param string $value the date-time value. |
||
174 | * @see setValue |
||
175 | * @since 3.1.2 |
||
176 | */ |
||
177 | public function setData($value) |
||
181 | |||
182 | /** |
||
183 | * Formats the localized number, be it currency or decimal, or percentage. |
||
184 | * If the culture is not specified, the default application |
||
185 | * culture will be used. |
||
186 | * @param string $culture |
||
187 | * @param mixed $datetype |
||
188 | * @param mixed $timetype |
||
189 | * @return NumberFormatter |
||
190 | */ |
||
191 | protected function getFormatter($culture, $datetype, $timetype) |
||
202 | |||
203 | /** |
||
204 | * Renders the localized version of the date-time value. |
||
205 | * If the culture is not specified, the default application |
||
206 | * culture will be used. |
||
207 | * This method overrides parent's implementation. |
||
208 | */ |
||
209 | protected function getFormattedDate() |
||
273 | |||
274 | public function render($writer) |
||
278 | } |
||
279 |