DEFINITION MODULE DMClock;
(*******************************************************************
Module DMClock ('Dialog Machine' DM_V3.0)
Copyright (c) 1990-2006 by Andreas Fischlin and ETH Zurich.
Purpose Access to the computer's internal clock to read
the current time and date.
Remarks Macintosh implementation:
------------------------
All date operations are only valid within range
[1st January 1904 till 31st December 2040].
Normally just the routines Today and Now are used.
However, note also that a date and a time are stored
in one long integer and this number corresponds to
the number of seconds elapsed since 1st January 1904.
This allows for easy and efficient date comparisons
(e.g. when comparing file modification dates) but
requires a routine for translation into more
meaningful forms and vice versa. The latter is
provided by the routines InterpreteSeconds and
ConvertDateToSeconds.
IBM PC implementation:
---------------------
- to be completed -.
This module belongs to the 'Dialog Machine'.
Programming
o Design
Andreas Fischlin 21/09/1990
o Implementation
Andreas Fischlin 21/09/1990
ETH Zurich
Systems Ecology
CHN E 35.1
Universitaetstrasse 16
8092 Zurich
SWITZERLAND
URLs:
<mailto:RAMSES@env.ethz.ch>
<http://www.sysecol.ethz.ch>
<http://www.sysecol.ethz.ch/SimSoftware/RAMSES>
Last revision of definition: 23/10/1990 AF
*******************************************************************)
CONST
Jan = 1; Feb = 2; Mar = 3; Apr = 4; Mai = 5; Jun = 6;
Jul = 7; Aug = 8; Sep = 9; Oct = 10; Nov = 11; Dec = 12;
Sun = 1; Mon = 2; Tue = 3; Wed = 4; Thu = 5; Fri = 6; Sat = 7;
(* hour is always within range [0..23] *)
PROCEDURE Today (VAR year, month, day, dayOfWeek: INTEGER);
PROCEDURE Now (VAR hour, minute, second: INTEGER);
(*
Low level routines for advanced programmers, mainly of use for
the Macintosh implementation:
*)
PROCEDURE NowInSeconds (): LONGINT;
(*
Note above routine returns negative values since 19/Jan/1972
03h14:07 UTC, since the range of LONGINT has been exhausted and
seconds are now counted between MAX(LONGINT) and MAX(LONGCARD).
Thus be aware of the fact that the more recent a time later than
that date, the lower its value in seconds as returned by
NowInSeconds. if comparing or computing times it might be
preferable to coerce first the returned value into a lcard value.
Ex.:
ConvertDateToSeconds(year1, ..., t1);
ConvertDateToSeconds(year2, ..., t2);
deltaT := LONGCARD(NowInSeconds()) + LONGCARD(t2) - LONGCARD(t1);
*)
PROCEDURE InterpreteSeconds (secs: LONGINT;
VAR year, month, day,
hour, minute, second,
dayOfWeek: INTEGER);
PROCEDURE ConvertDateToSeconds (year, month, day,
hour, minute, second: INTEGER;
VAR secs: LONGINT);
END DMClock.