isNumber vs isDate
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
isNumber vs isDate
I can use isNumber to determine if an input field has had a number entered but I'm not sure how to tell if what was just entered is a legitimate date. There does not appear to be an isDate function that returns true or false like isNumber. I have tried converting the input to dateItems and looking at that result but even a plain number will cause dateitems to give a date. Do you have a suggestion for looking at the input on closeField to tell whether the input is really a date.
Thanks,
Larry
Thanks,
Larry
Re: isNumber vs isDate
Hi Larry,
you CAN in fact do this:
...
answer ("10/8/12" is a date)
## -> true
...
Although there is no function "isDate".
Best
Klaus
you CAN in fact do this:
...
answer ("10/8/12" is a date)
## -> true
...

Although there is no function "isDate".
Best
Klaus
Re: isNumber vs isDate
Klaus-
The problem isn't with determining what is a date, but what isn't a date.
put 1234 is a date
==> true
the date functions are so flexible and forgiving of user inputs that it's harder for something to fail date verification.
The problem isn't with determining what is a date, but what isn't a date.
put 1234 is a date
==> true
the date functions are so flexible and forgiving of user inputs that it's harder for something to fail date verification.
PowerDebug http://powerdebug.ahsoftware.net
PowerTools http://www.ahsoftware.net/PowerTools/PowerTools.irev
PowerTools http://www.ahsoftware.net/PowerTools/PowerTools.irev
Re: isNumber vs isDate
Hi Mark,
yes, you are right, always forget this :-/
yes, you are right, always forget this :-/
Re: isNumber vs isDate
Hi,
I believe the isNumber and isDate are SuperCard syntax.
If a string is a number, then it is probably not date, but it could be seconds or milliseconds.
You might want to check that the date consists of 3 items in the last case.
Kind regards,
Mark
I believe the isNumber and isDate are SuperCard syntax.
If a string is a number, then it is probably not date, but it could be seconds or milliseconds.
Code: Select all
put ("10/10/10" is not a number) and ("10/10/10" is a date)
--> true
put ("123456" is not a number) and ("123456" is a date)
--> false
put ("abcdefgh" is not a number) and ("abcdefgh" is a date)
--> false
The following is slightly problematic:
put ("10/10" is not a number) and ("10/10" is a date)
--> true
Kind regards,
Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
Re: isNumber vs isDate
This goes way, way back. It can be managed easily, but talk about too flexible. You always have to remember to make sure that what you WANT to be a date is the only form that is allowed.
Craig
Craig