While I'm still struggling to find the time to work on new features for the CFJS libraries (IsValid, ArrayAverage, ArrayClear, ArrayDeleteAt, ArrayInsertAt, ArrayPrepend, and ArraySum), a bug in the DateFormat function had been brought to my attention by user Boyan Kostadinov. He then later pointed me to another DateFormat function written by Steve Levithan.
Steve's DateFormat function is very nice, and since Steve does some ColdFusion programming the syntax is very similar. Steve implemented his function as an extension of the JavaScript date object, but since I've incorporated his function into both branches of the CFJS library this is no longer the case. So the CFJS syntax of the function follows more closely to the syntax of CF's native function.
In Steve's implementation you could write a line of code like this:
date.format("Today is dddd");
Which should return something like, "Today is Thursday". But when using the CFJS implementation to get the same result you'd need to write it like this:
/*using CFJS for jQuery*/
$.DateFormat(new Date(), "Today is dddd");
/*using CFJS without jQuery*/
CFSJ.DateFormat(new Date(), "Today is dddd");
Following is a table of the different metacharacters available to the DateFormat function.
(This table is almost a direct rip from Steve's blog post which discusses his function)
The most notable differences are that I've added the 't' and 'T' metacharacters to the function. While, Steve's function allowed for 'AM' or 'am' with TT and tt respectively, he did not allow for 'A' or 'a' which is what 'T' and 't' are used for.
The other major thing to note (if you haven't already) is that this new DateFormat function also handles the formatting of time. This means that there really isn't a reason to have a TimeFormat function. However, since this breaks with CF's dogma, I've written TimeFormat such that it's really just an alias of DateFormat. Someone might use DateFormat() for all their date formatting needs and TimeFormat() for all their time formatting needs, but in reality the two functions work interchangeably.
The nice thing about having one function that handles both date and time formatting is that it replaces two other functions that were quite long, and so the overall size of CFJS just went down by a bit. :o)