summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog7
-rw-r--r--library/clock.tcl27
-rw-r--r--tests/clock.test33
3 files changed, 56 insertions, 11 deletions
diff --git a/ChangeLog b/ChangeLog
index d219048..5cf8570 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2011-10-18 Reinhard Max <max@suse.de>
+
+ * library/clock.tcl (::tcl::clock::GetSystemTimeZone): Cache the
+ time zone only if it was detected by one of the expensive
+ methods. Otherwise after unsetting TCL_TZ or TZ the previous value
+ will still be used.
+
2011-10-15 Venkat Iyer <venkat@comit.com>
* library/tzdata/America/Sitka : Update to Olson's tzdata2011l
* library/tzdata/Pacific/Fiji
diff --git a/library/clock.tcl b/library/clock.tcl
index b6ff359..2a4c7bd 100644
--- a/library/clock.tcl
+++ b/library/clock.tcl
@@ -3012,18 +3012,23 @@ proc ::tcl::clock::GetSystemTimeZone {} {
set timezone $result
} elseif {[set result [getenv TZ]] ne {}} {
set timezone $result
- } elseif { [info exists CachedSystemTimeZone] } {
- set timezone $CachedSystemTimeZone
- } elseif { $::tcl_platform(platform) eq {windows} } {
- set timezone [GuessWindowsTimeZone]
- } elseif { [file exists /etc/localtime]
- && ![catch {ReadZoneinfoFile \
- Tcl/Localtime /etc/localtime}] } {
- set timezone :Tcl/Localtime
- } else {
- set timezone :localtime
}
- set CachedSystemTimeZone $timezone
+ if {![info exists timezone]} {
+ # Cache the time zone only if it was detected by one of the
+ # expensive methods.
+ if { [info exists CachedSystemTimeZone] } {
+ set timezone $CachedSystemTimeZone
+ } elseif { $::tcl_platform(platform) eq {windows} } {
+ set timezone [GuessWindowsTimeZone]
+ } elseif { [file exists /etc/localtime]
+ && ![catch {ReadZoneinfoFile \
+ Tcl/Localtime /etc/localtime}] } {
+ set timezone :Tcl/Localtime
+ } else {
+ set timezone :localtime
+ }
+ set CachedSystemTimeZone $timezone
+ }
if { ![dict exists $TimeZoneBad $timezone] } {
dict set TimeZoneBad $timezone [catch {SetupTimeZone $timezone}]
}
diff --git a/tests/clock.test b/tests/clock.test
index 8c31f83..bda5e76 100644
--- a/tests/clock.test
+++ b/tests/clock.test
@@ -35895,6 +35895,39 @@ test clock-38.1 {regression - convertUTCToLocalViaC - east of Greenwich} \
} \
-result {01:00:00}
+test clock-38.2 {make sure TZ is not cached after unset} \
+ -setup {
+ if { [info exists env(TZ)] } {
+ set oldTZ $env(TZ)
+ unset env(TZ)
+ }
+ if { [info exists env(TCL_TZ)] } {
+ set oldTCLTZ $env(TCL_TZ)
+ unset env(TCL_TZ)
+ }
+ } \
+ -body {
+ set t1 [clock format 0]
+ # a time zone that is unlikely to anywhere
+ set env(TZ) "+04:20"
+ set t2 [clock format 0]
+ unset env(TZ)
+ set t3 [clock format 0]
+ expr {$t1 eq $t3 && $t1 ne $t2}
+ } \
+ -cleanup {
+ if { [info exists oldTZ] } {
+ set env(TZ) $oldTZ
+ unset oldTZ
+ }
+ if { [info exists oldTclTZ] } {
+ set env(TCL_TZ) $oldTclTZ
+ unset oldTclTZ
+ }
+ } \
+ -result 1
+
+
test clock-39.1 {regression - synonym timezones} {
clock format 0 -format {%H:%M:%S} -timezone :US/Eastern
} {19:00:00}
q>h ` 3q{5+37ihZXIƙDdYQ٦tywH0"('_595O] euZx.c{څTU0&K0.UԜP4biH$zbu}U8J+R0s91}/WRQ!Wpn,XG>2PB' ?pBFY%Qf-:YhƶU3T5u x686{1jԒBbPnDq/Pnz!zYta"Ev2hfTioL*;[ BuЉ4`eQ$0$ƝgqJʆpE(*WKjĝv'k:NUxmZf\+C'Ӱ18An Ku^i#37D{d>=''gB,w2cKy&gGЌ! L0A?rieF_*wŇ`ιcхP|:$=,Pe`}P{Fn8נi^T 29;Lu{lE]oFE^!qm7aT2p6tumcCt| 0T)!stV2i}> } Amљha4Mٲ'qPT@ch;CnHQB3]bfpʶ[N5ahdѢТZٸJAvR`b=>->8AFl ..SI`,698eHwyj{Ab34^ ra2RgСT uɎM,ģФoݡt&rz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