tracker issue : CF-3429216

select a category, or use search below
(searches all categories and all time range)
Title:

[ANeff] ER for: cfloop step precision (date range looping is sometimes imprecise)

| View in Tracker

Status/Resolution/Reason: To Fix//

Reporter/Name(from Bugbase): Aaron Neff / Aaron Neff (Aaron Neff)

Created: 12/14/2012

Components: Language

Versions: 10.0

Failure Type: Enhancement Request

Found In Build/Fixed In Build: Final /

Priority/Frequency: Trivial / Unknown

Locale/System: English / Win All

Vote Count: 0

Currently, cflooping backwards thru minutes (as an example) loses precision. Basically, cfloop's "step" behaves as if it lacks precisionEvaluate() behavior.

Repro:
<cfset startDate = createDateTime(2012,12,14,0,0,0) />
<cfloop from="#startDate#" to="#dateAdd('n', -2750, startDate)#" step="-#createTimeSpan(0,0,1,0)#" index="i">
#dateTimeFormat(i, "yyyy-mm-dd HH:nn:ss")#<br />
</cfloop>

Actual output:
<snip>
2012-12-12 05:26:00
2012-12-12 05:25:00
2012-12-12 05:24:00
2012-12-12 05:22:59 <== precision lost
2012-12-12 05:21:59
2012-12-12 05:20:59
</snip>

Expected output:
<snip>
2012-12-12 05:26:00
2012-12-12 05:25:00
2012-12-12 05:24:00
2012-12-12 05:23:00
2012-12-12 05:22:00
2012-12-12 05:21:00
</snip>

If cfloop's "step" would internally use precisionEvaluate(), then precision would be maintained. Pseudo-example:

<cfset startDate = createDateTime(2012,12,14,0,0,0) />
<cfoutput>#dateTimeFormat(startDate, "yyyy-mm-dd HH:nn:ss")#</cfoutput><br />
<cfloop from="1" to="2749" index="i">
  <cfset startDate = precisionEvaluate(startDate-createTimeSpan(0,0,1,0)) />
  <cfoutput>#dateTimeFormat(startDate, "yyyy-mm-dd HH:nn:ss")#</cfoutput><br />
</cfloop>

Please run attached file for full repro.

----------------------------- Additional Watson Details -----------------------------

Watson Bug ID:	3429216

Reason:	BugVerified

External Customer Info:
External Company:  
External Customer Name: itisdesign
External Customer Email:

Attachments:

  1. December 14, 2012 00:00:00: 1_cfloop_step_imprecise.cfm

Comments:

This bug still causes data corruption. Can it please be re-opened as "WorthTheEffort"? Seconds shouldn't start to disappear when looping backward thru time. Simply run the repro code in the example, then scroll to bottom of page. Thanks!, -Aaron
Comment by External U.
16939 | November 06, 2014 09:30:16 PM GMT
Hi Adobe, Implementing CF-4199506 would resolve this issue. Thanks!, -Aaron
Comment by Aaron N.
16940 | August 18, 2017 08:07:10 AM GMT