Overview
| Artifact ID: | 805825756cace2527dc29f8617c28edb5de516a2f6391051121b0155daf9c0c9 |
|---|---|
| Ticket: | c6f1ffa7a96b949c58b5bae73d6184c6ccbf4b0e
clock scan/freescan deviation (wrong conversion) if TZ specified in the input |
| User & Date: | sebres on 2019-05-02 19:18:26 |
Changes
- icomment:
More tests showing additionally another basic difference between both scan proceedings - fixed-format scan is following the general rule "if the string contains neither a %s format group nor a group specifying the hour of the day, then midnight (00:00, the start of the given date) is used." as it is documented, where free scan is always preferring a current time in this case. Here is a short script illustrating this difference related to the time zone issue (so free scan is also wrong here if another TZ used in the input): <code><pre style="padding-left:10pt; font-size:80%"> foreach tz {"GMT" "CET" "CEST" "CST" "CDT" "EST" "EDT"} { foreach s { {clock scan $tz -format %Z -base 100000000 -gmt 1} {clock scan $tz -base 100000000 -gmt 1} } { puts "% [format %-55s [subst $s]] ==> [format %10s [set c [if 1 $s]]], [catch {clock format $c -timezone $tz -locale en} r; set r]" } } puts -------------------------- foreach tz {"GMT" "CET" "EST"} { foreach s { {clock scan "" -format "" -base 100000000 -timezone $tz} {clock scan "" -base 100000000 -timezone $tz} } { puts "% [format %-55s [subst $s]] ==> [format %10s [set c [if 1 $s]]], [catch {clock format $c -timezone $tz -locale en} r; set r]" } } </pre></code> Original (unpatched tcl-clock): <code><pre style="padding-left:10pt; font-size:80%"> % clock scan GMT -format %Z -base 100000000 -gmt 1 ==> 99964800, Sat Mar 03 00:00:00 GMT 1973 % clock scan GMT -base 100000000 -gmt 1 ==> <b style="color:green">100000000, Sat Mar 03 09:46:40 GMT 1973</b> % clock scan CET -format %Z -base 100000000 -gmt 1 ==> 99961200, Sat Mar 03 00:00:00 CET 1973 % clock scan CET -base 100000000 -gmt 1 ==> <b style="color:red">99996400, Sat Mar 03 09:46:40 CET 1973</b> % clock scan CEST -format %Z -base 100000000 -gmt 1 ==> 99957600, time zone CEST not found % clock scan CEST -base 100000000 -gmt 1 ==> 99992800, time zone CEST not found % clock scan CST -format %Z -base 100000000 -gmt 1 ==> 99986400, time zone CST not found % clock scan CST -base 100000000 -gmt 1 ==> 100021600, time zone CST not found % clock scan CDT -format %Z -base 100000000 -gmt 1 ==> 99982800, time zone CDT not found % clock scan CDT -base 100000000 -gmt 1 ==> 100018000, time zone CDT not found % clock scan EST -format %Z -base 100000000 -gmt 1 ==> 99982800, Sat Mar 03 00:00:00 EST 1973 % clock scan EST -base 100000000 -gmt 1 ==> <b style="color:red">100018000, Sat Mar 03 09:46:40 EST 1973</b> % clock scan EDT -format %Z -base 100000000 -gmt 1 ==> 99979200, time zone EDT not found % clock scan EDT -base 100000000 -gmt 1 ==> 100014400, time zone EDT not found -------------------------- % clock scan "" -format "" -base 100000000 -timezone GMT ==> 99964800, Sat Mar 03 00:00:00 GMT 1973 % clock scan "" -base 100000000 -timezone GMT ==> 100000000, Sat Mar 03 09:46:40 GMT 1973 % clock scan "" -format "" -base 100000000 -timezone CET ==> 99961200, Sat Mar 03 00:00:00 CET 1973 % clock scan "" -base 100000000 -timezone CET ==> 100000000, Sat Mar 03 10:46:40 CET 1973 % clock scan "" -format "" -base 100000000 -timezone EST ==> 99982800, Sat Mar 03 00:00:00 EST 1973 % clock scan "" -base 100000000 -timezone EST ==> 100000000, Sat Mar 03 04:46:40 EST 1973 </pre></code> The fix changes the behavior, considering the higher precedence of TZ in input, as well as the general rule (no time == 00:00) of the fixed-format scan and free scan (no time == time of now): <code><pre style="padding-left:10pt; font-size:80%"> % clock scan GMT -format %Z -base 100000000 -gmt 1 ==> 99964800, Sat Mar 03 00:00:00 GMT 1973 % clock scan GMT -base 100000000 -gmt 1 ==> 100000000, Sat Mar 03 09:46:40 GMT 1973 % clock scan CET -format %Z -base 100000000 -gmt 1 ==> 99961200, Sat Mar 03 00:00:00 CET 1973 % clock scan CET -base 100000000 -gmt 1 ==> 100000000, Sat Mar 03 10:46:40 CET 1973 % clock scan CEST -format %Z -base 100000000 -gmt 1 ==> 99957600, Sat Mar 03 00:00:00 +0200 1973 % clock scan CEST -base 100000000 -gmt 1 ==> 100000000, Sat Mar 03 11:46:40 +0200 1973 % clock scan CST -format %Z -base 100000000 -gmt 1 ==> 99986400, Sat Mar 03 00:00:00 -0600 1973 % clock scan CST -base 100000000 -gmt 1 ==> 100000000, Sat Mar 03 03:46:40 -0600 1973 % clock scan CDT -format %Z -base 100000000 -gmt 1 ==> 99982800, Sat Mar 03 00:00:00 -0500 1973 % clock scan CDT -base 100000000 -gmt 1 ==> 100000000, Sat Mar 03 04:46:40 -0500 1973 % clock scan EST -format %Z -base 100000000 -gmt 1 ==> 99982800, Sat Mar 03 00:00:00 EST 1973 % clock scan EST -base 100000000 -gmt 1 ==> 100000000, Sat Mar 03 04:46:40 EST 1973 % clock scan EDT -format %Z -base 100000000 -gmt 1 ==> 99979200, Sat Mar 03 00:00:00 -0400 1973 % clock scan EDT -base 100000000 -gmt 1 ==> 100000000, Sat Mar 03 05:46:40 -0400 1973 -------------------------- % clock scan "" -format "" -base 100000000 -timezone GMT ==> 99964800, Sat Mar 03 00:00:00 GMT 1973 % clock scan "" -base 100000000 -timezone GMT ==> 100000000, Sat Mar 03 09:46:40 GMT 1973 % clock scan "" -format "" -base 100000000 -timezone CET ==> 99961200, Sat Mar 03 00:00:00 CET 1973 % clock scan "" -base 100000000 -timezone CET ==> 100000000, Sat Mar 03 10:46:40 CET 1973 % clock scan "" -format "" -base 100000000 -timezone EST ==> 99982800, Sat Mar 03 00:00:00 EST 1973 % clock scan "" -base 100000000 -timezone EST ==> 100000000, Sat Mar 03 04:46:40 EST 1973 </pre></code> - login: "sebres"
- mimetype: "text/x-fossil-wiki"