Skip to content
Snippets Groups Projects
Commit 9742a3fb authored by Peter Rotich's avatar Peter Rotich
Browse files

Merge pull request #101 from greezybacon/hotfix/custom-date-fields


Fix regression in custom date fields

Reviewed-By: default avatarPeter Rotich <peter@osticket.com>
parents 3dfd5347 7a68a386
No related branches found
No related tags found
No related merge requests found
......@@ -665,7 +665,7 @@ class DatetimeField extends FormField {
function parse($value) {
if (!$value) return null;
$config = $this->getConfiguration();
return ($config['gmt']) ? Misc::db2gmtime($value) : strtotime($value);
return ($config['gmt']) ? Misc::db2gmtime($value) : $value;
}
function toString($value) {
......@@ -991,7 +991,7 @@ class DatetimePickerWidget extends Widget {
showButtonPanel: true,
buttonImage: './images/cal.png',
showOn:'both',
dateFormat: $.translate_format(<?php echo $cfg->getDateFormat(); ?>),
dateFormat: $.translate_format('<?php echo $cfg->getDateFormat(); ?>'),
});
});
</script>
......@@ -1008,10 +1008,23 @@ class DatetimePickerWidget extends Widget {
* time value into a single date and time string value.
*/
function getValue() {
global $cfg;
$data = $this->field->getSource();
$datetime = parent::getValue();
if ($datetime && isset($data[$this->name . ':time']))
$datetime .= ' ' . $data[$this->name . ':time'];
$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'])) {
list($hr, $min) = explode(':', $data[$this->name . ':time']);
$datetime += $hr * 3600 + $min * 60;
}
if ($config['gmt'])
$datetime -= (int) (3600 * $_SESSION['TZ_OFFSET'] +
($_SESSION['TZ_DST'] ? date('I',$datetime) : 0));
}
return $datetime;
}
}
......
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