Copy link to clipboard
Copied
Hi to all,
I recently started a brand new project in CF9.0.1 (hotfix 1 in place).
In one of my main components I have a function as per the following :
________________________________________
<cffunction name="DateFormatBE"
access="public"
returntype="string"
description="Formats a given string to Belgian date format, returns a blanco when no date is given">
<cfargument name="myDate"
type="string"
required="false"
default=""
hint="the string to date format">
<cfscript>
if (Len(Trim(ARGUMENTS.myDate))) {
if (! IsDate(ARGUMENTS.myDate)) {
ARGUMENTS.myDate = ParseDateBE(ARGUMENTS.myDate);
if (! Len(Trim(ARGUMENTS.myDate)))
return "";
}
return Trim(LSDateFormat(ARGUMENTS.myDate,"DD/MM/YYYY"));
} else
return "";
</cfscript>
</cffunction>
<cffunction name="ParseDateBE"
returntype="any"
access="public"
output="false"
hint="Parses a given string to a date object (dd/mm/yyyy).">
<cfargument name="myDate"
required="No"
type="string"
default=""
hint="the string to parse of format (dd/mm/yyyy)">
<cfscript>
if (ListLen(ARGUMENTS.myDate,"/") == 3) // expects two slashes
return CreateDate(ListGetAt(ARGUMENTS.myDate,3,"/"), ListGetAt(ARGUMENTS.myDate,2,"/"),ListGetAt(ARGUMENTS.myDate,1,"/"));
else
return "";
</cfscript>
</cffunction>
________________________________________
As of version 9.0.1 I always receive an extra space in front if I output a date as following :
<cfoutput>
<input type="Text"
name="SomeName"
value="#DateFormatBE(Now())#" >
</cfoutput>
However, this does seem to work as expected :
<cfdump var="#DateFormatBE(Now())#">
Is this a known bug or am I missing something?
Thanks for reading!
Bert.
Yes, you are missing something: OUTPUT="FALSE" on your <cffunction> signature for DateFormatBE().
However this would not have been "since 9.0.1" it would have been "since 6.0" (ie: since the introduction of <cffunction>).
--
Adam
Copy link to clipboard
Copied
I actually get this a lot with various CF functions, never managed to sort it.
Very annoying.
Copy link to clipboard
Copied
Yes, you are missing something: OUTPUT="FALSE" on your <cffunction> signature for DateFormatBE().
However this would not have been "since 9.0.1" it would have been "since 6.0" (ie: since the introduction of <cffunction>).
--
Adam
Copy link to clipboard
Copied
Super, it works as a charm now !
I do have put output="false" in my component tag definition, but that seems to do just nothing...
Anyway, thanks for your feedback !
Cheers Bert.
Copy link to clipboard
Copied
I do have put output="false" in my component tag definition, but that seems to do just nothing...
When one instantiates a CFC, any code outside any <cffunction> within the CFC file is executed. That could generate spurious whitespace if you don't have OUTPUT="FALSE" on the CFCOMPONENT tag.
--
Adam
Copy link to clipboard
Copied
Thanks for the clarification, I must of misread that part in some old documentation as it now clearly states the behaviour as you mention.