check if an item is a date
J. Landman Gay
jacque at hyperactivesw.com
Thu Mar 17 11:15:57 EST 2005
On 3/17/05 6:38 AM, xbury.cs at clearstream.com wrote:
> No matter that I get weird data gathering item 3 of it... yet ANOTHER bug!
>
> But surprise!
>
> put (2485694 is a date)
I don't think this is a bug. Evaluating dates is a tricky business and I
think the engine does a pretty good job of it. We can't expect it to
read our minds and there will always be circumstances where we have to
work around some things.
You would probably be just as angry if "20050318" was not a date, since
that is a very common date notation in fixed-length databases. The
number could also be the seconds; are those not dates?
>
> It gets worse... 1 is also a date!
>
> So either the << is a date>> function is useless as a date checker and we
> all must roll our own AGAIN or
> there is a bug (or dare i add sarcastically "all of the above")...
We roll our own all the time. There are some decisions to be made about
how dates are evaluated, and I think Rev does a much better job of it
than HyperCard ever did. We had long discussions about date notation on
the HC list a few years ago. Because of the differences in system dates
(HC was distributed in dozens of different languages) the engineers on
the HC team decided to just use pattern matching to determine dates.
Thus in HyperCard:
put "1dog2dog3" is a date <-- TRUE
put "1dog2cat3" is a date <-- FALSE
Revolution says neither of these are dates. I think that is better.
>
> Is there something I missed? Can you enforce dateformat checking like you
> would in C via type casting?
Without variable typing, which is one of the strongest advantages of Rev
in my opinion, I don't see how the engine can do it any differently than
it does now. It certainly does a better job than HyperCard.
>
> The documentation was useless... Another bugzilla would delay further the
> other bugzillas which are
> blocking the release of 3 softwares since months...
>
> Any ideas other than writing YetAnotherBugDetour function?
A work-around was posted on the HC list a few years ago, you might
search those archives.
If you can think of a bullet-proof way to evaluate dates in all
languages, with all types of delimiters, with all types of system date
formats, without mistaking seconds or fixed-length notations as
non-dates, you might consider submitting a feature request with your
suggestions.
--
Jacqueline Landman Gay | jacque at hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
More information about the use-livecode
mailing list