
# $Id: dclock,v 1.1 1993/06/08 05:59:11 david Exp $

InterpBase add_module_directory [pwd]
require 7SegmentClass

canvas .c -background white
pack append . .c { top fill expand }
wm geometry . =180x100
wm minsize  . 1 1

set h1 [7SegmentClass new .c  20 20 20 50 black]
set h2 [7SegmentClass new .c  50 20 20 50 black]
.c create rectangle 86 28 94 36 -outline white -tags colon
.c create rectangle 86 53 94 61 -outline white -tags colon
set m1 [7SegmentClass new .c 110 20 20 50 black]
set m2 [7SegmentClass new .c 140 20 20 50 black]

proc setdate {} {
	global h1 h2 m1 m2 colon_setting
	set d [exec date]
	set word "\[A-Za-z\]+"; set num "\[0-9\]"
	regexp "^$word +$word +$num+ +($num)($num):($num)($num).*" $d match \
			hr1 hr2 mn1 mn2
	$h1 setval $hr1
	$h2 setval $hr2
	$m1 setval $mn1
	$m2 setval $mn2

	if ![info exists colon_setting] { set colon_setting "off" }
	if {$colon_setting == "off"} {
		.c itemconfigure colon -fill black
		set colon_setting "on"
	} else  {
		.c itemconfigure colon -fill white
		set colon_setting "off"
	}
}

proc dodate {} { setdate ; after 1000 dodate }
dodate
