summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorsebres <sebres@users.sourceforge.net>2017-01-10 22:44:30 (GMT)
committersebres <sebres@users.sourceforge.net>2017-01-10 22:44:30 (GMT)
commit9ece7c7e6960bda4940f6b550d3522be072a1092 (patch)
tree4b03deccddc827f2270a58e5a84f607f7d60add3 /tests
parent5d100ec32832dcd2eb49c5e734a2664e1f240c41 (diff)
downloadtcl-9ece7c7e6960bda4940f6b550d3522be072a1092.zip
tcl-9ece7c7e6960bda4940f6b550d3522be072a1092.tar.gz
tcl-9ece7c7e6960bda4940f6b550d3522be072a1092.tar.bz2
several missing scan tokens added, test cases extended and fixed;
token "%s" used for seconds only (time zone independent), additionally "%Es" token added for local seconds (zone dependent seconds);
Diffstat (limited to 'tests')
-rw-r--r--tests/clock.test49
1 files changed, 47 insertions, 2 deletions
diff --git a/tests/clock.test b/tests/clock.test
index b27d2a3..4b0587a 100644
--- a/tests/clock.test
+++ b/tests/clock.test
@@ -18605,6 +18605,40 @@ test clock-6.19 {no token parsing} {
[catch { clock scan "...%..." -format "...%%..." }]
} {0 0}
+test clock-6.20 {special char tokens %n, %t} {
+ clock scan "30\t06\t2009\n18\t30" -format "%d%t%m%t%Y%n%H%t%M" -gmt 1
+} 1246386600
+
+# Hi, Jeff!
+test clock-6.21.0 {Stardate 0 day} {
+ list [set d [clock format -757382400 -format "%Q" -gmt 1]] \
+ [clock scan $d -format "%Q" -gmt 1]
+} [list "Stardate 00000.0" -757382400]
+test clock-6.21.1 {Stardate} {
+ list [set d [clock format 1482857280 -format "%Q" -gmt 1]] \
+ [clock scan $d -format "%Q" -gmt 1]
+} [list "Stardate 70986.7" 1482857280]
+test clock-6.21.2 {Stardate next time} {
+ list [set d [clock format 1482865920 -format "%Q" -gmt 1]] \
+ [clock scan $d -format "%Q" -gmt 1]
+} [list "Stardate 70986.8" 1482865920]
+test clock-6.21.3 {Stardate correct scan over year (leap year, begin, middle and end of the year)} -body {
+ set s [clock scan "01.01.2016" -f "%d.%m.%Y" -g 1]
+ set s [set i [clock scan [clock format $s -f "%Q" -g 1] -g 1]]
+ set wrong {}
+ while {[incr i 86400] < $s + 86400*366*2} {
+ set d [clock format $i -f "%Q" -g 1]
+ set i2 [clock scan $d -f "%Q" -g 1]
+ if {$i != $i2} {
+ lappend wrong "$d -- ($i != $i2) -- [clock format $i -g 1]"
+ }
+ }
+ join $wrong \n
+} -result {} -cleanup {
+ unset -nocomplain wrong i i2 s d
+}
+
+
test clock-7.1 {Julian Day} {
clock scan 0 -format %J -gmt true
} -210866803200
@@ -36080,10 +36114,21 @@ test clock-37.1 {%s gmt testing} {
set s [clock seconds]
set a [clock format $s -format %s -gmt 0]
set b [clock format $s -format %s -gmt 1]
+ set c [clock scan $s -format %s -gmt 0]
+ set d [clock scan $s -format %s -gmt 1]
# %s, being the difference between local and Greenwich, does not
# depend on the time zone.
- set c [expr {$b-$a}]
-} {0}
+ list [expr {$b-$a}] [expr {$d-$c}]
+} {0 0}
+test clock-37.2 {%Es gmt testing} {
+ set s [clock seconds]
+ set a [clock format $s -format %Es -timezone CET]
+ set b [clock format $s -format %Es -gmt 1]
+ set c [clock scan $s -format %Es -timezone CET]
+ set d [clock scan $s -format %Es -gmt 1]
+ # %Es depend on the time zone (local seconds instead of posix seconds).
+ list [expr {$b-$a}] [expr {$d-$c}]
+} {-3600 3600}
test clock-38.1 {regression - convertUTCToLocalViaC - east of Greenwich} \
-setup {