|
14 | 14 | */ |
15 | 15 | class DateTimeFilter extends DatatableFilter |
16 | 16 | { |
17 | | - protected $is_filter_time = false; |
18 | | - protected $is_required = false; |
19 | | - protected $default_start; |
20 | | - protected $default_end; |
| 17 | + protected bool $is_filter_time = false; |
| 18 | + protected bool $is_required = false; |
| 19 | + protected \DateTime $default_start; |
| 20 | + protected \DateTime $default_end; |
21 | 21 |
|
22 | | - /** |
23 | | - * DateTimeFilter constructor. |
24 | | - * @param bool $is_filter_time |
25 | | - * @param bool $is_required |
26 | | - * @param \DateTime $default_start |
27 | | - * @param \DateTime $default_end |
28 | | - */ |
29 | | - public function __construct($is_filter_time=false, $is_required=false, \DateTime $default_start=null, \DateTime $default_end=null) |
| 22 | + public function __construct(bool $is_filter_time = false, bool $is_required = false, ?\DateTime $default_start = null, ?\DateTime $default_end = null, bool $use_default_start_time = true, bool $use_default_end_time = true) |
30 | 23 | { |
31 | 24 | $this->is_filter_time = $is_filter_time; |
32 | 25 | $this->is_required = $is_required; |
33 | 26 | $this->default_start = $default_start ?: new \DateTime; |
34 | 27 | $this->default_end = $default_end ?: new \DateTime; |
| 28 | + if ($use_default_start_time) |
| 29 | + { |
| 30 | + $this->default_start->setTime(0, 0, 0); |
| 31 | + } |
| 32 | + if ($use_default_end_time) |
| 33 | + { |
| 34 | + $this->default_end->setTime(23, 59, 59); |
| 35 | + } |
35 | 36 | parent::__construct([]); |
36 | 37 | } |
37 | 38 |
|
38 | | - /** |
39 | | - * @return bool |
40 | | - */ |
41 | | - public function isFilterTime() |
| 39 | + public function isFilterTime(): bool |
42 | 40 | { |
43 | 41 | return $this->is_filter_time; |
44 | 42 | } |
45 | 43 |
|
46 | | - /** |
47 | | - * @return bool |
48 | | - */ |
49 | | - public function isRequired() |
| 44 | + public function isRequired(): bool |
50 | 45 | { |
51 | 46 | return $this->is_required; |
52 | 47 | } |
53 | 48 |
|
54 | | - /** |
55 | | - * @return \DateTime |
56 | | - */ |
57 | | - public function getDefaultStart() |
| 49 | + public function getDefaultStart(): \DateTime |
58 | 50 | { |
59 | 51 | return $this->default_start; |
60 | 52 | } |
61 | 53 |
|
62 | | - /** |
63 | | - * @return \DateTime |
64 | | - */ |
65 | | - public function getDefaultEnd() |
| 54 | + public function getDefaultEnd(): \DateTime |
66 | 55 | { |
67 | 56 | return $this->default_end; |
68 | 57 | } |
|
0 commit comments