Modula-2 || Compiler & Tools || Library || Search Engine


Ulm's Modula-2 Library:
Calendar


NAME

Calendar - date and time calculations

SYNOPSIS

TYPE
   Time         = SystemTypes.TIME;
   Date         = LONGCARD;


Year = CARDINAL; Month = [1..12]; Day = [1..31]; Hour = [0..23]; Minute = [0..59]; Second = [0..59]; Weekday = (Mon, Tue, Wed, Thu, Fri, Sat, Sun); Week = [1..53]; Yearday = [1..366];

Daytime = RECORD hour: Hour; minute: Minute; second: Second; END;

Calendarday = RECORD year: Year; month: Month; day: Day; END;

CalendarInfo = RECORD weekday: Weekday; week: Week; yearday: Yearday; END; PROCEDURE CurrentTime(): Time; PROCEDURE ConvertTime(time: Time; VAR date: Date; VAR daytime: Daytime);

PROCEDURE ConvertDate(date: Date; VAR calendarday: Calendarday);

PROCEDURE ConvertCald(calendarday: Calendarday; VAR info: CalendarInfo); PROCEDURE CTime(date: Date; daytime: Daytime): Time;

PROCEDURE CDate(year: Year; month: Month; day: Day): Date;

PROCEDURE CUltimo(year: Year; month: Month): Date;

PROCEDURE CWeekday(date: Date): Weekday;

PROCEDURE DateOK(year, month, day: CARDINAL): BOOLEAN; PROCEDURE TimeToString(time: Time; VAR string: ARRAY OF CHAR); PROCEDURE SetFirstOfWeek(weekday: Weekday); PROCEDURE GetTimezone(VAR tzname: ARRAY OF CHAR);

PROCEDURE SetTimezone( tzname: ARRAY OF CHAR);

PROCEDURE GetLocaltime(VAR delay: Time);

PROCEDURE SetLocaltime( delay: Time);

DESCRIPTION

Calendar is a module supporting date and time calculations with the Caesar/Gregorian (i.e., our) calendar. Too, the time in the form used by the system can be handled.

Time is a LONGINT value of seconds since 00:00:00 GMT Jan 1, 1970 . Date is a day number since some date in ancient history - not later than Jan 1, 0001 - where consecutive days are always represented as consecutive numbers. Note that in 1582, the year of the Gregor calendar reformation, some dates were skipped, and that leap years occurred more often before.
Week is a week's number in the year - edge weeks belonging to the year that contains more days of them. Only therefore it matters which weekday is considered the first in a week, Sunday or Monday (default), which can be specified with SetFirstOfWeek.

CurrentTime returns the system's idea of what the time is.

ConvertTime, and ConvertCald convert/expand values of Time, or Calendarday into more and more reasonable information.

The functions CTime and CDate do the opposite. Correct results, however, are guaranteed for correct arguments only. Which calendar dates are correct, i.e. were or will be used actually, can be detected with DateOK.

CUltimo returns the date of the last day of the given month.

CWeekday returns the weekday upon which the given date falls.

TimeToString converts a Time value time into a character string string of the form, e.g. "Thu Jan 21 16:53:27 1988 MEZ". Its first 24 characters always have fixed positions; the rest of it is the local time zone name as returned by GetTimezone

As the system operates in GMT (Greenwich Mean Time), Ctime, and TimeToString use a delay in seconds relative to GMT to compute day and hour in the locally appropriate way. This delay and the name of the local time zone are initialized according to the environment parameter TZ, that should contain an optional non-numeric string for the time zone name and a small integer value specifying hours, or a large integer (with absolute value >= 60) specifying seconds. These can be looked up cf. altered with GetLocaltime, and SetTimezone.

AUTHOR

Martin Hasch, University of Ulm

SEE ALSO

time(2), date(1), Clock, Strings, Environment
Edited by: borchert, last change: 1997/02/25, revision: 1.3, converted to HTML: 1997/04/28

Modula-2 || Compiler & Tools || Library || Search Engine