Please confirm if this is a date bug
Ken Ray
kray at sonsothunder.com
Mon Jun 4 13:47:56 EDT 2007
On Mon, 04 Jun 2007 11:06:34 -0500, Len Morgan wrote:
> I've been trying to validate a user date entry and I'm not getting
> what I think the correct result should be:
>
> in the message box (for simplicity's sake):
>
> put "05/19/1956" is a date
> false
>
> This is on Windows XP with 2.8.1. This DOES work (i.e., returns
> true) on a Mac.
>
> If the year is 1970 or higher, it will return true (as it should).
>
> This seems like it might be related to bug 4911 which reported that
> if you passed "" to is a date, it returned "12/31/1969" instead of
> "invalid date"
>
> Is there a work-around?
1970 is the Windows "beginning of time" that affects all (AFAIK)
WIndows programs that deal with dates without writing or using a custom
library (i.e. it's a Windows kernel issue). You can get around this by
simply adding 1000 to the year; if you can't add 1000 to the year - it
means the last part of the "date" is not a number (and you can return
that it's not a date). If it *does* add the 1000, you can use the rest
of the month/day to validate that with the "is a date" function. The
only trouble you might have is leap year days (Feb 29), which would
take a different calculation:
function isLeapYear pYear
return ((pYear mod 400 = 0) or ((pYear mod 4 = 0) and (pYear mod 100
<> 0)))
end isLeapYear
HTH,
Ken Ray
Sons of Thunder Software, Inc.
Email: kray at sonsothunder.com
Web Site: http://www.sonsothunder.com/
More information about the use-livecode
mailing list