From 62fa1904395d289dbdd165d6ed8b3428c789cc68 Mon Sep 17 00:00:00 2001 From: Hadi Nategh Date: Mon, 5 May 2014 14:09:47 +0000 Subject: [PATCH] Handle converting string date/time formats to Date object for date-time widget --- etemplate/js/et2_widget_date.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/etemplate/js/et2_widget_date.js b/etemplate/js/et2_widget_date.js index 95cb8b13bb..10b18cac20 100644 --- a/etemplate/js/et2_widget_date.js +++ b/etemplate/js/et2_widget_date.js @@ -609,11 +609,14 @@ var et2_date_ro = et2_valueWidget.extend([et2_IDetachedDOM], if(typeof _value == 'string' && isNaN(_value)) { - var text = new Date(_value); - // Handle timezone offset - times are already in user time, but parse does UTC - var localOffset = text.getTimezoneOffset() * 60000; + // parseDateTime to handle string PHP: DateTime local date/time format + var parsed = (typeof jQuery.datepicker.parseDateTime("yy-mm-dd","hh:mm:ss", _value) !='undefined')? + jQuery.datepicker.parseDateTime("yy-mm-dd","hh:mm:ss", _value): + jQuery.datepicker.parseDateTime(this.egw().preference('dateformat'),this.egw().preference('timeformat') == '24' ? 'H:i' : 'g:i a', _value); + + var text = new Date(parsed); // JS dates use milliseconds - this.date.setTime(text.valueOf()+localOffset); + this.date.setTime(text.valueOf()); } else {