Tcl Source Code

Check-in [0cf2dfd2bf]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Don't cache the system timezone when it was derived from TCL_TZ or TZ.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | core-8-5-branch
Files: files | file ages | folders
SHA1: 0cf2dfd2bf81be22ad802f08d3062a525e0768d0
User & Date: max 2011-10-18 13:03:42
Context
2011-10-20
15:32
Update changes toward 8.5.11 release. Bump to http 2.7.7. check-in: 8010db2398 user: dgp tags: core-8-5-branch
2011-10-18
13:03
Don't cache the system timezone when it was derived from TCL_TZ or TZ. check-in: 0cf2dfd2bf user: max tags: core-8-5-branch
2011-10-15
10:21
Update to Olson's tzdata2011l check-in: d11be2712d user: venkat tags: core-8-5-branch
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to ChangeLog.








1
2
3
4
5
6
7







2011-10-15  Venkat Iyer <[email protected]>
	* library/tzdata/America/Sitka : Update to Olson's tzdata2011l
	* library/tzdata/Pacific/Fiji
	* library/tzdata/Asia/Hebron (New)

2011-10-11  Jan Nijtmans  <[email protected]>

>
>
>
>
>
>
>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
2011-10-18  Reinhard Max  <[email protected]>

	* 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 <[email protected]>
	* library/tzdata/America/Sitka : Update to Olson's tzdata2011l
	* library/tzdata/Pacific/Fiji
	* library/tzdata/Asia/Hebron (New)

2011-10-11  Jan Nijtmans  <[email protected]>

Changes to library/clock.tcl.

3072
3073
3074
3075
3076
3077
3078




3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090

3091
3092
3093
3094
3095
3096
3097
    variable CachedSystemTimeZone
    variable TimeZoneBad

    if {[set result [getenv TCL_TZ]] ne {}} {
	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 { ![dict exists $TimeZoneBad $timezone] } {
	dict set TimeZoneBad $timezone [catch {SetupTimeZone $timezone}]
    }
    if { [dict get $TimeZoneBad $timezone] } {
	return :localtime
    } else {
	return $timezone







>
>
>
>
|
|
|
|
|
|
|
|
|
|
|
|
>







3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
    variable CachedSystemTimeZone
    variable TimeZoneBad

    if {[set result [getenv TCL_TZ]] ne {}} {
	set timezone $result
    } elseif {[set result [getenv TZ]] ne {}} {
	set timezone $result
    }
    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}]
    }
    if { [dict get $TimeZoneBad $timezone] } {
	return :localtime
    } else {
	return $timezone

Changes to tests/clock.test.

35890
35891
35892
35893
35894
35895
35896

































35897
35898
35899
35900
35901
35902
35903
	    set env(TZ) $oldTZ
	    unset oldTZ
	} else {
	    unset env(TZ)
	}
    } \
    -result {01:00:00}


































test clock-39.1 {regression - synonym timezones} {
    clock format 0 -format {%H:%M:%S} -timezone :US/Eastern
} {19:00:00}

test clock-40.1 {regression - bad month with -timezone :localtime} \
    -setup {







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







35890
35891
35892
35893
35894
35895
35896
35897
35898
35899
35900
35901
35902
35903
35904
35905
35906
35907
35908
35909
35910
35911
35912
35913
35914
35915
35916
35917
35918
35919
35920
35921
35922
35923
35924
35925
35926
35927
35928
35929
35930
35931
35932
35933
35934
35935
35936
	    set env(TZ) $oldTZ
	    unset oldTZ
	} else {
	    unset env(TZ)
	}
    } \
    -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}

test clock-40.1 {regression - bad month with -timezone :localtime} \
    -setup {