Split timestamp field for supported HTML5 input types

This commit is contained in:
onli 2020-08-14 18:37:03 +02:00
parent 26c402ec5c
commit e1bda89dc0
2 changed files with 20 additions and 11 deletions

View File

@ -60,17 +60,22 @@ switch($serendipity['GET']['adminAction']) {
}
// Check if the user changed the timestamp.
if (isset($serendipity['allowDateManipulation']) && $serendipity['allowDateManipulation'] && isset($serendipity['POST']['new_timestamp']) && $serendipity['POST']['new_timestamp'] != date(DATE_FORMAT_2, $serendipity['POST']['chk_timestamp'])) {
// The user changed the timestamp, now set the DB-timestamp to the user's date
$entry['timestamp'] = strtotime($serendipity['POST']['new_timestamp']);
if (isset($serendipity['POST']['new_date']) && isset($serendipity['POST']['new_time'])) {
$newTimestamp = $serendipity['POST']['new_date'] . 'T' . $serendipity['POST']['new_time'];
if (isset($serendipity['allowDateManipulation']) && $serendipity['allowDateManipulation'] && $newTimestamp != date(DATE_FORMAT_2, $serendipity['POST']['chk_timestamp'])) {
// The user changed the timestamp, now set the DB-timestamp to the user's date
$entry['timestamp'] = strtotime($newTimestamp);
if ($entry['timestamp'] == -1) {
$data['switched_output'] = true;
$data['dateval'] = false;
// The date given by the user is not convertable. Reset the timestamp.
$entry['timestamp'] = $serendipity['POST']['timestamp'];
if ($entry['timestamp'] == -1) {
$data['switched_output'] = true;
$data['dateval'] = false;
// The date given by the user is not convertable. Reset the timestamp.
$entry['timestamp'] = $serendipity['POST']['timestamp'];
}
}
}
// Save server timezone in database always, so substract the offset we added for display; otherwise it would be added time and again
if (!empty($entry['timestamp'])) {

View File

@ -98,9 +98,13 @@
{if $entry_vars.allowDateManipulation}
<div id="edit_entry_timestamp" class="form_field">
<input name="serendipity[chk_timestamp]" type="hidden" value="{$entry_vars.timestamp|escape}">
<label for="serendipityNewTimestamp">{$CONST.DATE}</label>
<input id="serendipityNewTimestamp" name="serendipity[new_timestamp]" type="datetime-local" value="{$entry_vars.timestamp|formatTime:'Y-m-d\TH:i':true:false:true}">
<label for="serendipityNewDate">{$CONST.DATE}</label>
<input id="serendipityNewDate" name="serendipity[new_date]" type="date" value="{$entry_vars.timestamp|formatTime:'Y-m-d':true:false:true}">
<label for="serendipityNewTime">{$CONST.TIME}</label>
<input id="serendipityNewTime" name="serendipity[new_time]" type="time" value="{$entry_vars.timestamp|formatTime:'H:i':true:false:true}">
</div>
{/if}
<div id="edit_entry_status" class="form_select">