From 2a552ac984e719a90dd9e9b554e2c3eb929359f9 Mon Sep 17 00:00:00 2001
From: Kevin B Kenny <kennykb@acm.org>
Date: Sat, 24 Oct 2009 22:20:10 +0000
Subject: 	* library/clock.tcl (ProcessPosixTimeZone): 	Corrected a
 regression in the fix to [Bug 2207436] that caused 	[clock] to apply EU
 daylight saving time rules in the US. 	Thanks to Karl Lehenbauer for
 reporting this regression. 	* tests/clock.test (clock-52.4): 	Added
 a regression test for the above bug. 	* library/tzdata/Asia/Dhaka: 	*
 library/tzdata/Asia/Karachi: 	New DST rules for Bangladesh and Pakistan.
 (Olson's tzdata2009o.)

---
 ChangeLog                   |  12 +++
 library/clock.tcl           |  14 +++-
 library/tzdata/Asia/Dhaka   |   1 -
 library/tzdata/Asia/Karachi | 182 +++++++++++++++++++++++++++++++++++++++++++-
 tests/clock.test            |  12 ++-
 5 files changed, 215 insertions(+), 6 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 47f0a53..23eaa35 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2009-10-24  Kevin B. Kenny  <kennykb@acm.org>
+
+	* library/clock.tcl (ProcessPosixTimeZone): 
+	Corrected a regression in the fix to [Bug 2207436] that caused
+	[clock] to apply EU daylight saving time rules in the US.
+	Thanks to Karl Lehenbauer for reporting this regression.
+	* tests/clock.test (clock-52.4):
+	Added a regression test for the above bug.
+	* library/tzdata/Asia/Dhaka:
+	* library/tzdata/Asia/Karachi:
+	New DST rules for Bangladesh and Pakistan. (Olson's tzdata2009o.)
+	
 2009-10-23  Andreas Kupries  <andreask@activestate.com>
 
 	* generic/tclIO.c (FlushChannel): Skip OutputProc for low-level
diff --git a/library/clock.tcl b/library/clock.tcl
index 36e3a4e..bc4ec4d 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.54 2009/07/24 10:53:47 dkf Exp $
+# RCS: @(#) $Id: clock.tcl,v 1.55 2009/10/24 22:20:10 kennykb Exp $
 #
 #----------------------------------------------------------------------
 
@@ -3789,11 +3789,16 @@ proc ::tcl::clock::ProcessPosixTimeZone { z } {
     }
 
     # Fill in defaults for European or US DST rules
+    # US start time is the second Sunday in March
+    # EU start time is the last Sunday in March
+    # US end time is the first Sunday in November.
+    # EU end time is the last Sunday in October
 
     if {
 	[dict get $z startDayOfYear] eq {} && [dict get $z startMonth] eq {}
     } then {
-	if {($stdHours>=0) && ($stdHours<=12)} {
+	if {($stdSignum * $stdHours>=0) && ($stdSignum * $stdHours<=12)} {
+	    # EU
 	    dict set z startWeekOfMonth 5
 	    if {$stdHours>2} {
 		dict set z startHours 2
@@ -3801,6 +3806,7 @@ proc ::tcl::clock::ProcessPosixTimeZone { z } {
 		dict set z startHours [expr {$stdHours+1}]
 	    }
 	} else {
+	    # US
 	    dict set z startWeekOfMonth 2
 	    dict set z startHours 2
 	}
@@ -3812,7 +3818,8 @@ proc ::tcl::clock::ProcessPosixTimeZone { z } {
     if {
 	[dict get $z endDayOfYear] eq {} && [dict get $z endMonth] eq {}
     } then {
-	if {($stdHours>=0) && ($stdHours<=12)} {
+	if {($stdSignum * $stdHours>=0) && ($stdSignum * $stdHours<=12)} {
+	    # EU
 	    dict set z endMonth 10
 	    dict set z endWeekOfMonth 5
 	    if {$stdHours>2} {
@@ -3821,6 +3828,7 @@ proc ::tcl::clock::ProcessPosixTimeZone { z } {
 		dict set z endHours [expr {$stdHours+2}]
 	    }
 	} else {
+	    # US
 	    dict set z endMonth 11
 	    dict set z endWeekOfMonth 1
 	    dict set z endHours 2
diff --git a/library/tzdata/Asia/Dhaka b/library/tzdata/Asia/Dhaka
index 70fc865..7ce68ce 100644
--- a/library/tzdata/Asia/Dhaka
+++ b/library/tzdata/Asia/Dhaka
@@ -9,5 +9,4 @@ set TZData(:Asia/Dhaka) {
     {-576138600 21600 0 DACT}
     {38772000 21600 0 BDT}
     {1245430800 25200 1 BDST}
-    {1262278800 21600 0 BDT}
 }
diff --git a/library/tzdata/Asia/Karachi b/library/tzdata/Asia/Karachi
index 6535471..acd69f4 100644
--- a/library/tzdata/Asia/Karachi
+++ b/library/tzdata/Asia/Karachi
@@ -12,5 +12,185 @@ set TZData(:Asia/Karachi) {
     {1212260400 21600 1 PKST}
     {1225476000 18000 0 PKT}
     {1239735600 21600 1 PKST}
-    {1254333600 18000 0 PKT}
+    {1257012000 18000 0 PKT}
+    {1271271600 21600 1 PKST}
+    {1288548000 18000 0 PKT}
+    {1302807600 21600 1 PKST}
+    {1320084000 18000 0 PKT}
+    {1334430000 21600 1 PKST}
+    {1351706400 18000 0 PKT}
+    {1365966000 21600 1 PKST}
+    {1383242400 18000 0 PKT}
+    {1397502000 21600 1 PKST}
+    {1414778400 18000 0 PKT}
+    {1429038000 21600 1 PKST}
+    {1446314400 18000 0 PKT}
+    {1460660400 21600 1 PKST}
+    {1477936800 18000 0 PKT}
+    {1492196400 21600 1 PKST}
+    {1509472800 18000 0 PKT}
+    {1523732400 21600 1 PKST}
+    {1541008800 18000 0 PKT}
+    {1555268400 21600 1 PKST}
+    {1572544800 18000 0 PKT}
+    {1586890800 21600 1 PKST}
+    {1604167200 18000 0 PKT}
+    {1618426800 21600 1 PKST}
+    {1635703200 18000 0 PKT}
+    {1649962800 21600 1 PKST}
+    {1667239200 18000 0 PKT}
+    {1681498800 21600 1 PKST}
+    {1698775200 18000 0 PKT}
+    {1713121200 21600 1 PKST}
+    {1730397600 18000 0 PKT}
+    {1744657200 21600 1 PKST}
+    {1761933600 18000 0 PKT}
+    {1776193200 21600 1 PKST}
+    {1793469600 18000 0 PKT}
+    {1807729200 21600 1 PKST}
+    {1825005600 18000 0 PKT}
+    {1839351600 21600 1 PKST}
+    {1856628000 18000 0 PKT}
+    {1870887600 21600 1 PKST}
+    {1888164000 18000 0 PKT}
+    {1902423600 21600 1 PKST}
+    {1919700000 18000 0 PKT}
+    {1933959600 21600 1 PKST}
+    {1951236000 18000 0 PKT}
+    {1965582000 21600 1 PKST}
+    {1982858400 18000 0 PKT}
+    {1997118000 21600 1 PKST}
+    {2014394400 18000 0 PKT}
+    {2028654000 21600 1 PKST}
+    {2045930400 18000 0 PKT}
+    {2060190000 21600 1 PKST}
+    {2077466400 18000 0 PKT}
+    {2091812400 21600 1 PKST}
+    {2109088800 18000 0 PKT}
+    {2123348400 21600 1 PKST}
+    {2140624800 18000 0 PKT}
+    {2154884400 21600 1 PKST}
+    {2172160800 18000 0 PKT}
+    {2186420400 21600 1 PKST}
+    {2203696800 18000 0 PKT}
+    {2218042800 21600 1 PKST}
+    {2235319200 18000 0 PKT}
+    {2249578800 21600 1 PKST}
+    {2266855200 18000 0 PKT}
+    {2281114800 21600 1 PKST}
+    {2298391200 18000 0 PKT}
+    {2312650800 21600 1 PKST}
+    {2329927200 18000 0 PKT}
+    {2344273200 21600 1 PKST}
+    {2361549600 18000 0 PKT}
+    {2375809200 21600 1 PKST}
+    {2393085600 18000 0 PKT}
+    {2407345200 21600 1 PKST}
+    {2424621600 18000 0 PKT}
+    {2438881200 21600 1 PKST}
+    {2456157600 18000 0 PKT}
+    {2470503600 21600 1 PKST}
+    {2487780000 18000 0 PKT}
+    {2502039600 21600 1 PKST}
+    {2519316000 18000 0 PKT}
+    {2533575600 21600 1 PKST}
+    {2550852000 18000 0 PKT}
+    {2565111600 21600 1 PKST}
+    {2582388000 18000 0 PKT}
+    {2596734000 21600 1 PKST}
+    {2614010400 18000 0 PKT}
+    {2628270000 21600 1 PKST}
+    {2645546400 18000 0 PKT}
+    {2659806000 21600 1 PKST}
+    {2677082400 18000 0 PKT}
+    {2691342000 21600 1 PKST}
+    {2708618400 18000 0 PKT}
+    {2722964400 21600 1 PKST}
+    {2740240800 18000 0 PKT}
+    {2754500400 21600 1 PKST}
+    {2771776800 18000 0 PKT}
+    {2786036400 21600 1 PKST}
+    {2803312800 18000 0 PKT}
+    {2817572400 21600 1 PKST}
+    {2834848800 18000 0 PKT}
+    {2849194800 21600 1 PKST}
+    {2866471200 18000 0 PKT}
+    {2880730800 21600 1 PKST}
+    {2898007200 18000 0 PKT}
+    {2912266800 21600 1 PKST}
+    {2929543200 18000 0 PKT}
+    {2943802800 21600 1 PKST}
+    {2961079200 18000 0 PKT}
+    {2975425200 21600 1 PKST}
+    {2992701600 18000 0 PKT}
+    {3006961200 21600 1 PKST}
+    {3024237600 18000 0 PKT}
+    {3038497200 21600 1 PKST}
+    {3055773600 18000 0 PKT}
+    {3070033200 21600 1 PKST}
+    {3087309600 18000 0 PKT}
+    {3101655600 21600 1 PKST}
+    {3118932000 18000 0 PKT}
+    {3133191600 21600 1 PKST}
+    {3150468000 18000 0 PKT}
+    {3164727600 21600 1 PKST}
+    {3182004000 18000 0 PKT}
+    {3196263600 21600 1 PKST}
+    {3213540000 18000 0 PKT}
+    {3227886000 21600 1 PKST}
+    {3245162400 18000 0 PKT}
+    {3259422000 21600 1 PKST}
+    {3276698400 18000 0 PKT}
+    {3290958000 21600 1 PKST}
+    {3308234400 18000 0 PKT}
+    {3322494000 21600 1 PKST}
+    {3339770400 18000 0 PKT}
+    {3354116400 21600 1 PKST}
+    {3371392800 18000 0 PKT}
+    {3385652400 21600 1 PKST}
+    {3402928800 18000 0 PKT}
+    {3417188400 21600 1 PKST}
+    {3434464800 18000 0 PKT}
+    {3448724400 21600 1 PKST}
+    {3466000800 18000 0 PKT}
+    {3480346800 21600 1 PKST}
+    {3497623200 18000 0 PKT}
+    {3511882800 21600 1 PKST}
+    {3529159200 18000 0 PKT}
+    {3543418800 21600 1 PKST}
+    {3560695200 18000 0 PKT}
+    {3574954800 21600 1 PKST}
+    {3592231200 18000 0 PKT}
+    {3606577200 21600 1 PKST}
+    {3623853600 18000 0 PKT}
+    {3638113200 21600 1 PKST}
+    {3655389600 18000 0 PKT}
+    {3669649200 21600 1 PKST}
+    {3686925600 18000 0 PKT}
+    {3701185200 21600 1 PKST}
+    {3718461600 18000 0 PKT}
+    {3732807600 21600 1 PKST}
+    {3750084000 18000 0 PKT}
+    {3764343600 21600 1 PKST}
+    {3781620000 18000 0 PKT}
+    {3795879600 21600 1 PKST}
+    {3813156000 18000 0 PKT}
+    {3827415600 21600 1 PKST}
+    {3844692000 18000 0 PKT}
+    {3859038000 21600 1 PKST}
+    {3876314400 18000 0 PKT}
+    {3890574000 21600 1 PKST}
+    {3907850400 18000 0 PKT}
+    {3922110000 21600 1 PKST}
+    {3939386400 18000 0 PKT}
+    {3953646000 21600 1 PKST}
+    {3970922400 18000 0 PKT}
+    {3985268400 21600 1 PKST}
+    {4002544800 18000 0 PKT}
+    {4016804400 21600 1 PKST}
+    {4034080800 18000 0 PKT}
+    {4048340400 21600 1 PKST}
+    {4065616800 18000 0 PKT}
+    {4079876400 21600 1 PKST}
+    {4097152800 18000 0 PKT}
 }
diff --git a/tests/clock.test b/tests/clock.test
index 0f1e9da..39f9142 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.91 2009/06/09 13:52:38 kennykb Exp $
+# RCS: @(#) $Id: clock.test,v 1.92 2009/10/24 22:20:10 kennykb Exp $
 
 if {[lsearch [namespace children] ::tcltest] == -1} {
     package require tcltest 2
@@ -36140,6 +36140,16 @@ test clock-52.3 {correct conversion of times in Russia} {
    set result
 } {01:59:59 03:00:00 02:59:59 02:00:00}
 
+test clock-52.4 {correct conversion of times in USA} {
+   # [Bug 2207436]
+   set result {}
+   foreach t [list 1268549999 1268550000 1257055199 1257055200] {
+       lappend result [clock format $t -format %H:%M:%S \
+                           -timezone EST5EDT]
+   }
+   set result
+} {01:59:59 03:00:00 01:59:59 01:00:00}
+
 # Regression test for Bug # 1505383
 
 test clock-53.1 {%EC %Ey} {
-- 
cgit v0.12

