Re: [clock scan] weirdness
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.tcl archive

Re: [clock scan] weirdness

From: Michael Schlenker <schlenk@uni-oldenburg.de>
Date: Thu Apr 27 2006 - 01:02:40 CEST

ytyourclothes@p.zapto.org schrieb:
> OK, I'm just kinda baffled by all this:
>
> (Tcl) 54 % puts $tcl_patchLevel
> 8.4.12
> (Tcl) 55 % clock format [clock scan "2005-08-05 14:20:09"]
> Fri Aug 05 2:20:09 PM Pacific Standard Time 2005
> (Tcl) 56 % clock format [clock scan "2005-08-05 14:20:09 +1"]
> unable to convert date-time string "2005-08-05 14:20:09 +1"
> (Tcl) 57 % clock format [clock scan "2005-08-05 14:20:09 i1"]
> Sun Aug 05 4:20:09 PM Pacific Standard Time 2001
> (Tcl) 58 % clock format [clock scan "2005-08-05 14:20:09 -1"]
> Fri Aug 05 7:21:09 AM Pacific Standard Time 2005
> (Tcl) 59 % clock format [clock scan "2005-08-05 14:20:09 x1"]
> Sat Aug 04 8:20:09 PM Pacific Standard Time 2001
> (Tcl) 60 % clock format [clock scan "2005-08-05 14:20:09 - 1 hour"]
> Fri Aug 05 8:21:09 AM Pacific Standard Time 2005
> (Tcl) 61 % clock format [clock scan "2005-08-05 14:20:09 + 1 hour"]
> Fri Aug 05 3:20:09 PM Pacific Standard Time 2005
>
> I'm sure there's a rational explanation why 14-1=8 and why "-1" and
> "x1" and "i1" are allowed but "+1" isn't and why "-1hour" subtracts
> 5:59 while "-1" subtracts 6:59 and why "i1" adds two hours but
> subtracts 4 years and so on but... I sure as hell don't see the
> pattern...
The clock parser is a somewhat broken yacc grammar, which is one reason
for the complete rewrite in Tcl 8.5. So the rational explanation is
likely: Broken parser.
>
> And on a more practical note: is there a way to hand [clock scan] a
> time spec like 14:20:09-400 and have it actually understand that this
> identifies a time zone?

I'm not sure if this exact pattern is usable with the new clock scan
which can get a format specifier in Tcl 8.5., but for the older format
you can only use string operations to reformat that into a recoginzed
format. (at least as far as I know, Kevin Kenny may have some magic
advice how or if it is doable with the 8.4 clock scan)

Michael
Received on Sun Apr 30 03:27:32 2006