1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10:
11:
12: namespace Xoops\Form;
13:
14: 15: 16: 17: 18: 19: 20: 21: 22: 23:
24: class DateTime extends ElementTray
25: {
26: 27: 28: 29: 30: 31: 32:
33: public function __construct($caption, $name = null, $value = 0)
34: {
35:
36: if (is_array($caption)) {
37: parent::__construct($caption);
38: $this->set(':joiner', '');
39: } else {
40: parent::__construct($caption, '', $name);
41: $this->set('value', $value);
42: }
43:
44: $workingTime = \Xoops\Core\Locale\Time::cleanTime($this->get('value', 0));
45:
46: $dateDefinition = [
47: 'caption' => '',
48: 'name' => $this->get('name') . '[date]',
49: 'id' => $this->get('name') . '-date',
50: 'size' => 15,
51: 'value' => $workingTime,
52: ElementFactory::FORM_KEY => $this,
53: ];
54: new DateSelect($dateDefinition);
55:
56: $minuteInterval = $this->get(':minuteinterval', 15);
57: $hours = (int) ltrim($workingTime->format('H'), '0');
58: $minutes = (int) ltrim($workingTime->format('i'), '0');
59:
60: $timeDefinition = [
61: 'caption' => '',
62: 'name' => $this->get('name') . '[time]',
63: 'id' => $this->get('name') . '-time',
64: 'size' => 1,
65: 'value' => \Xoops\Core\Locale\Time::formatTime(
66: $hours * 3600 + 60*$minuteInterval * ceil($minutes / $minuteInterval),
67: 'short',
68: new \DateTimeZone('UTC')
69: ),
70: ElementFactory::FORM_KEY => $this,
71: 'option' => \Xoops\Core\Lists\Time::getList($minuteInterval),
72: ];
73: new Select($timeDefinition);
74: }
75: }
76: