All date procedures have been checked for problems around 2000. Some old routines didn't consider the year 2000 to be a leapyear. Fixed
TYPE MonthStr = ARRAY[1..12] OF String[3]; DowsStr = ARRAY[0..6] OF String[3]; CONST Months:MonthStr=('Jan','Feb','Mar','Apr','May','Jun','Jul', 'Aug','Sep','Oct','Nov','Dec'); Dows :DowsStr=('Sun','Mon','Tue','Wed','Thu','Fri','Sat');
The following type is used by MovableCeremony
TYPE Ceremony = (AshWednesday,GoodFriday,EasterSunday, EasterMonday,AscensionDay,Whitsunday, WhitsunMonday,CorpusChristiDay,RepentanceDay, FirstAdvent,SecondAdvent,MothersDay);
The procedures marked with PAS are always Pascal
Normal procedures
Declaration
FUNCTION LeapYr( Year : WORD ) : BOOLEAN;
Description
Returns TRUE when the year is a leapyear. FALSE otherwise.
A leapyear is defined as
(Year and 3=0) AND ((Year DIV 100)<>0 OR (Year DIV 400)=0)
which will be correct until the year 4000 or so.
Declaration
FUNCTION DayNr( Day,Month,Year : WORD) : WORD;
Description
Calculates daynumber, January 1st =1. Februari 1st=32, accounts for leapyears.
Easy way to subtract days within a year, or (DayNr(31,12,Year-1) is the number of days in last year. Use DayNrBack to convert a day number back to a real date
Note: Remember, a DayNr is NOT corresponding to a date. A year and a DayNr is sufficient however
Uses LeapYr
Declaration
PROCEDURE DayNrBack( Year,DayNr:WORD; VAR Month,Day : WORD);
Description
Converts a daynumber(created with DayNr back to day and month format.
Note: Expires Feb 28th, 2100
Declaration
FUNCTION DOW( Year,Month,Day:WORD): WORD;
Description
Day of week (Sunday,Monday etc) for a given date. DOW(a Sunday)=0; DOW( a Monday)=1 etc.
Note: Expires Feb 28th, 2100
Declaration
FUNCTION ToUnix(Year, Month, Day, Hrs, Mins, Secs : WORD):CARDINAL;
Description
Calculates unixdate, which is defined as the number of seconds after 1-1-70.
Note:
Uses DayNr and (via DayNr) LeapYr
See Also FromUnix
Declaration
PROCEDURE FromUnix(Unix : LONGINT;VAR Year,Month,Day,Hour,Min,Sec:WORD);
Description
Retrieves DD-MM-YY HH:MM:SS back the from unixdate, which is defined as the number of seconds after 1-1-70.
Note:
Uses None
See Also ToUnix
Declaration
FUNCTION WeekNr(Year,Mnth,Day:WORD):WORD;
Description
Returns weeknumber (in year) for a certain date. Remember this isn't simply DayNr DIV 7. Jan 1st is not necessarily the first day of week 1.
Note:
Declaration
FUNCTION Easter (Year : WORD) : WORD;
Description
Returns the date of Easter for a given year. 1=March 1st. 32= April 1st etc.
Note:
Declaration
PROCEDURE DaTiToStr(Hour,Min,Sec,Day,Month,Year:WORD; CONST Format:String; VAR DateStr : String);
Description
DaTiToStr is a complex configurable date-formatting routine, and the biggest EDate procedure by far
Basically it copies "Format" to "DateStr", while replacing some switches. Padding character is default (when the procedure starts) 0, but can be changed to space
Replaces | with | padding with padchar? |
---|---|---|
%H | Hour | no |
%M | Min | no |
%S | Sec | no |
%D | Day | no |
%O | Month | no |
%Y | Year MOD 100 | Yes |
%h | Hour | Yes |
%m | Min | Yes |
%s | Sec | Yes |
%d | Day | Yes |
%o | Month | Yes |
%Y | Day | Yes |
%y | Year (all 4 characters) | no |
%J or %j | 3 character month (Jan,Feb) | n/a |
%W or %w | 3 character day of week (Sun,Mon) | n/a |
%L | suffix of day (st,nd,rd,th) | n/a |
%i | padding character to space | No output,internal |
%I | padding character to zero | No output,internal |
%U | Hour MOD 13 (1..12) | No |
%u | Hour MOD 13 (1..12) | Yes |
%A | AM or PM | n/a |
%a | am or pm | n/a |
Format-string to see all options, use this string twice (once prefixed with %i to see padding) to see all options:
'%H:%M:%S %h:%m:%s %U:%m %a %u:%m %A %D-%O-%Y %d-%o-%y, %W %J %D%L, %y';
Note:
Uses DOW
Declaration
PROCEDURE MovableCeremony (MovableCeremon : Ceremony; Year: WORD; VAR Day, Month : WORD);
Description
Returns day and month of a certain movable ceremony in a certain year.
Note: