a little more on datetime
Timothy Miller
gandalf at doctorTimothyMiller.com
Sun Dec 18 20:29:26 EST 2005
Greetings,
As Jacque recently mentioned, RR is inconsistent in the way it copes
with dates and times, when interpreting, sorting or converting
values. How true!
As far as I can tell, the IDE will appear to sort datetime or convert
from one dateTime format to another, without producing an error
message, regardless of the value in question. It will do so in cases
where the value is almost, but not quite completely unlike a date or
a time. If the IDE cannot understand the value as a date or time, it
sorts as if the value were alphanumeric, or ignores the convert
command.
In addition, it will report a value is a date, but then refuse to
recognize the same value as a date when converting or sorting.
Try this:
on mouseUp
put " 11/24/96" into var1
answer (var1 is a date)
convert var1 to seconds
answer the result
answer var1
end mouseUp
At least on my machine and version, the IDE reports the value is a
date, but then refuses to convert it, or converts it incorrectly. The
result is empty.
This example even stranger:
on mouseUp
put " 11/24/96" & cr & "avfdt" into var1
answer (var1 is a date)
convert var1 to seconds
answer the result
answer var1
end mouseUp
The IDE says the value in the second example is also a number, but it
ignores the same leading spaces AND the second line, AND correctly
converts the first line, leading spaces and all, to seconds! The
result is still empty.
The second example suggests a handy hack if you want to force the IDE
to correctly interpret certain badly formatted dates or times. Just
ad a cr and some nonsense characters in the second line. I'm mostly
joking...
Maybe this is all as it must be, for obscure reasons. Still, it seems
to me the user needs a break here. A small and likely easy step would
be for the IDE to give the user a result, if the user cares to take
advantage of it. "Ambiguous dateTime value" other such words might be
helpful in some cases. "Value not in dateTime format" and "value
contains multiple lines" are other possibilities.
The IDE seems to be making these determinations anyway, but not reporting them.
Is this is a bad idea?
Cheers,
Tim
More information about the use-livecode
mailing list