tracker issue : CF-4200030

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

CF11 Update 12 breaks custom formatted date

| View in Tracker

Status/Resolution/Reason: Closed/Withdrawn/HaveNewInfo

Reporter/Name(from Bugbase): Jörg Zimmer / Jörg Zimmer ()

Created: 10/16/2017

Components: Functions

Versions: 2016,11.0,2018

Failure Type: Incorrectly functioning

Found In Build/Fixed In Build: 11,0,13,292866 /

Priority/Frequency: Normal / Some users will encounter

Locale/System: German / Windows 10 64 bit

Vote Count: 0

_emphasized text_Problem Description:
 Creating a array of structures from a query and then serializing it to json or cfdumping it seems to change the type of strings back to date-fields.
 I loop over a query and set datetime fields to an ISO-Timestring for angularJS.
 But as of Update 12 (and also 13), the reformatted field does not read 2016-10-01T08:00:00Z after sending it through serialiceJSON or cfdump. Instead it's "2016-10-01 10:00:00.0" with .toString() or with serializeJSON it's "October, 01 2016 10:00:00"

Steps to Reproduce:
 Two Functions in an Object called "g":
 function QueryToArrayOfStructures(theQuery){
 var theArray = arraynew(1);
 var cols = ListtoArray(lcase(theQuery.columnlist));
 var row = 1;
 var thisRow = "";
 var col = 1;
 for(row = 1; row LTE theQuery.recordcount; row = row + 1){
 thisRow = structnew();
 for(col = 1; col LTE arraylen(cols); col = col + 1){
 if (lsIsDate(theQuery[cols[col]][row]))

{ theQuery[cols[col]][row] = getIsoTimeString(theQuery[cols[col]][row],true); }

thisRow[cols[col]] = theQuery[cols[col]][row];

string function getIsoTimeString(required date datetime, boolean convertToUTC=false) {
 if (convertToUTC)

{ datetime = dateConvert("local2utc", datetime); }

 dateFormat(datetime, "yyyy-mm-dd") &
 "T" &
 timeFormat(datetime, "HH:mm:ss") & "Z"

Then a testscript.cfm:
 <cfset g = createObject("component","g")>
 <cfquery name="get" datasource="DSN1">
 select key_task, plan_starttime
 from table1
 limit 1
 <cfdump var="#g.QueryToArrayOfStructures(get)#">

Actual Result:
 2016-10-01 10:00:00.0
 [\{key_task={1234}, plan_starttime=\{2016-10-01 10:00:00.0}}]
 [\{key_task={1234}, plan_starttime=\{October, 01 2016 10:00:00}}]

Expected Result:
 2016-10-01 10:00:00.0



Any Workarounds:
 Uninstall Update 13 and 12



Still the same behavior in CF2018 HF1 ?! This bug report has been filed over a year ago... and it's marked as BugVerified... So I think I'm allowed to say: WTF?!?!?
Comment by Jörg Z.
29842 | October 24, 2018 02:24:07 PM GMT
Chatting with support and playing around with my sample-code I seem to be stumbled across the origin of the problem. In my cfc function QueryToArrayOfStructures() I assigned the ISO-formatted value back to the query: theQuery[cols[col]][row] = getIsoTimeString(theQuery[cols[col]][row],true); The handling of query date-fields must have changed… Because when I rewrite my code to assign the ISO-formatted string to the intermediate object that gets duplicated into my array, it works as before CF11 HF12: if (lsIsDate(theQuery[cols[col]][row])) { thisRow[cols[col]] = getIsoTimeString(theQuery[cols[col]][row],true); } else { thisRow[cols[col]] = theQuery[cols[col]][row]; } So yes, the handling of query-date-fields has changed, but I think this should be considered a good thing. Ticket can be closed
Comment by Jörg Z.
29847 | October 25, 2018 01:08:10 PM GMT
In custom time format user is adding 'z' add the end of date time then it is being assigned to query column of date type, during this assignment this `date-time string` is parsed as date and as 'z' is at trail of string it's UTC time therefore while parsing it is being converted into local time and then being assigned to query column thats why date difference is appearing. If assign same date string to thisRow then it works fine. below is the snipet put it inside the for loop : {color:#707070}if (lsIsDate(theQuery[cols[col]][row])){ {color} {color:#707070} thisRow[cols[col]] = getIsoTimeString(theQuery[cols[col]][row],true); {color} {color:#707070} }{color} {color:#707070} else{{color} {color:#707070} thisRow[cols[col]] = theQuery[cols[col]][row];{color} {color:#707070} }{color}
Comment by Ajay R.
29985 | November 30, 2018 10:18:36 AM GMT