summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog9
-rw-r--r--library/clock.tcl32
-rw-r--r--tests/clock.test15
3 files changed, 44 insertions, 12 deletions
diff --git a/ChangeLog b/ChangeLog
index 5ae9e9d..686d717 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2009-10-27 Kevin B. Kenny <kennykb@acm.org>
+
+ * library/clock.tcl (ParseClockScanFormat):
+ Corrected a problem where [clock scan] didn't load the timezone
+ soon enough when processing a time format that lacked a complete
+ date. [Bug 2886852]
+ * tests/clock.test (clock-66.1):
+ Added a test case for the above bug.
+
2009-10-26 Don Porter <dgp@users.sourceforge.net>
* unix/Makefile.in: Remove $(PACKAGE).* and prototype from the
diff --git a/library/clock.tcl b/library/clock.tcl
index bc4ec4d..51118e1 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.55 2009/10/24 22:20:10 kennykb Exp $
+# RCS: @(#) $Id: clock.tcl,v 1.56 2009/10/27 03:23:32 kennykb Exp $
#
#----------------------------------------------------------------------
@@ -1955,6 +1955,21 @@ proc ::tcl::clock::ParseClockScanFormat {formatString locale} {
append procBody $postcode
append procBody [list set changeover [mc GREGORIAN_CHANGE_DATE]] \n
+ # Set up the time zone before doing anything with a default base date
+ # that might need a timezone to interpret it.
+
+ if { ![dict exists $fieldSet seconds]
+ && ![dict exists $fieldSet starDate] } {
+ if { [dict exists $fieldSet tzName] } {
+ append procBody {
+ set timeZone [dict get $date tzName]
+ }
+ }
+ append procBody {
+ ::tcl::clock::SetupTimeZone $timeZone
+ }
+ }
+
# Add code that gets Julian Day Number from the fields.
append procBody [MakeParseCodeFromFields $fieldSet $DateParseActions]
@@ -1963,7 +1978,9 @@ proc ::tcl::clock::ParseClockScanFormat {formatString locale} {
append procBody [MakeParseCodeFromFields $fieldSet $TimeParseActions]
- # Assemble seconds, and convert local nominal time to UTC.
+ # Assemble seconds from the Julian day and second of the day.
+ # Convert to local time unless epoch seconds or stardate are
+ # being processed - they're always absolute
if { ![dict exists $fieldSet seconds]
&& ![dict exists $fieldSet starDate] } {
@@ -1978,17 +1995,10 @@ proc ::tcl::clock::ParseClockScanFormat {formatString locale} {
+ [dict get $date secondOfDay]
}]
}
- }
- if { ![dict exists $fieldSet seconds]
- && ![dict exists $fieldSet starDate] } {
- if { [dict exists $fieldSet tzName] } {
- append procBody {
- set timeZone [dict get $date tzName]
- }
- }
+ # Finally, convert the date to local time
+
append procBody {
- ::tcl::clock::SetupTimeZone $timeZone
set date [::tcl::clock::ConvertLocalToUTC $date[set date {}] \
$TZData($timeZone) $changeover]
}
diff --git a/tests/clock.test b/tests/clock.test
index 39f9142..51d5655 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.92 2009/10/24 22:20:10 kennykb Exp $
+# RCS: @(#) $Id: clock.test,v 1.93 2009/10/27 03:23:32 kennykb Exp $
if {[lsearch [namespace children] ::tcltest] == -1} {
package require tcltest 2
@@ -36733,6 +36733,19 @@ test clock-65.1 {clock add, bad option [Bug 2481670]} {*}{
-result {bad switch "-foo"*}
}
+test clock-66.1 {clock scan, no date, never-before-seen timezone} {*}{
+ -setup {
+ ::tcl::clock::ClearCaches
+ }
+ -body {
+ clock scan 1200 \
+ -timezone {<EST>+05:00:00<EDT>+04:00:00,M3.2.0/02:00:00,M11.1.0/02:00:00} \
+ -base 1256529600 \
+ -format %H%M
+ }
+ -result 1256572800
+}
+
# cleanup
namespace delete ::testClock