Re: clock scan oddity



Donald Arseneau wrote:
> Good Monday morning,
> Here is a puzzle I just ran into.
>
> clock scan "x15:19:01 Jun 11, 2000" -gmt 1
>
> returns 960697141, though I expected an error. Does anyone
> know what is the "x" is interpretd as?
>
> "15:19:01 Jun 11, 2000" (gmt) is 960736741, which is 11 hours
> different.
>
> --
> Donald Arseneau asnd@xxxxxxxxx

Hello at a late hour on Monday,
in Europe ;-)

It seems that "x" is not the only interpreted character. I did a small
test using the following piece of code:

foreach x [list a b c d e f g h i j k l m n o p q r s t u v w x y z] {
set inst 0
foreach y [list $x [string toupper $x]] {
puts -nonewline [format %-3s $y]
if {[catch {puts -nonewline [format %-11s [set inst \
[clock scan "${y}15:19:01 Jun 11, 2000" -gmt 1]]]}]} {
puts -nonewline [format %-11s ""]
}
}
if {$inst != 0} {
puts [clock format [expr $ref - $inst] -format %H:%M:%S]
} else {puts ""}
}

The code evaluates [clock scan "${y}15:19:01 Jun 11, 2000" -gmt 1],
with ${y} replaced each time by an alphabetic character in lower and
upper cases. It shows [clock scan] value for each character and the
difference in hour:min:sec between the original date-time string and
the same string with the character inserted.

Here is the result:

a 960740341 A 960740341 23:00:00
b 960743941 B 960743941 22:00:00
c 960747541 C 960747541 21:00:00
d 960751141 D 960751141 20:00:00
e 960754741 E 960754741 19:00:00
f 960758341 F 960758341 18:00:00
g 960761941 G 960761941 17:00:00
h 960765541 H 960765541 16:00:00
i 960769141 I 960769141 15:00:00
j J
k 960772741 K 960772741 14:00:00
l 960776341 L 960776341 13:00:00
m 960779941 M 960779941 12:00:00
n 960733141 N 960733141 01:00:00
o 960729541 O 960729541 02:00:00
p 960725941 P 960725941 03:00:00
q 960722341 Q 960722341 04:00:00
r 960718741 R 960718741 05:00:00
s S
t 960711541 T 960711541 07:00:00
u 960707941 U 960707941 08:00:00
v 960704341 V 960704341 09:00:00
w 960700741 W 960700741 10:00:00
x 960697141 X 960697141 11:00:00
y 960693541 Y 960693541 12:00:00
z 960736741 Z 960736741 00:00:00

It is shown that:
- interpretation is the same for the same letter in lower
and upper cases.
- with j/J and s/S inserted, [clock scan] was not able to
interpret the date-time string.
- both y/Y and m/M give a difference of 12 hours from the
original string.
- no letter gives 6 hours differnce.
- a/A gives the maximum 23 hours differnce, and z/Z gives
no differnce.
- it seems that there is some sort of ordering of the diffe-
rences given by the interpretation of different letters.
- all letters give perfect hours differences, no minutes or
seconds.

Further testing showed that:
- The following strings are interpreted similarly:
"${y}15:19:01 Jun 11, 2000"
"15:19:01${y} Jun 11, 2000"
"15:19:01 Jun 11, 2000${y}"
They give exactly the same results shown above.

- if "${y}" is put anywhere else in the string, interpretation
fails for all letters.

I don't know the reason for this, but I tried to find some
mathematical/logical patterns in these results, oh but I'm tired. It
would be easier perhaps to have a look at the C code for [clock]. I
might be doing this tomorrow if I'm not still tired :^)

Khaled

.



Relevant Pages

  • Re: Incorrect use of documentary sources
    ... an interpretation, not word to word or literal translation. ... For example; " A string ... The above poster is again abusing this forum with his use of corrupt ...
    (rec.games.mahjong)
  • Re: info dicts?
    ... In my understanding is a dictionary just a specific interpretation of a ... string though. ... dict update dictionaryVariable key varName ?key varName ...? ...
    (comp.lang.tcl)
  • Re: Anonymous string constants
    ... If you want to save a string, ... "The interpretation semantics for S" are intended to provide a simple ... mechanism for entering a string in the interpretation state. ... ==> When the possibility of overwriting a string can arise, ...
    (comp.lang.forth)
  • Re: atoi return
    ... strtolisn't just used to determine the integer value of a string. ... because there's a mathematically correct value but it's not ... I'm not saying that my interpretation is the only possible one, ...
    (comp.lang.c)
  • Re: how to generate executables?
    ... since the string is allocated memory, ... interpretive mode (compilation works fine). ... interpretation;-) And will not survive saving and restarting the program. ...
    (comp.lang.forth)