summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornijtmans <nijtmans>2008-12-11 14:01:59 (GMT)
committernijtmans <nijtmans>2008-12-11 14:01:59 (GMT)
commit07779703b451dce687221a6608d0bef01e3afde0 (patch)
treec39135221c14bcfff0a9ee97f413753bfe0fd15e
parentb008803bf2feb7fa0c43d9890e57d94007b5f304 (diff)
downloadtcl-07779703b451dce687221a6608d0bef01e3afde0.zip
tcl-07779703b451dce687221a6608d0bef01e3afde0.tar.gz
tcl-07779703b451dce687221a6608d0bef01e3afde0.tar.bz2
Fallback to European time zone DST rules, when the timezone is
between 0 and -12 [Bug 2207436].
-rw-r--r--ChangeLog7
-rw-r--r--library/clock.tcl33
-rw-r--r--tests/clock.test24
3 files changed, 56 insertions, 8 deletions
diff --git a/ChangeLog b/ChangeLog
index dd16b6e..dd1c8e2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2008-12-11 Jan Nijtmans <nijtmans@users.sf.net>
+
+ * library/clock.tcl (ProcessPosixTimeZone): Fallback to
+ European time zone DST rules, when the timezone is
+ between 0 and -12 [Bug 2207436].
+ * tests/clock.test (clock-64.[12]): Test cases for [Bug 2207436]
+
2008-12-11 Donal K. Fellows <dkf@users.sf.net>
TIP #234 IMPLEMENTATION
diff --git a/library/clock.tcl b/library/clock.tcl
index e4a21e3..bfac4e6 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.49 2008/11/30 19:24:00 kennykb Exp $
+# RCS: @(#) $Id: clock.tcl,v 1.50 2008/12/11 14:01:59 nijtmans Exp $
#
#----------------------------------------------------------------------
@@ -3885,23 +3885,42 @@ proc ::tcl::clock::ProcessPosixTimeZone { z } {
* $dstSignum }]
}
- # Fill in defaults for US DST rules
+ # Fill in defaults for European or US DST rules
if { [dict get $z startDayOfYear] eq {}
&& [dict get $z startMonth] eq {} } {
+ if {($stdHours>=0) && ($stdHours<=12)} {
+ dict set z startWeekOfMonth 5
+ if {$stdHours>1} {
+ dict set z startHours 2
+ } else {
+ dict set z startHours [expr {$stdHours+1}]
+ }
+ } else {
+ dict set z startWeekOfMonth 2
+ dict set z startHours 2
+ }
dict set z startMonth 3
- dict set z startWeekOfMonth 2
dict set z startDayOfWeek 0
- dict set z startHours 2
dict set z startMinutes 0
dict set z startSeconds 0
}
if { [dict get $z endDayOfYear] eq {}
&& [dict get $z endMonth] eq {} } {
- dict set z endMonth 11
- dict set z endWeekOfMonth 1
+ if {($stdHours>=0) && ($stdHours<=12)} {
+ dict set z endMonth 10
+ dict set z endWeekOfMonth 5
+ if {$stdHours>1} {
+ dict set z endHours 3
+ } else {
+ dict set z endHours [expr {$stdHours+2}]
+ }
+ } else {
+ dict set z endMonth 11
+ dict set z endWeekOfMonth 1
+ dict set z endHours 2
+ }
dict set z endDayOfWeek 0
- dict set z endHours 2
dict set z endMinutes 0
dict set z endSeconds 0
}
diff --git a/tests/clock.test b/tests/clock.test
index 6f2afdd..b1fcfb6 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.87 2008/11/30 19:24:00 kennykb Exp $
+# RCS: @(#) $Id: clock.test,v 1.88 2008/12/11 14:01:59 nijtmans Exp $
if {[lsearch [namespace children] ::tcltest] == -1} {
package require tcltest 2
@@ -36083,6 +36083,28 @@ test clock-52.1 {Posix timezone and conversion on last Sunday} {
set result
} {01:59:59 01:59:59 03:00:00 03:00:00}
+test clock-52.2 {correct conversion of times in Europe} {
+ # [Bug 2207436]
+ set result {}
+ foreach t [list 1206838799 1206838800 1224982799 1224982800] {
+ lappend result [clock format $t -format %H:%M:%S \
+ -timezone MET-1METDST]
+ lappend result [clock format $t -format %H:%M:%S \
+ -timezone MET0METDST]
+ }
+ set result
+} {01:59:59 00:59:59 03:00:00 02:00:00 02:59:59 01:59:59 02:00:00 01:00:00}
+
+test clock-52.3 {correct conversion of times in Russia} {
+ # [Bug 2207436]
+ set result {}
+ foreach t [list 1206799199 1206799200 1224943199 1224943200] {
+ lappend result [clock format $t -format %H:%M:%S \
+ -timezone WST-12WSTDST]
+ }
+ set result
+} {01:59:59 03:00:00 02:59:59 02:00:00}
+
# Regression test for Bug # 1505383
test clock-53.1 {%EC %Ey} {