summaryrefslogtreecommitdiffstats
path: root/tests/clock.test
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2023-09-14 21:17:21 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2023-09-14 21:17:21 (GMT)
commitf59a26a7c8e592e030fd55bc5e1dc02789dc7bbe (patch)
tree7e1ca17ffa40e1929c1af6cc768942e6847367d1 /tests/clock.test
parent715e8c335c2d4fa5e6547009522f3c5d1ca1d034 (diff)
downloadtcl-f59a26a7c8e592e030fd55bc5e1dc02789dc7bbe.zip
tcl-f59a26a7c8e592e030fd55bc5e1dc02789dc7bbe.tar.gz
tcl-f59a26a7c8e592e030fd55bc5e1dc02789dc7bbe.tar.bz2
Fix [00655c867e]: ClockGetdatefieldsObjCmd(): avoid signed integer overflow and platform-dependent behavior
Diffstat (limited to 'tests/clock.test')
-rw-r--r--tests/clock.test14
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/clock.test b/tests/clock.test
index 587828f..4b12d5c 100644
--- a/tests/clock.test
+++ b/tests/clock.test
@@ -18600,6 +18600,20 @@ test clock-7.9 {Julian Day, two values} {
clock scan {2440588 2440589} -format {%J %J} -gmt true
} 86400
+test clock-7.10 {Julian Day, negative amount} {
+ # Note: %J does not accept negative input;
+ # add negative amounts to Julian day 0 instead
+ set s0 [clock scan 0 -format %J -gmt true]
+ set J0 [scan [clock format $s0 -format %J -gmt true] %lld]
+ set s0m1d [clock add $s0 -1 days]
+ set s0m24h [clock add $s0 -24 hours]
+ set J0m24h [scan [clock format $s0m24h -format %J -gmt true] %lld]
+ set s0m1s [clock add $s0 -1 seconds]
+ set J0m1s [scan [clock format $s0m1s -format %J -gmt true] %lld]
+ list $s0m1d $s0m24h $J0m24h $s0m1s $J0m1s $s0 $J0 \
+ [::tcl::mathop::== $s0m1d $s0m24h] [::tcl::mathop::== $J0m24h $J0m1s]
+} [list -210866889600 -210866889600 -1 -210866803201 -1 -210866803200 0 1 1]
+
# BEGIN testcases8
# Test parsing of ccyymmdd