Skip to content
Snippets Groups Projects
Commit 46511c46 authored by Jared Hancock's avatar Jared Hancock
Browse files

forms: Don't assume client date time is parseable

parent f88508b3
No related branches found
No related tags found
No related merge requests found
......@@ -1019,14 +1019,15 @@ class DatetimePickerWidget extends Widget {
$config = $this->field->getConfiguration();
if ($datetime = parent::getValue()) {
$datetime = (is_int($datetime) ? $datetime :
(int)DateTime::createFromFormat($cfg->getDateFormat() . ' G:i',
$datetime . ' 00:00')
->format('U'));
if (isset($data[$this->name . ':time'])) {
(($dt = DateTime::createFromFormat($cfg->getDateFormat() . ' G:i',
$datetime . ' 00:00'))
? (int) $dt->format('U') : false)
);
if ($datetime && isset($data[$this->name . ':time'])) {
list($hr, $min) = explode(':', $data[$this->name . ':time']);
$datetime += $hr * 3600 + $min * 60;
}
if ($config['gmt'])
if ($datetime && $config['gmt'])
$datetime -= (int) (3600 * $_SESSION['TZ_OFFSET'] +
($_SESSION['TZ_DST'] ? date('I',$datetime) : 0));
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment