@@ 19-48 (lines=30) @@ | ||
16 | /** |
|
17 | * @author Ishmael Doss <[email protected]> |
|
18 | */ |
|
19 | class DateTimeType implements TypeInterface |
|
20 | { |
|
21 | /** |
|
22 | * {@inheritdoc} |
|
23 | */ |
|
24 | public static function getName() |
|
25 | { |
|
26 | return 'datetime'; |
|
27 | } |
|
28 | ||
29 | /** |
|
30 | * @param mixed $value |
|
31 | * |
|
32 | * @return string |
|
33 | */ |
|
34 | public function getter($value) |
|
35 | { |
|
36 | return \DateTime::createFromFormat('Y-m-d H:i:s', $value) ?: null; |
|
37 | } |
|
38 | ||
39 | /** |
|
40 | * @param mixed $value |
|
41 | * |
|
42 | * @return string |
|
43 | */ |
|
44 | public function setter($value) |
|
45 | { |
|
46 | return $value ? $value->format('Y-m-d H:i:s') : null; |
|
47 | } |
|
48 | } |
|
49 |
@@ 19-48 (lines=30) @@ | ||
16 | /** |
|
17 | * @author Ishmael Doss <[email protected]> |
|
18 | */ |
|
19 | class DateType implements TypeInterface |
|
20 | { |
|
21 | /** |
|
22 | * {@inheritdoc} |
|
23 | */ |
|
24 | public static function getName() |
|
25 | { |
|
26 | return 'date'; |
|
27 | } |
|
28 | ||
29 | /** |
|
30 | * @param mixed $value |
|
31 | * |
|
32 | * @return string |
|
33 | */ |
|
34 | public function getter($value) |
|
35 | { |
|
36 | return \DateTime::createFromFormat('Y-m-d', $value) ?: null; |
|
37 | } |
|
38 | ||
39 | /** |
|
40 | * @param mixed $value |
|
41 | * |
|
42 | * @return string |
|
43 | */ |
|
44 | public function setter($value) |
|
45 | { |
|
46 | return $value ? $value->format('Y-m-d') : null; |
|
47 | } |
|
48 | } |
|
49 |