
# tests for clock from tcl date1

package require tcltest



# bug found 06/2008 in clock scan "x day y sec" routine in summertime at 22:00

tcltest::test date {bug clock scan x day y sec summertime 16:00:00} -body {expr [clock scan "[expr 31+29+31+ 7*365 + 1] day [expr 16*3600] sec" -base 946681200] - [clock scan "[expr 31+29+31+ 7*365 + 1] day [expr 16*3600 - 1] sec" -base 946681200]} -result 1
tcltest::test date {bug clock scan x day y sec summertime 22:00:00} -body {expr [clock scan "[expr 31+29+31+ 7*365 + 1] day [expr 22*3600] sec" -base 946681200] - [clock scan "[expr 31+29+31+ 7*365 + 1] day [expr 22*3600 - 1] sec" -base 946681200]} -result 1
tcltest::test date {bug clock scan x day y sec summertime 22:59:59} -body {expr [clock scan "[expr 31+29+31+ 7*365 + 1] day [expr 23*3600] sec" -base 946681200] - [clock scan "[expr 31+29+31+ 7*365 + 1] day [expr 23*3600 - 1] sec" -base 946681200]} -result 1
tcltest::test date {bug clock scan x day y sec summertime 23:00:00} -body {expr [clock scan "[expr 31+29+31+ 7*365 + 1] day [expr 23*3600+1] sec" -base 946681200] - [clock scan "[expr 31+29+31+ 7*365 + 1] day [expr 23*3600] sec" -base 946681200]} -result 1
tcltest::test date {bug clock scan x day y sec wintertime} -body {expr [clock scan "[expr 31+29+20+ 7*365 + 1] day [expr 22*3600] sec" -base 946681200] - [clock scan "[expr 31+29+20+ 7*365 + 1] day [expr 22*3600 - 1] sec" -base 946681200]} -result 1


# bug found 06/2008 in clock scan "x day y sec" routine on change to wintertime on 21:00

tcltest::test date {bug clock scan x day y sec change wintertime 21:00} -body {expr [clock scan "[expr 31+29+31+30+31+30+31+31+30+25+ 8*365 + 1] day [expr 21*3600] sec" -base 946681200] - [clock scan "[expr 31+29+31+30+31+30+31+31+30+25+ 8*365 + 1] day [expr 21*3600 - 1] sec" -base 946681200]} -result 1
tcltest::test date {bug clock scan x day y sec change wintertime 22:00} -body {expr [clock scan "[expr 31+29+31+30+31+30+31+31+30+25+ 8*365 + 1] day [expr 22*3600] sec" -base 946681200] - [clock scan "[expr 31+29+31+30+31+30+31+31+30+25+ 8*365 + 1] day [expr 22*3600 - 1] sec" -base 946681200]} -result 1
tcltest::test date {bug clock scan x day y sec change wintertime 23:00} -body {expr [clock scan "[expr 31+29+31+30+31+30+31+31+30+25+ 8*365 + 1] day [expr 23*3600] sec" -base 946681200] - [clock scan "[expr 31+29+31+30+31+30+31+31+30+25+ 8*365 + 1] day [expr 23*3600 - 1] sec" -base 946681200]} -result 1

tcltest::test date {bug clock scan x day y sec change wintertime test 4} -body {clock format [clock scan "[expr 31+29+31+30+31+30+31+31+30+25+ 8*365 + 1] day [expr 23*3600-1] sec" -base 946681200] -format "%d.%m.%Y %H:%M:%S"} -result "25.10.2008 22:59:59"
tcltest::test date {bug clock scan x day y sec change wintertime test 5} -body {clock format [clock scan "[expr 31+29+31+30+31+30+31+31+30+25+ 8*365 + 1] day [expr 23*3600] sec" -base 946681200] -format "%d.%m.%Y %H:%M:%S"} -result "25.10.2008 23:00:00"
tcltest::test date {bug clock scan x day y sec wintertime test 6} -body {clock format [clock scan "[expr 31+29+31+30+31+30+31+31+30+26+ 8*365 + 1] day [expr 23*3600-1] sec" -base 946681200] -format "%d.%m.%Y %H:%M:%S"} -result "26.10.2008 22:59:59"
tcltest::test date {bug clock scan x day y sec wintertime test 7} -body {clock format [clock scan "[expr 31+29+31+30+31+30+31+31+30+26+ 8*365 + 1] day [expr 23*3600] sec" -base 946681200] -format "%d.%m.%Y %H:%M:%S"} -result "26.10.2008 23:00:00"


tcltest::cleanupTests
