summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog14
-rw-r--r--library/clock.tcl12
-rw-r--r--tests/clock.test24
3 files changed, 38 insertions, 12 deletions
diff --git a/ChangeLog b/ChangeLog
index 46c7cd8..851ea03 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2004-11-03 Kevin B. Kenny <kennykb@acm.org>
+
+ * library/clock.tcl (FreeScan): Fixed a bug where scanning
+ "Monday" with a base time other than midnight incorrectly carried
+ the base time forward.
+
+ * test/clock.test (clock-33.{5,5a}): Made the test failure more
+ informative.
+
+ * tests/clock.test (clock-34.{28,44,45,46}): Removed 'knownBug'
+ constraints from tests that no longer fail.
+
+ Thanks to Don Porter for reporting these.
+
2004-11-03 David Gravereaux <davygrvy@pobox.com>
* generic/tcl.h: Moved the preprocessor logic
diff --git a/library/clock.tcl b/library/clock.tcl
index 0f91cca..d65723b 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.10 2004/10/26 02:08:38 kennykb Exp $
+# RCS: @(#) $Id: clock.tcl,v 1.11 2004/11/03 23:00:22 kennykb Exp $
#
#----------------------------------------------------------------------
@@ -1275,7 +1275,14 @@ proc ::tcl::clock::FreeScan { string base timezone locale } {
set date [GetJulianDayFromEraYearMonthDay $date[set date {}]]
if { $parseTime ne {} } {
dict set date secondOfDay $parseTime
+ } elseif { [llength $parseWeekday] != 0
+ || [llength $parseOrdinalMonth] != 0
+ || ( [llength $parseRel] != 0
+ && ( [lindex $parseRel 0] != 0
+ || [lindex $parseRel 1] != 0 ) ) } {
+ dict set date secondOfDay 0
}
+
dict set date localSeconds \
[expr { -210866803200
+ ( 86400 * wide([dict get $date julianDay]) )
@@ -1284,7 +1291,6 @@ proc ::tcl::clock::FreeScan { string base timezone locale } {
set date [ConvertLocalToUTC $date[set date {}]]
set seconds [dict get $date seconds]
-
# Do relative times
if { [llength $parseRel] > 0 } {
@@ -1292,7 +1298,7 @@ proc ::tcl::clock::FreeScan { string base timezone locale } {
set seconds [add $seconds \
$relMonth months $relDay days $relSecond seconds \
-timezone $timezone -locale $locale]
- }
+ }
# Do relative weekday
diff --git a/tests/clock.test b/tests/clock.test
index 20fec79..9b29a73 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.50 2004/10/29 15:39:07 dkf Exp $
+# RCS: @(#) $Id: clock.test,v 1.51 2004/11/03 23:00:23 kennykb Exp $
if {[lsearch [namespace children] ::tcltest] == -1} {
package require tcltest 2
@@ -34894,15 +34894,21 @@ test clock-33.5 {clock clicks tests, millisecond timing test} {
after 10
set end [clock clicks -milli]
# 60 msecs seems to be the max time slice under Windows 95/98
- expr {($end > $start) && (($end - $start) <= 60)}
-} {1}
+ expr {
+ ($end > $start) && (($end - $start) <= 60) ?
+ "ok" :
+ "test should have taken 0-60 ms, actually took [expr $end - $start]"}
+} {ok}
test clock-33.5a {clock tests, millisecond timing test} {
set start [clock milliseconds]
after 10
set end [clock milliseconds]
# 60 msecs seems to be the max time slice under Windows 95/98
- expr {($end > $start) && (($end - $start) <= 60)}
-} {1}
+ expr {
+ ($end > $start) && (($end - $start) <= 60) ?
+ "ok" :
+ "test should have taken 0-60 ms, actually took [expr $end - $start]"}
+} {ok}
test clock-33.6 {clock clicks, milli with too much abbreviation} {
list [catch { clock clicks {} } msg] $msg
} {1 {bad option "": must be -milliseconds or -microseconds}}
@@ -35106,7 +35112,7 @@ test clock-34.26 {clock scan, DST for days} {
test clock-34.27 {clock scan, DST for days} {
clock scan "yesterday" -base [clock scan "19991101 00:00:00"]
} [clock scan "19991031 00:00:00"]
-test clock-34.28 {clock scan, day} knownBug {
+test clock-34.28 {clock scan, day} {
clock format [clock scan "Monday" -gmt true -base 946627200] \
-format {%b %d, %Y %H:%M:%S} -gmt true
} "Jan 03, 2000 00:00:00"
@@ -35183,7 +35189,7 @@ test clock-34.43 {last monday in november} {
set res
} {1991-11-25 1992-11-30 1993-11-29 1994-11-28 1995-11-27 1996-11-25}
-test clock-34.44 {2nd monday in november} knownBug {
+test clock-34.44 {2nd monday in november} {
set res {}
foreach i {91 92 93 94 95 96} {
set nov8th [clock scan 11/8/$i -gmt 1]
@@ -35192,7 +35198,7 @@ test clock-34.44 {2nd monday in november} knownBug {
}
set res
} {1991-11-11 1992-11-09 1993-11-08 1994-11-14 1995-11-13 1996-11-11}
-test clock-34.45 {2nd monday in november (2nd try)} knownBug {
+test clock-34.45 {2nd monday in november (2nd try)} {
set res {}
foreach i {91 92 93 94 95 96} {
set nov1th [clock scan 11/1/$i -gmt 1]
@@ -35201,7 +35207,7 @@ test clock-34.45 {2nd monday in november (2nd try)} knownBug {
}
set res
} {1991-11-11 1992-11-09 1993-11-08 1994-11-14 1995-11-13 1996-11-11}
-test clock-34.46 {last monday in november} knownBug {
+test clock-34.46 {last monday in november} {
set res {}
foreach i {91 92 93 94 95 96} {
set dec1th [clock scan 12/1/$i -gmt 1]