summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorgahr <gahr@gahr.ch>2016-02-17 11:03:48 (GMT)
committergahr <gahr@gahr.ch>2016-02-17 11:03:48 (GMT)
commit03dd6c13603af9d6792030412f52d942fc2eaefd (patch)
tree36dc308e5e2879fff93be3333f2225732a0387fd /tests
parentf7ea5b6cc57fafcbcb3377e83fdbc4d999d123d4 (diff)
downloadtcl-03dd6c13603af9d6792030412f52d942fc2eaefd.zip
tcl-03dd6c13603af9d6792030412f52d942fc2eaefd.tar.gz
tcl-03dd6c13603af9d6792030412f52d942fc2eaefd.tar.bz2
[5f71353740] Support the "weekdays" unit in [clock add]
Diffstat (limited to 'tests')
-rw-r--r--tests/clock.test37
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/clock.test b/tests/clock.test
index 615f3a8..fc7992d 100644
--- a/tests/clock.test
+++ b/tests/clock.test
@@ -34992,6 +34992,10 @@ test clock-29.1800 {time parsing} {
} 86399
# END testcases29
+
+# BEGIN testcases30
+
+# Test [clock add]
test clock-30.1 {clock add years} {
set t [clock scan 2000-01-01 -format %Y-%m-%d -timezone :UTC]
set f [clock add $t 1 year -timezone :UTC]
@@ -35218,6 +35222,39 @@ test clock-30.25 {clock add seconds at DST conversion} {
set x1 [clock format $f1 -format {%Y-%m-%d %H:%M:%S %z} \
-timezone EST05:00EDT04:00,M4.1.0/02:00,M10.5.0/02:00]
} {2004-10-31 01:00:00 -0500}
+test clock-30.26 {clock add weekdays} {
+ set t [clock scan {2013-11-20}] ;# Wednesday
+ set f1 [clock add $t 3 weekdays]
+ set x1 [clock format $f1 -format {%Y-%m-%d}]
+} {2013-11-25}
+test clock-30.27 {clock add weekdays starting on Saturday} {
+ set t [clock scan {2013-11-23}] ;# Saturday
+ set f1 [clock add $t 1 weekday]
+ set x1 [clock format $f1 -format {%Y-%m-%d}]
+} {2013-11-25}
+test clock-30.28 {clock add weekdays starting on Sunday} {
+ set t [clock scan {2013-11-24}] ;# Sunday
+ set f1 [clock add $t 1 weekday]
+ set x1 [clock format $f1 -format {%Y-%m-%d}]
+} {2013-11-25}
+test clock-30.29 {clock add weekdays systematic} -body {
+ set n [clock seconds]
+ set d [clock format $n -format %u]
+ for {set i 1} {$i < 100} {incr i} {
+ set res_no [clock format [clock add $n $i weekdays] -format %u]
+ set exp_mod [expr {($d+$i)%5}]
+ if {$exp_mod == 0} {
+ set exp_mod 5
+ }
+ if {$res_no != $exp_mod} {
+ return "Got $res_no adding $i to $n, expected: $exp_mod"
+ }
+ }
+ return "OK"
+} -result {OK}
+
+# END testcases30
+
test clock-31.1 {system locale} \
-constraints win \