-
Notifications
You must be signed in to change notification settings - Fork 16
/
fillTimeRange.ur
26 lines (24 loc) · 984 Bytes
/
fillTimeRange.ur
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
functor Make(M : sig
table slot : { Begin : time, End : time }
val initial : time
val final : time
val duration : int
end) = struct
open M
fun addStartingAt here =
if addSeconds here duration > final then
return ()
else
dml (INSERT INTO slot(Begin, End)
VALUES ({[here]}, {[addSeconds here duration]}));
addStartingAt (addSeconds here duration)
task initialize = fn () =>
anyThere <- oneRowE1 (SELECT COUNT( * ) > 0
FROM slot
WHERE slot.Begin >= {[initial]}
AND slot.End <= {[final]});
if anyThere then
return ()
else
addStartingAt initial
end