svn commit: r1641068 - in /ofbiz/branches/release13.07: ./ 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: r1641068 - in /ofbiz/branches/release13.07: ./ framework/widget/templates/htmlFormMacroLibrary.ftl

jleroux@apache.org
Author: jleroux
Date: Sat Nov 22 14:20:36 2014
New Revision: 1641068

URL: http://svn.apache.org/r1641068
Log:
"Applied fix from trunk for revision: 1641066  "
------------------------------------------------------------------------
r1641066 | jleroux | 2014-11-22 15:15:54 +0100 (sam. 22 nov. 2014) | 8 lignes

A slightly modified patch from Gareth Carter for "<@htmlTemplate.renderDateTimeField does not parse date string based on input format" https://issues.apache.org/jira/browse/OFBIZ-5850

Commit 1626419 changed htmlFormMacroLibrary.ftl renderDateTimeField to use Date.parse instead of Date.parseExact.
https://code.google.com/p/datejs/wiki/APIDocumentation states Date.parse will use current CultureInfo for formats but for parsing ISO yyyy-MM-dd from hidden field, need to use parseExact.
I spotted this when CultureInfo was en-GB and selecting 2014-11-01 on any date field (i18n field displays 11/01/2014 instead of 01/11/2014)
For November all days after the 12th display correctly

jleroux: I simply removed the line added in the block which remove the dot and 000 ms in date/time string. I did not see any reason why this was needed. I modified the comment on this block for faster understanding.
------------------------------------------------------------------------


Modified:
    ofbiz/branches/release13.07/   (props changed)
    ofbiz/branches/release13.07/framework/widget/templates/htmlFormMacroLibrary.ftl

Propchange: ofbiz/branches/release13.07/
------------------------------------------------------------------------------
  Merged /ofbiz/trunk:r1641066

Modified: ofbiz/branches/release13.07/framework/widget/templates/htmlFormMacroLibrary.ftl
URL: http://svn.apache.org/viewvc/ofbiz/branches/release13.07/framework/widget/templates/htmlFormMacroLibrary.ftl?rev=1641068&r1=1641067&r2=1641068&view=diff
==============================================================================
--- ofbiz/branches/release13.07/framework/widget/templates/htmlFormMacroLibrary.ftl (original)
+++ ofbiz/branches/release13.07/framework/widget/templates/htmlFormMacroLibrary.ftl Sat Nov 22 14:20:36 2014
@@ -122,15 +122,15 @@ under the License.
       <script type="text/javascript">
         <#-- If language specific lib is found, use date / time converter else just copy the value fields -->
         if (Date.CultureInfo != undefined) {
-          var initDate = <#if value?has_content>jQuery("#${id}_i18n").val()<#else>""</#if>;
+          var initDate = <#if value?has_content>jQuery("#${id}").val()<#else>""</#if>;
           if (initDate != "") {
             var dateFormat = Date.CultureInfo.formatPatterns.shortDate<#if shortDateInput?exists && !shortDateInput> + " " + Date.CultureInfo.formatPatterns.longTime</#if>;
-            <#-- bad hack because the JS date parser doesn't understand dots in the date / time string -->
+            <#-- The JS date parser doesn't understand the dot before ms in the date/time string. The ms here should be always 0 -->
             if (initDate.indexOf('.') != -1) {
               initDate = initDate.substring(0, initDate.indexOf('.'));
             }
             var ofbizTime = "<#if shortDateInput?exists && shortDateInput>yyyy-MM-dd<#else>yyyy-MM-dd HH:mm:ss</#if>";
-            var dateObj = Date.parse(initDate, ofbizTime);
+            var dateObj = Date.parseExact(initDate, ofbizTime);
             var formatedObj = dateObj.toString(dateFormat);
             jQuery("#${id}_i18n").val(formatedObj);
           }
@@ -139,7 +139,7 @@ under the License.
             var ofbizTime = "<#if shortDateInput?exists && shortDateInput>yyyy-MM-dd<#else>yyyy-MM-dd HH:mm:ss</#if>";
             var newValue = ""
             if (this.value != "") {
-              var dateObj = Date.parse(this.value, ofbizTime);
+              var dateObj = Date.parseExact(this.value, ofbizTime);
               var dateFormat = Date.CultureInfo.formatPatterns.shortDate<#if shortDateInput?exists && !shortDateInput> + " " + Date.CultureInfo.formatPatterns.longTime</#if>;
               newValue = dateObj.toString(dateFormat);
             }
@@ -148,7 +148,7 @@ under the License.
           jQuery("#${id}_i18n").change(function() {
             var dateFormat = Date.CultureInfo.formatPatterns.shortDate<#if shortDateInput?exists && !shortDateInput> + " " + Date.CultureInfo.formatPatterns.longTime</#if>,
             newValue = "",
-            dateObj = Date.parse(this.value, dateFormat),
+            dateObj = Date.parseExact(this.value, dateFormat),
             ofbizTime;
             if (this.value != "" && dateObj !== null) {
               ofbizTime = "<#if shortDateInput?exists && shortDateInput>yyyy-MM-dd<#else>yyyy-MM-dd HH:mm:ss</#if>";