svn commit: r1139521 - /ofbiz/trunk/framework/widget/templates/htmlFormMacroLibrary.ftl

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r1139521 - /ofbiz/trunk/framework/widget/templates/htmlFormMacroLibrary.ftl

lektran
Author: lektran
Date: Sat Jun 25 11:13:33 2011
New Revision: 1139521

URL: http://svn.apache.org/viewvc?rev=1139521&view=rev
Log:
OFBIZ-4306 fix bug reported by Gaudin Pierre.  The datejs library's Date.parse(string) method doesn't work very well, seems to just guess at what format to use.  Switch to using the parseExact(date, format) method instead.

Modified:
    ofbiz/trunk/framework/widget/templates/htmlFormMacroLibrary.ftl

Modified: ofbiz/trunk/framework/widget/templates/htmlFormMacroLibrary.ftl
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/templates/htmlFormMacroLibrary.ftl?rev=1139521&r1=1139520&r2=1139521&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/templates/htmlFormMacroLibrary.ftl (original)
+++ ofbiz/trunk/framework/widget/templates/htmlFormMacroLibrary.ftl Sat Jun 25 11:13:33 2011
@@ -127,20 +127,23 @@ under the License.
                       if (initDate.indexOf('.') != -1) {
                           initDate = initDate.substring(0, initDate.indexOf('.'));
                       }
-                      var dateObj = Date.parse(initDate);
+                      var ofbizTime = "<#if shortDateInput?exists && shortDateInput>yyyy-MM-dd<#else>yyyy-MM-dd HH:mm:ss</#if>";
+                      var dateObj = Date.parseExact(initDate, ofbizTime);
                       var formatedObj = dateObj.toString(dateFormat);
                       jQuery("#${id}_i18n").val(formatedObj);
                   }
 
                   jQuery("#${id}").change(function() {
+                      var ofbizTime = "<#if shortDateInput?exists && shortDateInput>yyyy-MM-dd<#else>yyyy-MM-dd HH:mm:ss</#if>";
+                      var dateObj = Date.parseExact(this.value, ofbizTime);
                       var dateFormat = Date.CultureInfo.formatPatterns.shortDate<#if shortDateInput?exists && !shortDateInput> + " " + Date.CultureInfo.formatPatterns.longTime</#if>;
-                      var dateObj = Date.parse(this.value);
                       var formatedObj = dateObj.toString(dateFormat);
                       jQuery("#${id}_i18n").val(formatedObj);
                   });
                   jQuery("#${id}_i18n").change(function() {
+                      var dateFormat = Date.CultureInfo.formatPatterns.shortDate<#if shortDateInput?exists && !shortDateInput> + " " + Date.CultureInfo.formatPatterns.longTime</#if>;
+                      var dateObj = Date.parseExact(this.value, dateFormat);
                       var ofbizTime = "<#if shortDateInput?exists && shortDateInput>yyyy-MM-dd<#else>yyyy-MM-dd HH:mm:ss</#if>";
-                      var dateObj = Date.parse(this.value);
                       var formatedObj = dateObj.toString(ofbizTime);
                       jQuery("#${id}").val(formatedObj);
                   });