summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhobbs <hobbs>2001-10-18 20:17:17 (GMT)
committerhobbs <hobbs>2001-10-18 20:17:17 (GMT)
commit8cb0f2416f83a98f74072ea81d165995b490883d (patch)
tree9cc736e98e8d87d5dd45ae35f9e26d558ff2206c
parent39d061fecc95e857aeb6cb1c3e2a3ed9e2eed92a (diff)
downloadtcl-8cb0f2416f83a98f74072ea81d165995b490883d.zip
tcl-8cb0f2416f83a98f74072ea81d165995b490883d.tar.gz
tcl-8cb0f2416f83a98f74072ea81d165995b490883d.tar.bz2
* tests/clock.test (clock-8.1):
* generic/tclDate.c (RelativeMonth): * generic/tclGetDate.y (RelativeMonth): corrected off-by-one-day error in clock scan with relative months and years during swing hours. [Bug #413397, Patch #414024] (lavana)
-rw-r--r--ChangeLog31
-rw-r--r--generic/tclDate.c19
-rw-r--r--generic/tclGetDate.y19
-rw-r--r--tests/clock.test17
4 files changed, 70 insertions, 16 deletions
diff --git a/ChangeLog b/ChangeLog
index c3fe032..f97e933 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2001-10-18 Jeff Hobbs <jeffh@ActiveState.com>
+
+ * tests/clock.test (clock-8.1):
+ * generic/tclDate.c (RelativeMonth):
+ * generic/tclGetDate.y (RelativeMonth): corrected off-by-one-day
+ error in clock scan with relative months and years during swing
+ hours. [Bug #413397, Patch #414024] (lavana)
+
2001-10-17 Jeff Hobbs <jeffh@ActiveState.com>
* unix/tclUnixPipe.c (PipeInputProc, PipeOutputProc): do immediate
@@ -547,23 +555,26 @@
* generic/tclPlatDecls.h:
* generic/tclStubInit.c: regen'd tables.
- * generic/tclAsync.c: Brought source to match -r1.6 on the HEAD branch.
+ * generic/tclAsync.c: Brought source to match -r1.6 on the HEAD
+ branch.
* generic/tclEvent.c:
- * generic/tclInt.h: Added prototype to and use of new TclFinalizeAsync()
- found in tclAsync.c.
+ * generic/tclInt.h: Added prototype to and use of new
+ TclFinalizeAsync() found in tclAsync.c.
* unix/tclUnixPort.h:
* mac/tclMacPort.h: removed #defines for TclpAsyncMark.
- * win/tclWinInit.c: Removed the TclpAsyncMark function and the thread ID
- saving that was going on in TclpInitPlatform(). [the old hack]
+ * win/tclWinInit.c: Removed the TclpAsyncMark function and the
+ thread ID saving that was going on in TclpInitPlatform(). [the old
+ hack]
- * win/tclWinThread.c: TclpFinalizeCondition() and TclpFinalizeMutex()
- are now properly returning the old CriticalSection handle to the system.
- Tcl_CreateThread() is now decrementing its handle reference, so the
- system will recover resources when the thread closes (doh!). These
- changes are all already up on the HEAD.
+ * win/tclWinThread.c: TclpFinalizeCondition() and
+ TclpFinalizeMutex() are now properly returning the old
+ CriticalSection handle to the system. Tcl_CreateThread() is now
+ decrementing its handle reference, so the system will recover
+ resources when the thread closes (doh!). These changes are all
+ already up on the HEAD.
* doc/Async.3: matches HEAD.
diff --git a/generic/tclDate.c b/generic/tclDate.c
index 979609c..28ae9f2 100644
--- a/generic/tclDate.c
+++ b/generic/tclDate.c
@@ -10,7 +10,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclDate.c,v 1.17.2.2 2001/10/17 19:29:25 das Exp $
+ * RCS: @(#) $Id: tclDate.c,v 1.17.2.3 2001/10/18 20:17:17 hobbs Exp $
*/
#include "tclInt.h"
@@ -579,6 +579,23 @@ RelativeMonth(Start, RelMonth, TimePtr)
result = Convert(Month, (time_t) tm->tm_mday, Year,
(time_t) tm->tm_hour, (time_t) tm->tm_min, (time_t) tm->tm_sec,
MER24, DSTmaybe, &Julian);
+
+ /*
+ * The Julian time returned above is behind by one day, if "month"
+ * or "year" is used to specify relative time and the GMT flag is true.
+ * This problem occurs only when the current time is closer to
+ * midnight, the difference being not more than its time difference
+ * with GMT. For example, in US/Pacific time zone, the problem occurs
+ * whenever the current time is between midnight to 8:00am or 7:00amDST.
+ * See Bug# 413397 for more details and sample script.
+ * To resolve this bug, we simply add the number of seconds corresponding
+ * to timezone difference with GMT to Julian time, if GMT flag is true.
+ */
+
+ if (TclDateTimezone == 0) {
+ Julian += TclpGetTimeZone((unsigned long) Start) * 60L;
+ }
+
/*
* The following iteration takes into account the case were we jump
* into a "short month". Far example, "one month from Jan 31" will
diff --git a/generic/tclGetDate.y b/generic/tclGetDate.y
index 1b110b9..aa616c4 100644
--- a/generic/tclGetDate.y
+++ b/generic/tclGetDate.y
@@ -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: tclGetDate.y,v 1.15.2.2 2001/10/17 19:29:25 das Exp $
+ * RCS: @(#) $Id: tclGetDate.y,v 1.15.2.3 2001/10/18 20:17:17 hobbs Exp $
*/
%{
@@ -798,6 +798,23 @@ RelativeMonth(Start, RelMonth, TimePtr)
result = Convert(Month, (time_t) tm->tm_mday, Year,
(time_t) tm->tm_hour, (time_t) tm->tm_min, (time_t) tm->tm_sec,
MER24, DSTmaybe, &Julian);
+
+ /*
+ * The Julian time returned above is behind by one day, if "month"
+ * or "year" is used to specify relative time and the GMT flag is true.
+ * This problem occurs only when the current time is closer to
+ * midnight, the difference being not more than its time difference
+ * with GMT. For example, in US/Pacific time zone, the problem occurs
+ * whenever the current time is between midnight to 8:00am or 7:00amDST.
+ * See Bug# 413397 for more details and sample script.
+ * To resolve this bug, we simply add the number of seconds corresponding
+ * to timezone difference with GMT to Julian time, if GMT flag is true.
+ */
+
+ if (TclDateTimezone == 0) {
+ Julian += TclpGetTimeZone((unsigned long) Start) * 60L;
+ }
+
/*
* The following iteration takes into account the case were we jump
* into a "short month". Far example, "one month from Jan 31" will
diff --git a/tests/clock.test b/tests/clock.test
index aa84f6d..9400b34 100644
--- a/tests/clock.test
+++ b/tests/clock.test
@@ -10,7 +10,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.13.2.2 2001/04/03 22:54:38 hobbs Exp $
+# RCS: @(#) $Id: clock.test,v 1.13.2.3 2001/10/18 20:17:17 hobbs Exp $
if {[lsearch [namespace children] ::tcltest] == -1} {
package require tcltest
@@ -46,8 +46,8 @@ test clock-2.5 {clock clicks tests, millisecond timing test} {
set start [clock clicks -milli]
after 10
set end [clock clicks -milli]
- # assume, even with slow interp'ing, the diff is less than 60 msecs
- expr {($end > $start) && (($end - $start) < 60)}
+ # 60 msecs seems to be the max time slice under Windows 95/98
+ expr {($end > $start) && (($end - $start) <= 60)}
} {1}
# clock format
@@ -418,7 +418,16 @@ test clock-7.3 {clock scan next monthname} {
-format %m.%Y
} "05.2001"
+# We use 5am PST, 31-12-1999 as the base for these scans because irrespective
+# of your local timezone it should always give us times on December 31
+set 5amPST 946645200
+test clock-8.1 {clock scan midnight/gmt range bug 413397} {
+ set fmt "%m/%d"
+ list [clock format [clock scan year -base $5amPST -gmt 0] -format $fmt] \
+ [clock format [clock scan year -base $5amPST -gmt 1] -format $fmt]
+} {12/31 12/31}
+
+
# cleanup
::tcltest::cleanupTests
return
-