first import
[projectpier.git] / application / models / config_handlers / general / DateTimeConfigHandler.class.php
blob30c2e001abe3bfd61c69f062e9e4ae6cf5170a6e
1 <?php
3 /**
4 * Class that handles integer config values
6 * @version 1.0
7 * @http://www.projectpier.org/
8 */
9 class DateTimeConfigHandler extends ConfigHandler {
11 /**
12 * Render form control
14 * @param string $control_name
15 * @return string
17 function render($control_name) {
18 $year = date('Y');
19 return pick_date_widget($control_name, $this->getValue(), $year - 10, $year + 10);
20 } // render
22 /**
23 * Conver $value to raw value
25 * @param DateTimeValue $value
26 * @return null
28 protected function phpToRaw($value) {
29 return $value instanceof DateTimeValue ? $value->toMySQL() : EMPTY_DATETIME;
30 } // phpToRaw
32 /**
33 * Convert raw value to php
35 * @param string $value
36 * @return mixed
38 protected function rawToPhp($value) {
39 $from_value = trim($value) ? $value : EMPTY_DATETIME;
40 return DateTimeValueLib::makeFromString($from_value);
41 } // rawToPhp
43 } // DateTimeConfigHandler