summaryrefslogtreecommitdiffstats
path: root/tests/clock.test
diff options
context:
space:
mode:
Diffstat (limited to 'tests/clock.test')
-rw-r--r--tests/clock.test61
1 files changed, 59 insertions, 2 deletions
diff --git a/tests/clock.test b/tests/clock.test
index 53eb63d..a947a42 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.7 2000/01/12 23:35:52 ericm Exp $
+# RCS: @(#) $Id: clock.test,v 1.8 2000/01/13 00:12:33 ericm Exp $
if {[lsearch [namespace children] ::tcltest] == -1} {
package require tcltest
@@ -228,7 +228,7 @@ test clock-4.26 {clock scan, DST for days} {
} 941353200
test clock-4.27 {clock scan, day} knownBug {
clock format [clock scan "Monday" -gmt true -base 946627200] \
- -format {%b %d, %Y %H:%M:%S}
+ -format {%b %d, %Y %H:%M:%S} -gmt true
} "Jan 03, 2000 00:00:00"
test clock-4.28 {clock scan, number/number} {
clock format [clock scan "1/1" -gmt true -base 946627200] \
@@ -274,6 +274,63 @@ test clock-4.37 {clock scan, next day of week} {
-format {%b %d, %Y}
} "Jan 20, 2000"
+# weekday specification and base.
+test clock-4.38 {2nd monday in november} {
+ set res {}
+ foreach i {91 92 93 94 95 96} {
+ set nov8th [clock scan 11/8/$i]
+ set monday [clock scan monday -base $nov8th]
+ lappend res [clock format $monday -format %Y-%m-%d]
+ }
+ set res
+} {1991-11-11 1992-11-09 1993-11-08 1994-11-14 1995-11-13 1996-11-11}
+test clock-4.39 {2nd monday in november (2nd try)} {
+ set res {}
+ foreach i {91 92 93 94 95 96} {
+ set nov1th [clock scan 11/1/$i]
+ set monday [clock scan "2 monday" -base $nov1th]
+ lappend res [clock format $monday -format %Y-%m-%d]
+ }
+ set res
+} {1991-11-11 1992-11-09 1993-11-08 1994-11-14 1995-11-13 1996-11-11}
+test clock-4.40 {last monday in november} {
+ set res {}
+ foreach i {91 92 93 94 95 96} {
+ set dec1th [clock scan 12/1/$i]
+ set monday [clock scan "monday 1 week ago" -base $dec1th]
+ lappend res [clock format $monday -format %Y-%m-%d]
+ }
+ set res
+} {1991-11-25 1992-11-30 1993-11-29 1994-11-28 1995-11-27 1996-11-25}
+
+test clock-4.40 {2nd monday in november} knownBug {
+ set res {}
+ foreach i {91 92 93 94 95 96} {
+ set nov8th [clock scan 11/8/$i -gmt 1]
+ set monday [clock scan monday -base $nov8th -gmt 1]
+ lappend res [clock format $monday -format %Y-%m-%d -gmt 1]
+ }
+ set res
+} {1991-11-11 1992-11-09 1993-11-08 1994-11-14 1995-11-13 1996-11-11}
+test clock-4.41 {2nd monday in november (2nd try)} knownBug {
+ set res {}
+ foreach i {91 92 93 94 95 96} {
+ set nov1th [clock scan 11/1/$i -gmt 1]
+ set monday [clock scan "2 monday" -base $nov1th -gmt 1]
+ lappend res [clock format $monday -format %Y-%m-%d -gmt 1]
+ }
+ set res
+} {1991-11-11 1992-11-09 1993-11-08 1994-11-14 1995-11-13 1996-11-11}
+test clock-4.40 {last monday in november} knownBug {
+ set res {}
+ foreach i {91 92 93 94 95 96} {
+ set dec1th [clock scan 12/1/$i -gmt 1]
+ set monday [clock scan "monday 1 week ago" -base $dec1th -gmt 1]
+ lappend res [clock format $monday -format %Y-%m-%d -gmt 1]
+ }
+ set res
+} {1991-11-25 1992-11-30 1993-11-29 1994-11-28 1995-11-27 1996-11-25}
+
# clock seconds
test clock-5.1 {clock seconds tests} {
expr [clock seconds]+1