DEV Community

James Moberg
James Moberg

Posted on

5 2

Response to isDate() Blog Post

My response to this blog post was detected as spam, so I'm responding here.

The recommendation from Adobe has been to use isValid("date") instead of isDate(). If isDate() returns TRUE, you should also test using isValid("date") and use parseDateTime (with try/catch) to see what ColdFusion actually evaluates as the date. In my opinion, a value isn't a valid date until it can be correctly parsed and then sent to third-parties and also be parsed as a date (ie, SQL).
https://tracker.adobe.com/#/view/CF-4204879

For example, tested with latest CF2016

isDate(2000); /* NO */
isValid('date',2000); /* YES */
parseDateTime(2000); /* CF Error */
Enter fullscreen mode Exit fullscreen mode

A year ago, 12/31/292278993 was considered a valid date by Adobe ColdFusion.
More info here:
https://dev.to/gamesover/coldfusion-dates-m-d-yyyyyyyyy-555h
https://tracker.adobe.com/#/view/CF-4204879
(ACF also returned TRUE for isvalid("integer", 2147483648) and a value like $45000.)

Here are some test date strings that I've used to compare ColdFusion date parsing against a client-side DateJS library that I use.
https://gist.github.com/JamoCA/acd9514b5b8cd9c3c37308aa8f48fd18

šŸ‘‹ One new thing before you go

Tired of spending so much on your side projects? šŸ˜’

We have created a membership program that helps cap your costs so you can build and experiment for less. And we currently have early-bird pricing which makes it an even better value! šŸ„

Substantially upgrade your career earning potential for $8/month ā¤ļø

Top comments (2)

Collapse
 
mellen profile image
Matt Ellen-Tsivintzeli ā€¢

Apart from the American ordering to the month and the date, why isn't 12/31/292278993 a date? I'll admit that we probably won't be using the same calendar system in 292278993, but we don't know what it will be, so why not stick with the one we know?

Collapse
 
gamesover profile image
James Moberg ā€¢

We may need to deal with this before 12/31/9999. The current max date for MSSQL SqlDateTime while java is 12/31/999999999. Luckily none of my clients are asking to schedule anything that far out in advance "yet".

What would it take to get all related technologies to agree on a standard? (ie, the current max date for java is 12/31/999999999.)

A recent project had a high lifetime membership calculation bug. Instead of entering "birthdate", the customer entered "current age". Server-side isDate() returned "yes" that the integer was a valid date, but couldn't perform a DateDiff() using the "valid date". To fix, I added a check using isValid("usdate", birthdate).

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

šŸ‘‹ Kindness is contagious

Engage with a sea of insights in this enlightening article, highly esteemed within the encouraging DEV Community. Programmers of every skill level are invited to participate and enrich our shared knowledge.

A simple "thank you" can uplift someone's spirits. Express your appreciation in the comments section!

On DEV, sharing knowledge smooths our journey and strengthens our community bonds. Found this useful? A brief thank you to the author can mean a lot.

Okay