summaryrefslogtreecommitdiffstats
path: root/library
diff options
context:
space:
mode:
authorKevin B Kenny <kennykb@acm.org>2007-03-09 01:08:58 (GMT)
committerKevin B Kenny <kennykb@acm.org>2007-03-09 01:08:58 (GMT)
commit452ddd16c36251a8d907fa8d956b3bb97bc8d345 (patch)
tree4062c627db96b3badc823f799b481e74612e0fe8 /library
parentb22292c6011d63a4bee083d4afc3678880140fce (diff)
downloadtcl-452ddd16c36251a8d907fa8d956b3bb97bc8d345.zip
tcl-452ddd16c36251a8d907fa8d956b3bb97bc8d345.tar.gz
tcl-452ddd16c36251a8d907fa8d956b3bb97bc8d345.tar.bz2
* library/clock.tcl (ReadZoneinfoFile): Added Y2038 compliance to
the code for version-2 'zoneinfo' files. * tests/clock.test (clock-56.3): Added a test case for Y2038 and 'zoneinfo'.
Diffstat (limited to 'library')
-rw-r--r--library/clock.tcl26
1 files changed, 21 insertions, 5 deletions
diff --git a/library/clock.tcl b/library/clock.tcl
index 1a7c079..da4309c 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.39 2007/03/08 02:53:23 kennykb Exp $
+# RCS: @(#) $Id: clock.tcl,v 1.40 2007/03/09 01:09:00 kennykb Exp $
#
#----------------------------------------------------------------------
@@ -3635,7 +3635,6 @@ proc ReadZoneinfoFile {fileName fname} {
incr i [expr { [string length $a] + 1 }]
}
- # The rest of the data in the file are not used at present.
# Package up a list of tuples, each of which contains transition time,
# seconds east of Greenwich, DST flag and time zone abbreviation.
@@ -3651,10 +3650,27 @@ proc ReadZoneinfoFile {fileName fname} {
lappend r [list $t $gmtoff $isDst $abbrev]
}
- set TZData(:$fileName) $r
+ # In a version 2 file, there is also a POSIX-style time zone description
+ # at the very end of the file. To get to it, skip over
+ # nLeap leap second values (8 bytes each),
+ # nIsStd standard/DST indicators and nIsGMT UTC/local indicators.
+
+ if {$version eq {2}} {
+ set seek [expr {$seek + 8 * $nLeap + $nIsStd + $nIsGMT + 1}]
+ set last [string first \n $d $seek]
+ set posix [string range $d $seek [expr {$last-1}]]
+ if {[llength $posix] > 0} {
+ set posixFields [ParsePosixTimeZone $posix]
+ foreach tuple [ProcessPosixTimeZone $posixFields] {
+ foreach {t gmtoff isDst abbrev} $tuple break
+ if {$t > $lastTime} {
+ lappend r $tuple
+ }
+ }
+ }
+ }
- # TODO - The end of a version 2 zoneinfo file has a Posiz TZ spec
- # that can be used to fill out the rules past the End of Time.
+ set TZData(:$fileName) $r
return
}