|
On Thu, 1 Apr 2004, Barbara Morris wrote:
> James, your API works on the assumption that the first non-failing guess
> is the correct one. Depending on what the dates mean, that could be
> dangerous, and in the long run it's less user-friendly than asking the
> user what format the dates are in.
Yes, that is intentional. We chose that because char2date() is often
called in places where there is no user to ask. We made a decision that
if a date is ambiguous, assume the *mdy representation. We could return
FAIL in those cases where there is more than one positive match, I
suppose. Regardless, in those cases where there is a user sitting at a
screen, we do validate that the date entered is what they really intended.
> I think a date-format guessing routine should check the date against all
> date formats for the date's length, and declare it invalid unless it
> matched exactly one format.
That would probably be more rigorous, but we decided to assume *mdy in
those ambiguous cases. Perhaps we made the wrong decision.
> 04/04/04 is coming up on Sunday. (That's 04/04/04 for you *MDY folks.)
That isn't really ambiguous. No matter what it means 2004-04-04.
James Rich
Zvpebfbsg vf abg gur nafjre.
Zvpebfbsg vf gur dhrfgvba.
AB (be Yvahk) vf gur nafjre.
-- Gnxra sebz n .fvtangher sebz fbzrbar sebz gur HX, fbhepr haxabja
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2025 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.