There is a lot of thing that will end up confusing with our current date/time handling. We should be sticking to HTML5 input types to not confuse developers about what a drupal input type will give them.
The example I'll be refereeing to is the node add form.
When datetime module is not enabled we have: <input type="text">
and validation functions, all good.
When datetime is enabled:
array('#type' => 'datetime')
will give you <input type="date"><input type="time">
and it will adjust for TZ. So that one is fine as 2 separated fields.
If I follow the doc to have a datetime-local
element:
array('#type' => 'datetime-local', '#date_date_element' => 'datetime-local', '#date_time_element' => 'none')
will give <input type="datetime-local">
as expected and it'll be adjusted for TZ.
So essentially Drupal datetime
behaves like HTML datetime-local
input. It still is pretty convoluted to make a HTML5 datetime-local input from Drupal datetime FAPI type.
There is also in system_element_info()
this that I'm really not sure belongs:
$types['date'] = array(
'#input' => TRUE,
'#theme' => 'date',
'#theme_wrappers' => array('form_element'),
);
array('#type' => 'date')
=> <input type="date">
array('#type' => 'time')
=> <input type="time">
array('#type' => 'datetime')
=> <input type="datetime">
with TZ information (either Z
or an offset like +02:00
). If no TZ information the value is not valid.
array('#type' => 'datetime-local')
=> <input type="datetime-local">
without any TZ information (we suppose datetime TZ is user TZ).
Date + time should only be one field, no need for a date field and a separated time field.
✨
META: Support HTML5 form input elements
Active
#1496652: Add new HTML5 FAPI Element : datetime-local →
#1972660: Add tests for the new HTML5 date elements 'date', 'datetime', 'datetime-local' and 'time' →
#1835016: Polyfill date input type →
Active
11.0 🔥
datetime.module
Enhances developer experience.
Not all content is available!
It's likely this issue predates Contrib.social: some issue and comment data are missing.