tracker issue : CF-4100808

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

isNumericDate() does not do what it says on the tin

| View in Tracker

Status/Resolution/Reason: Closed/Withdrawn/AsDesigned

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

Created: 12/16/2015

Components: Language, Functions

Versions: 11.0

Failure Type:

Found In Build/Fixed In Build: CF11_Final /

Priority/Frequency: Major / Some users will encounter

Locale/System: ALL / Platforms All

Vote Count: 3

Repro:

<cfscript>
aDateObject = createDate(2015,12,16);
notANumericDate = dateFormat(aDateObject, "d mmmm, yyyy");
aNumericDate = aDateObject+0;

writeDump(label="baseline", var=[
	aDateObject,
	aDateObject.getClass().getName(),
	notANumericDate,
	notANumericDate.getClass().getName(),
	aNumericDate,
	aNumericDate.getClass().getName()
]);

writeDump(label="test with notANumericDate", var={
	"isDate" = isDate(notANumericDate),
	"isValid" = isValid("date", notANumericDate),
	"isNumericDate" = isNumericDate(notANumericDate)
});

writeDump(label="test with aNumericDate", var={
	"isDate" = isDate(aNumericDate),
	"isValid" = isValid("date", aNumericDate),
	"isNumericDate" = isNumericDate(aNumericDate)
});

writeDump(label="test with aDateObject", var={
	"isDate" = isDate(aDateObject),
	"isValid" = isValid("date", aDateObject),
	"isNumericDate" = isNumericDate(aDateObject)
});

writeDump(label="parse them", var={
	"aDateObject" = parseDateTime(aDateObject),
	"notANumericDate" = parseDateTime(notANumericDate),
	"aNumericDate" = parseDateTime(aNumericDate)
});
</cfscript>

Expectations:
1) notANumericDate - which is clearly NOT A NUMERIC DATE - should not validate as a numeric date;
2) if aDateObject parses OK, then aNumericDate should *probably* parse back to the same date, but that's arguably a misuse of this function

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

Watson Bug ID:	4100808

External Customer Info:
External Company:  
External Customer Name: Adam Cameron
External Customer Email:  
External Test Config: My Hardware and Environment details:

Attachments:

Comments:

+1 - notANumericDate shouldn't validate as a numeric date and aNumericDate should parse back to the same date
Vote by External U.
5064 | December 20, 2015 05:47:13 AM GMT
Any updates on this "review" that it needs?
Comment by External U.
5062 | January 25, 2016 08:29:21 AM GMT
1) As per the documentation of isNumericDate(), ColdFusion by default, evaluates any input parameter and attempts to convert it to a real number before it passes the parameter to the IsNumericDate function. Hence, apart from the pure numeric values, there are some additional dates which this function is able to recognize as a numeric date. Although, it should be noted that this additional functionality is limited and should not be expected to cover all kinds of date representations. Reference : https://helpx.adobe.com/coldfusion/cfml-reference/coldfusion-functions/functions-in-k/isnumericdate.html 2) parseDateTime() by definition parses a date/time string according to the English (U.S.) locale conventions. Hence, expecting it to parse a numeric value to a date is out of its scope.
Comment by Nikhil S.
5063 | August 05, 2016 05:39:02 AM GMT