> <your UI>
> Type a date like this yyyy/mm/dd: <input type="text" />
> </your UI>
>
> Don't trust users.
sadly, it's more complicated than that. Yes, we don't trust uses but we
have an orginisational spec to follow. A user HAS to be able to fill out a
form entirely using the keyboard (no mouse). this means short-cut keys and
taborders AND entering the date as ddmmyyy (no delims). we use javascript
to convert that to (in this case yyyy-mm-dd*) as well as client side
validation. we also have a date picker (pop-up calendar) for mouse users.
the app knows the user is Australian and displays as dd/mm/yyyy BUT
there's a matching hidden form element with the REAL date in it that will
get used, ready for server side validation (which sparked the origional
post).
<cftry>
<cfset theDate = LSDateFormat(trim(form.theDate), "yyyy-mm-dd")>
<cfcatch><!--- HACKER ALERT ---></cfcatch>
</cftry>
(* it was origionally "dd mmm yyyy" with text month so CF shouldn't get it
wrong. I still reckon yyyy-mm-dd will work better, be more consistant, etc
- that's why I'm spending so much energy on this. It's a technique learned
from ASP getting it wrong and ISO dates comming to the rescue and
ultimatly from the US thinking that their format is the only one that
matters)
> A convenient aside:
> I used to work for the organisation in NZ that accredited things like ISO
> standards... and until today I didn't even *know* there was an ISO standard
> for date formatting.
yes, every decent db understands the ISO date format. the trick is to
specify the yyyy so it can get it right.
> > OR LSParseDateTime(date/time-string)?
> > sorry, no ISO date masks supported
>
> This is where your complaint should lie.
> This function *doesn't work*.
agreed. Darren Tracey's (he knows all about these woes, as do many people
on this list) comments about the lack of LS testers seems plausable.
> But *is* it simply a specially-formatted string, or is CF doing a type
> conversion when you ask a date/time object to display (which inherently
> needs to cast it as a string).
sometimes CF thinks too much. Last year I had a string with "{ts '..." at
the start and CF was desperatly trying to convert it into a date - even
when it wasn't and I didn't want it to. go figure.
manually piecing the "date/time object" from a string (adding {ts '...'},
etc) has been the previous work-around. While it HAS worked, I still have
my doubts and are quietly confident that the ISO way will cure all.
thanx for your input Adam (and others). What this thread has shown is a
lack of decent date format handeling and inadequacies with LS functions.
When I prove the ISO format will consistantly work, I'll write it up and
post it somewhere so people will never have grief with dates and CF again
(big hope/wish, methinks) - until Blackstone has re-worked date handeling
and dependable LS functions (even bigger wish)
cheers
barry.b
---
You are currently subscribed to cfaussie as: [EMAIL PROTECTED]
To unsubscribe send a blank email to [EMAIL PROTECTED]
Aussie Macromedia Developers: http://lists.daemon.com.au/