:-eval(consult('ContractLog/math.prova')).
:-eval(consult('ContractLog/list.prova')).
:-eval(consult('ContractLog/list_math.prova')).
:-eval(consult('ContractLog/datetime.prova')).
:-eval(consult('ContractLog/timeinterval.prova')).


timeInterval(X) :-
	sysTime(DT),
	DT = [A,B,C,D,HOUR,F,G],
	X = DT,
	primePeriod(HOUR),
	!,
	interval(timespan(0,0,0,1), DT).

timeInterval(X) :-
	sysTime(DT),
	DT = [A,B,C,D,HOUR,F,G],
	X = DT,
	mainPeriod(HOUR),
	interval(timespan(0,0,0,3), DT).

timeIntervalError() :-
	sysTime(DT),
	interval(timespan(0,0,0,5), DT).
	


%two time periods
primePeriod(HOUR):-
	moreequ(HOUR,8),
	less(HOUR,18).

mainPeriod(HOUR) :-
	moreequ(HOUR,8).

mainPeriod(HOUR) :-
	less(HOUR , 8).
	
:-solve(timeInterval(Y)).