tracker issue : CF-4198661

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

Date.compare doesn't work same as dateCompare

| View in Tracker

Status/Resolution/Reason: Closed/Fixed/Fixed

Reporter/Name(from Bugbase): Adam Cameron / Adam Cameron ()

Created: 05/12/2017

Components: Language, Member Functions

Versions: 2016,11.0

Failure Type: Incorrectly functioning

Found In Build/Fixed In Build: ? / 303808

Priority/Frequency: Normal / Some users will encounter

Locale/System: / Platforms All

Vote Count: 1

Repro:
https://trycf.com/gist/623f7c8bfb40420461c578b7255c5932/acf2016?theme=monokai
<cfscript>
nowAsDateObject = now();
nowAsString = toString(now());
dateFromParsedString = parseDateTime(nowAsString);

writeDump([
    nowAsDateObject.compare(dateFromParsedString),
    nowAsDateObject.compare(dateFromParsedString, "s"),
    dateCompare(nowAsDateObject, dateFromParsedString, "s")
]);
</cfscript>

Results:
array
1	1
2	0
3	0

The first one is wrong in two ways:
1) it should behave the same as when specifying "s", as "s" is the default
2) the dates are the same: there *isn't* a difference. I suspect the comparison is doing a comparison to an unsolicited level of accuracy, and this reflects a bug in how dates are converted to strings as it looks like there's a millisecond component lost. But that's a different issue, possibly. The dates *should* be the same, anyhow.

Attachments:

Comments:

+1
Vote by Aaron N.
743 | May 19, 2017 05:28:59 AM GMT