StdTime.dcl 1.4 KB
Newer Older
Peter Achten's avatar
Peter Achten committed
1
2
3
4
5
6
7
8
9
definition module StdTime


//	********************************************************************************
//	Clean Standard Object I/O library, version 1.2
//	
//	StdTime contains time related operations.
//	********************************************************************************

10
from	StdOverloaded import <
11
from	ostick import Tick
Peter Achten's avatar
Peter Achten committed
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30

::	Time
	=	{	hours	:: !Int		// hours		(0-23)
		,	minutes	:: !Int		// minutes		(0-59)
		,	seconds	:: !Int		// seconds		(0-59)
		}
::	Date
	=	{	year	:: !Int		// year
		,	month	:: !Int		// month		(1-12)
		,	day		:: !Int		// day			(1-31)
		,	dayNr	:: !Int		// day of week	(1-7, Sunday=1, Saturday=7)
		}

wait				:: !Int .x -> .x

/*	wait n x suspends the evaluation of x modally for n ticks.
	If n<=0, then x is evaluated immediately.
*/

31
32
instance < Tick

33
34
intPlusTick			::	!Int  !Tick	-> Tick
tickDifference		::	!Tick !Tick	-> Int
35

Peter Achten's avatar
Peter Achten committed
36
37
38
39
class TimeEnv env where
	getBlinkInterval:: !*env -> (!Int,	!*env)
	getCurrentTime	:: !*env -> (!Time,	!*env)
	getCurrentDate	:: !*env -> (!Date,	!*env)
40
	getCurrentTick	:: !*env -> (!Tick,	!*env)
Peter Achten's avatar
Peter Achten committed
41
42
43
44
45
46
47
48
/*	getBlinkInterval
		returns the time interval in ticks that should elapse between blinks of 
		e.g. a cursor. This interval may be changed by the user while the 
		interactive process is running!
	getCurrentTime
		returns the current Time.
	getCurrentDate
		returns the current Date.
49
50
	getCurrentTick
		returns the current Tick.
Peter Achten's avatar
Peter Achten committed
51
52
53
*/

instance TimeEnv World