Status/Resolution/Reason: Closed/Fixed/Fixed
Reporter/Name(from Bugbase): Aaron Neff / Aaron Neff ()
Created: 10/03/2017
Components: Documentation
Versions: 2016
Failure Type: Others
Found In Build/Fixed In Build: 2016.0.01.298513 / latest doc
Priority/Frequency: Normal / Some users will encounter
Locale/System: / Platforms All
Vote Count: 0
The cfloop doc is unclear regarding index's data type. New developers reading cfloop's doc would logically assume the index is a DateTime, whereas it is actually Numeric. This causes problems when they use the doc's Example code, and then replace DateFormat() and TimeFormat() with i.dateTimeFormat() (b/c Numeric doesn't have a .dateTimeFormat() member function).
Suggestions:
1) Change the index attribute's description from this:
-----------
Index value. ColdFusion sets it to the from value and increments by the step value, until it equals the to value.
-----------
to this:
-----------
Numeric index value. ColdFusion sets it to the numeric equivalent of the from value and increments by the numeric equivalent of the step value, until it equals the numeric equivalent of the to value.
-----------
2) Insert this example between the 2 existing examples:
-----------
The following example is the same as the first example, except it uses the .dateTimeFormat() member function instead of the dateFormat() function:
<cfset startDate = Now()>
<cfset endDate = Now() + 30>
<cfloop from="#startDate#" to="#endDate#" index="i" step="#CreateTimeSpan(7,0,0,0)#">
<cfset i = dateAdd("d", 0, i)><!--- converts number to date --->
<cfoutput>#i.dateTimeFormat("mm/dd/yyyy")#</cfoutput>
</cfloop>
-----------
-OR- Skip all the above and just add "fromDate" and "toDate" attributes to cfloop. When using those, instead of "from" and "to", then the index value's data type would be DateTime. I'll log a separate ER.
Attachments:
Comments: