37 lines
1.1 KiB
Text
37 lines
1.1 KiB
Text
constant watches = {"First","Middle","Morning","Forenoon","Afternoon","First dog","Last dog","First"},
|
|
watch_ends = {"00:00", "04:00", "08:00", "12:00", "16:00", "18:00", "20:00", "23:59"},
|
|
bells = {"One","Two","Three","Four","Five","Six","Seven","Eight"},
|
|
ding = "ding!"
|
|
|
|
procedure nb(integer h,m)
|
|
integer bell = mod(floor((h*60+m)/30),8)
|
|
if bell==0 then bell = 8 end if
|
|
string hm = sprintf("%02d:%02d",{h,m})
|
|
integer watch=1
|
|
while hm>watch_ends[watch] do watch += 1 end while
|
|
string plural = iff(bell==1?" ":"s")
|
|
string dings = ding
|
|
for i=2 to bell do dings &= iff(mod(i,2)?" ":"")&ding end for
|
|
printf(1,"%s %9s watch %5s bell%s %s\n",
|
|
{hm,watches[watch],bells[bell],plural,dings})
|
|
end procedure
|
|
|
|
procedure simulate1day()
|
|
for h=0 to 23 do
|
|
for m=0 to 30 by 30 do
|
|
nb(h,m)
|
|
end for
|
|
end for
|
|
nb(0,0) -- (again)
|
|
end procedure
|
|
|
|
simulate1day()
|
|
|
|
while 1 do
|
|
sequence d = date(DT_GMT)
|
|
integer m = d[DT_SECOND] + mod(d[DT_MINUTE],30)*60
|
|
if m=0 then
|
|
nb(d[DT_HOUR],d[DT_MINUTE])
|
|
end if
|
|
sleep(30*60-m)
|
|
end while
|