You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by jl...@apache.org on 2014/11/22 15:24:49 UTC
svn commit: r1641069 - in /ofbiz/branches/release12.04: ./
framework/widget/templates/htmlFormMacroLibrary.ftl
Author: jleroux
Date: Sat Nov 22 14:24:49 2014
New Revision: 1641069
URL: http://svn.apache.org/r1641069
Log:
"Applied fix from trunk for revision: 1641066" Conflicts handled by hand, I tolerated 2 neutral FTL ?exist to ?? changes.
------------------------------------------------------------------------
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/release12.04/ (props changed)
ofbiz/branches/release12.04/framework/widget/templates/htmlFormMacroLibrary.ftl
Propchange: ofbiz/branches/release12.04/
------------------------------------------------------------------------------
Merged /ofbiz/trunk:r1641066
Modified: ofbiz/branches/release12.04/framework/widget/templates/htmlFormMacroLibrary.ftl
URL: http://svn.apache.org/viewvc/ofbiz/branches/release12.04/framework/widget/templates/htmlFormMacroLibrary.ftl?rev=1641069&r1=1641068&r2=1641069&view=diff
==============================================================================
--- ofbiz/branches/release12.04/framework/widget/templates/htmlFormMacroLibrary.ftl (original)
+++ ofbiz/branches/release12.04/framework/widget/templates/htmlFormMacroLibrary.ftl Sat Nov 22 14:24:49 2014
@@ -111,59 +111,63 @@ under the License.
<#if maxlength?has_content> maxlength="${maxlength}"</#if>
<#if id?has_content> id="${id}_i18n"</#if>/><#rt/>
</#if>
- <#-- the style attribute is a little bit messy but when using disply:none the timepicker is shown on a wrong place -->
- <input type="text" name="${name}" style="height:1px;width:1px;border:none;background-color:transparent" <#if event?has_content && action?has_content> ${event}="${action}"</#if> <@renderClass className alert /><#rt/>
- <#if title?has_content> title="${title}"</#if>
- <#if value?has_content> value="${value}"</#if>
- <#if size?has_content> size="${size}"</#if><#rt/>
- <#if maxlength?has_content> maxlength="${maxlength}"</#if>
- <#if id?has_content> id="${id}"</#if>/><#rt/>
- <#if dateType!="time" >
- <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>;
- 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 -->
- 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.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 newValue = ""
- if (this.value != "") {
- 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);
- }
- jQuery("#${id}_i18n").val(newValue);
- });
- jQuery("#${id}_i18n").change(function() {
- var dateFormat = Date.CultureInfo.formatPatterns.shortDate<#if shortDateInput?exists && !shortDateInput> + " " + Date.CultureInfo.formatPatterns.longTime</#if>;
- var newValue = ""
- if (this.value != "") {
- var dateObj = Date.parseExact(this.value, dateFormat);
- var ofbizTime = "<#if shortDateInput?exists && shortDateInput>yyyy-MM-dd<#else>yyyy-MM-dd HH:mm:ss</#if>";
- newValue = dateObj.toString(ofbizTime);
- }
- jQuery("#${id}").val(newValue);
- });
- } else {
- <#-- fallback if no language specific js date file is found -->
- jQuery("#${id}").change(function() {
- jQuery("#${id}_i18n").val(this.value);
- });
- jQuery("#${id}_i18n").change(function() {
- jQuery("#${id}").val(this.value);
- });
- }
+ <#-- the style attribute is a little bit messy but when using disply:none the timepicker is shown on a wrong place -->
+ <input type="text" name="${name}" style="height:1px;width:1px;border:none;background-color:transparent" <#if event?has_content && action?has_content> ${event}="${action}"</#if> <@renderClass className alert /><#rt/>
+ <#if title?has_content> title="${title}"</#if>
+ <#if value?has_content> value="${value}"</#if>
+ <#if size?has_content> size="${size}"</#if><#rt/>
+ <#if maxlength?has_content> maxlength="${maxlength}"</#if>
+ <#if id?has_content> id="${id}"</#if>/><#rt/>
+ <#if dateType!="time" >
+ <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}").val()<#else>""</#if>;
+ if (initDate != "") {
+ var dateFormat = Date.CultureInfo.formatPatterns.shortDate<#if shortDateInput?? && !shortDateInput> + " " + Date.CultureInfo.formatPatterns.longTime</#if>;
+ <#-- 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?? && 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?? && shortDateInput>yyyy-MM-dd<#else>yyyy-MM-dd HH:mm:ss</#if>";
+ var newValue = ""
+ if (this.value != "") {
+ var dateObj = Date.parseExact(this.value, ofbizTime);
+ var dateFormat = Date.CultureInfo.formatPatterns.shortDate<#if shortDateInput?? && !shortDateInput> + " " + Date.CultureInfo.formatPatterns.longTime</#if>;
+ newValue = dateObj.toString(dateFormat);
+ }
+ jQuery("#${id}_i18n").val(newValue);
+ });
+ jQuery("#${id}_i18n").change(function() {
+ var dateFormat = Date.CultureInfo.formatPatterns.shortDate<#if shortDateInput?? && !shortDateInput> + " " + Date.CultureInfo.formatPatterns.longTime</#if>,
+ newValue = "",
+ dateObj = Date.parseExact(this.value, dateFormat),
+ ofbizTime;
+ if (this.value != "" && dateObj !== null) {
+ ofbizTime = "<#if shortDateInput?? && shortDateInput>yyyy-MM-dd<#else>yyyy-MM-dd HH:mm:ss</#if>";
+ newValue = dateObj.toString(ofbizTime);
+ }
+ else { // invalid input
+ jQuery("#${id}_i18n").val("");
+ }
+ jQuery("#${id}").val(newValue);
+ });
+ } else {
+ <#-- fallback if no language specific js date file is found -->
+ jQuery("#${id}").change(function() {
+ jQuery("#${id}_i18n").val(this.value);
+ });
+ jQuery("#${id}_i18n").change(function() {
+ jQuery("#${id}").val(this.value);
+ });
+ }
<#if shortDateInput?exists && shortDateInput>
jQuery("#${id}").datepicker({