diff options
-rw-r--r-- | tests/clock.test | 34 |
1 files changed, 19 insertions, 15 deletions
diff --git a/tests/clock.test b/tests/clock.test index f4f8c39..949b6a0 100644 --- a/tests/clock.test +++ b/tests/clock.test @@ -10,13 +10,27 @@ # 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.33 2004/07/10 21:02:28 kennykb Exp $ +# RCS: @(#) $Id: clock.test,v 1.34 2004/07/10 21:26:10 kennykb Exp $ if { [info exists env(LC_TIME)] } { set oldlctime $env(LC_TIME) } set env(LC_TIME) POSIX +proc saveTZ {} { + if { [info exists ::env(TZ)] } { + set ::oldTZ $::env(TZ) + } +} +proc restoreTZ {} { + if { [info exists ::oldTZ] } { + set ::env(TZ) $::oldTZ + unset ::oldTZ + } else { + unset ::env(TZ) + } +} + if {[lsearch [namespace children] ::tcltest] == -1} { package require tcltest namespace import -force ::tcltest::* @@ -117,17 +131,15 @@ test clock-3.1 {clock format tests} {unix} { set clockval 657687766 clock format $clockval -format {%a %b %d %I:%M:%S %p %Y} -gmt true } {Sun Nov 04 03:02:46 AM 1990} -test clock-3.2 {clock format tests} { +test clock-3.2 {clock format tests} -setup saveTZ -body { # TCL_USE_TIMEZONE_VAR - catch {set oldtz $env(TZ)} set env(TZ) PST set x {} append x [clock format 863800000 -format %Z -gmt 1] append x [set env(TZ)] - catch {unset env(TZ); set env(TZ) $oldtz} set x -} {GMTPST} +} -cleanup restoreTZ -result {GMTPST} test clock-3.3 {clock format tests} { # tzset() under Borland doesn't seem to set up tzname[] for local # timezone, which caused "clock format" to think that %Z was an invalid @@ -186,22 +198,14 @@ test clock-3.13 {clock format with non-ASCII character in the format string} { # Bug 942078 test clock-3.14 {change of time zone} -setup { - catch { unset oldTZ } - if { [info exists env(TZ)] } { - set oldTZ $env(TZ) - } + saveTZ } -body { set env(TZ) PST8PDT set s [clock format 0 -format %H%M] set env(TZ) GMT0 append s -[clock format 0 -format %H%M] } -cleanup { - if { [info exists oldTZ] } { - set env(TZ) $oldTZ - unset oldTZ - } else { - unset env(TZ) - } + restoreTZ } -result {1600-0000} # clock scan |