diff options
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | library/clock.tcl | 16 | ||||
-rw-r--r-- | tests/clock.test | 8 |
3 files changed, 22 insertions, 9 deletions
@@ -1,3 +1,10 @@ +2004-11-30 Kevin B. Kenny <kennykb@acm.org> + + * 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. + Thanks to Rolf Ade for reporting this issue [http://wiki.tcl.tk/13094] + 2004-11-29 Andreas Kupries <andreask@activestate.com> * win/Makefile.in (install-libraries): Brought entry '2004-10-26 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 }] } diff --git a/tests/clock.test b/tests/clock.test index 9b29a73..b5c19fb 100644 --- a/tests/clock.test +++ b/tests/clock.test @@ -11,7 +11,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.test,v 1.51 2004/11/03 23:00:23 kennykb Exp $ +# RCS: @(#) $Id: clock.test,v 1.52 2004/11/30 15:45:04 kennykb Exp $ if {[lsearch [namespace children] ::tcltest] == -1} { package require tcltest 2 @@ -35369,7 +35369,11 @@ test clock-44.1 {regression test - time zone name containing hyphen } \ } \ -result {12:34:56-0500} - +test clock-45.1 {regression test - time zone containing only two digits} \ + -body { + clock scan 1985-04-12T10:15:30+04 -format %Y-%m-%dT%H:%M:%S%Z + } \ + -result 482134530 # cleanup |