diff options
author | Kevin B Kenny <kennykb@acm.org> | 2004-09-10 17:50:11 (GMT) |
---|---|---|
committer | Kevin B Kenny <kennykb@acm.org> | 2004-09-10 17:50:11 (GMT) |
commit | 02ca88a79487e618d0aa1bf9a949ecb18cbd0acc (patch) | |
tree | 4fef37d05f8f4b25936248edab8b9337623ea24b | |
parent | 7ae4115a5e7d953245963c4287ad342e9c0f54ba (diff) | |
download | tcl-02ca88a79487e618d0aa1bf9a949ecb18cbd0acc.zip tcl-02ca88a79487e618d0aa1bf9a949ecb18cbd0acc.tar.gz tcl-02ca88a79487e618d0aa1bf9a949ecb18cbd0acc.tar.bz2 |
fixed a bug where %z was always positive in :localtime
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | library/clock.tcl | 11 | ||||
-rw-r--r-- | tests/clock.test | 22 |
3 files changed, 33 insertions, 6 deletions
@@ -1,3 +1,9 @@ +2004-09-10 Kevin Kenny <kennykb@acm.org> + + * library/clock.tcl: Fixed a bug where %z always put a plus + sign on the time zone in :localtime. + * tests/clock.test: Added test case for the above bug. + 2004-09-10 Miguel Sofer <msofer@users.sf.net> * generic/tclExecute.c (INST_CONCAT1): added a peephole diff --git a/library/clock.tcl b/library/clock.tcl index 1152576..d26c2c8 100644 --- a/library/clock.tcl +++ b/library/clock.tcl @@ -13,7 +13,7 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # -# RCS: @(#) $Id: clock.tcl,v 1.4 2004/09/07 17:38:56 kennykb Exp $ +# RCS: @(#) $Id: clock.tcl,v 1.5 2004/09/10 17:50:15 kennykb Exp $ # #---------------------------------------------------------------------- @@ -3061,12 +3061,13 @@ proc ::tcl::clock::ConvertUTCToLocalViaC { date } { # Determine the name and offset of the timezone - set delta [expr { $localSeconds - $gmtSeconds }] - if { $delta <= 0 } { + set diff [expr { $localSeconds - $gmtSeconds }] + if { $diff <= 0 } { set signum - - set delta [expr { - $delta }] + set delta [expr { - $diff }] } else { set signum + + set delta $diff } set hh [::format %02d [expr { $delta / $SecondsPerHour }]] set mm [::format %02d [expr { ($delta / $SecondsPerMinute ) @@ -3081,7 +3082,7 @@ proc ::tcl::clock::ConvertUTCToLocalViaC { date } { # Fix the dictionary dict set date localSeconds $localSeconds - dict set date tzOffset $delta + dict set date tzOffset $diff dict set date tzName $zoneName return $date diff --git a/tests/clock.test b/tests/clock.test index acb7a6e..a83ebf0 100644 --- a/tests/clock.test +++ b/tests/clock.test @@ -11,7 +11,7 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # -# RCS: @(#) $Id: clock.test,v 1.43 2004/09/08 18:46:18 kennykb Exp $ +# RCS: @(#) $Id: clock.test,v 1.44 2004/09/10 17:50:15 kennykb Exp $ if {[lsearch [namespace children] ::tcltest] == -1} { package require tcltest 2 @@ -35261,6 +35261,26 @@ test clock-41.1 {regression test - format group %k when hour is 0 } { clock format 0 -format %k -gmt true } { 0} +test clock-42.1 {regression test - %z in :localtime when west of Greenwich } \ + -setup { + if { [info exists env(TZ)] } { + set oldTZ $env(TZ) + } + set env(TZ) EST5 + } \ + -body { + clock format 0 -format %z -timezone :localtime + } \ + -cleanup { + if { [info exists oldTZ] } { + set env(TZ) $oldTZ + unset oldTZ + } else { + unset env(TZ) + } + } \ + -result {-0500} + # cleanup namespace delete ::testClock |