summaryrefslogtreecommitdiffstats
path: root/library
diff options
context:
space:
mode:
authorKevin B Kenny <kennykb@acm.org>2004-11-30 15:45:03 (GMT)
committerKevin B Kenny <kennykb@acm.org>2004-11-30 15:45:03 (GMT)
commit144b1b16e962181661e12d2c592f37b17e22278b (patch)
tree7bef60e9f5d590153c01c127558289e10061606f /library
parentce4338e6397022547fddacab80018e21ae5773ef (diff)
downloadtcl-144b1b16e962181661e12d2c592f37b17e22278b.zip
tcl-144b1b16e962181661e12d2c592f37b17e22278b.tar.gz
tcl-144b1b16e962181661e12d2c592f37b17e22278b.tar.bz2
* library/clock.tcl: Corrected the regular expressions that match
a time zone to allow for time zones specified as +HH or -HH. * tests/clock.test: Added regression test case for the above issue.
Diffstat (limited to 'library')
-rw-r--r--library/clock.tcl16
1 files changed, 9 insertions, 7 deletions
diff --git a/library/clock.tcl b/library/clock.tcl
index d65723b..0a872ba 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.11 2004/11/03 23:00:22 kennykb Exp $
+# RCS: @(#) $Id: clock.tcl,v 1.12 2004/11/30 15:45:04 kennykb Exp $
#
#----------------------------------------------------------------------
@@ -1668,7 +1668,7 @@ proc ::tcl::clock::ParseClockScanFormat { formatString } {
"\]\n"
}
z - Z { # Time zone name
- append re {(?:([-+]\d\d:?\d\d(?::?\d\d)?)|([[:alnum:]]{1,4}))}
+ append re {(?:([-+]\d\d(?::?\d\d(?::?\d\d)?)?)|([[:alnum:]]{1,4}))}
dict set fieldSet tzName [incr fieldCount]
append postcode \
{if } \{ { $field} [incr captureCount] \
@@ -3237,21 +3237,23 @@ proc ::tcl::clock::SetupTimeZone { timezone } {
# Nothing to do, we'll convert using the localtime function
- } elseif { [regexp {^([-+])(\d\d):?(\d\d)(?::?(\d\d))?} $timezone \
+ } elseif { [regexp {^([-+])(\d\d)(?::?(\d\d)(?::?(\d\d))?)?} $timezone \
-> s hh mm ss] } {
# Make a fixed offset
::scan $hh %d hh
- ::scan $mm %d mm
+ if { $mm eq {} } {
+ set mm 0
+ } else {
+ ::scan $mm %d mm
+ }
if { $ss eq {} } {
set ss 0
} else {
::scan $ss %d ss
}
- set offset [expr { ( $hh * 60
- + $mm ) * 60
- + $ss }]
+ set offset [expr { ( $hh * 60 + $mm ) * 60 + $ss }]
if { $s eq {-} } {
set offset [expr { - $offset }]
}