Last active
January 2, 2016 00:09
-
-
Save ryanguill/8220900 to your computer and use it in GitHub Desktop.
comparing isDate() vs isValid("date")
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<cfscript> | |
variables.foo = 0; | |
writeDump("isDate(): " & isDate(variables.foo)); //returns false | |
writeoutput("<br />"); | |
writeDump("isValid('date'): " & isValid("date",variables.foo)); //returns true | |
writeoutput("<br />"); | |
writeDump("isNumericDate(): " & isNumericDate(variables.foo)); //returns true | |
writeoutput("<br />"); | |
writeDump("dateFormat(): " & dateFormat(variables.foo,"yyyy-mm-dd")); //returns 1899-12-30 | |
writeoutput("<br />"); | |
//this one is just for fun | |
writeDump("isDate(dateFormat(10000000,'yyyy-mm-dd')): " & isDate(dateFormat(10000000,"yyyy-mm-dd"))); //ACF10: returns no Railo 4.1: returns true | |
writeoutput("<br />"); | |
</cfscript> | |
<pre> | |
relevant documentation: | |
https://learn.adobe.com/wiki/display/coldfusionen/IsDate | |
https://learn.adobe.com/wiki/display/coldfusionen/IsNumericDate | |
https://learn.adobe.com/wiki/display/coldfusionen/IsValid | |
"date or time: any date-time value, including dates or times; equivalent to the IsDate function." | |
http://railodocs.org/index.cfm/function/isvalid | |
"date or time: any date-time value, including dates or times; equivalent to the IsDate function." | |
Conclusion: I believe this is at least a documentation bug with isValid("date",) - it is equivalent to | |
isNumericDate() not isDate(). Would like confirmation on this from ACF and Railo. | |
I also feel that isNumericDate()'s documentation would benefit from describing the valid range of | |
numbers that could be provided as well as describing what the numbers correspond to, | |
eg 0 = 1899-12-30. | |
I also would like isDate() to list the valid date formats that it accepts. | |
</pre> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment