Overview
| Artifact ID: | f7d7a9e8541407b59a040844af36a4df9aa9416a07752361f25e50bfee7ac6fa |
|---|---|
| Ticket: | c6f1ffa7a96b949c58b5bae73d6184c6ccbf4b0e
clock scan/freescan deviation (wrong conversion) if TZ specified in the input |
| User & Date: | sebres on 2019-05-01 16:05:15 |
Changes
- icomment:
Following snippet illustrates the ambiguity problem: The time-point of the applying of time zone if only time is provided for scan of if some info is missing and will be retrieved from base. Rather it looks like a precedence question - which time zone should win: <ul> <li>- either the default (or specified as argument) (Variant 1)</li> <li>- or specified in the input string (Variant 2)</li> </ul> <code><pre style="padding-left:10pt"> proc _test {base args} { foreach defTZ {:GMT :America/New_York} { set trgTZ [lindex $args 0 end] puts "== $defTZ ==" puts "base:\t[clock format $base -timezone $defTZ -locale en]\t = [clock format $base -timezone $trgTZ -locale en]" set time [clock scan {*}$args -timezone $defTZ -base $base] puts "scan:\t[clock format $time -timezone $defTZ -locale en]\t = [clock format $time -timezone $trgTZ -locale en]" } } </pre></code> <b>Variant 1:</b><br/> scan assumes retrieving date of base using <b>default TZ (or given as argument)</b>,<br/> this is the current behaviour of free-scan in tcl-core <pre style="padding-left:10pt"> % _test 1556240400 {10:00 GMT} -format {%H:%M %Z} == :GMT == base: Fri Apr 26 01:00:00 GMT 2019 = Fri Apr 26 01:00:00 GMT 2019 <b style="color:green">scan: Fri Apr 26 10:00:00 GMT 2019 = Fri Apr 26 10:00:00 GMT 2019</b> == :America/New_York == base: Thu Apr 25 21:00:00 EDT 2019 = Fri Apr 26 01:00:00 GMT 2019 <b style="color:blue">scan: Thu Apr 25 06:00:00 EDT 2019 = Thu Apr 25 10:00:00 GMT 2019</b> </pre> <b>Variant 2:</b><br/> scan assumes retrieving date of base using TZ <b>from the input</b> after time,<br/> this is the current behaviour of format-scan in tcl-core <pre style="padding-left:10pt"> % _test 1556240400 {10:00 GMT} -format {%H:%M %Z} == :GMT == base: Fri Apr 26 01:00:00 GMT 2019 = Fri Apr 26 01:00:00 GMT 2019 <b style="color:green">scan: Fri Apr 26 10:00:00 GMT 2019 = Fri Apr 26 10:00:00 GMT 2019</b> == :America/New_York == base: Thu Apr 25 21:00:00 EDT 2019 = Fri Apr 26 01:00:00 GMT 2019 <b style="color:blue">scan: Fri Apr 26 06:00:00 EDT 2019 = Fri Apr 26 10:00:00 GMT 2019</b> </pre> My tclclockmod (and clock-speedup branch) uses Variant 1 at the moment:<br/> the missing input-parts are converted from base relative to default/argument time zone, so it has precedence over the time zone specified in input (which is then applied only to the time resp. values of the input string). And current (broken) state of tcl-core (in all versions):<br/> format-scan and free-scan working differently (and this is uncovered in test-suite at the moment). Here is the result as diff: <pre style="padding-left:10pt"> <b style="color:red">-% _test 1556240400 {10:00 GMT} -format {%H:%M %Z}; # format scan</b> <b style="color:green">+% _test 1556240400 {10:00 GMT} ; # free scan</b> == :GMT == base: Fri Apr 26 01:00:00 GMT 2019 = Fri Apr 26 01:00:00 GMT 2019 scan: Fri Apr 26 10:00:00 GMT 2019 = Fri Apr 26 10:00:00 GMT 2019 == :America/New_York == base: Thu Apr 25 21:00:00 EDT 2019 = Fri Apr 26 01:00:00 GMT 2019 <b style="color:red">-scan: Fri Apr 26 06:00:00 EDT 2019 = Fri Apr 26 10:00:00 GMT 2019</b> <b style="color:green">+scan: Thu Apr 25 06:00:00 EDT 2019 = Thu Apr 25 10:00:00 GMT 2019</b> </pre> - login: "sebres"
- mimetype: "text/x-fossil-wiki"