DATE_OF_INTEGER

The DATE_OF_INTEGER function converts a date in the Gregorian calendar from integer date form to standard date form (YYYYMMDD). The type of this function is integer.

The functionality is identical to the COBOL85 function DATE-OF-INTEGER.

Explanation

The one parameter to this function is a positive integer that represents a number of days succeeding December 31, 1600, on the Gregorian calendar.

An invalid argument will return a value of 0 (zero).

The returned value represents the ISO standard date equivalent of the integer parameter in the form (YYYYMMDD) where,

In the representation YYYYMMDD, . . .

Represents . . .

YYYY

Represents a year in the Gregorian calendar.

MM

Represents the month of that year.

DD

Represents the day of that month.

Example

BEGIN
   $ INCLUDE INTL = "*SYMBOL/INTL/ALGOL/PROPERTIES." 10000000 - 89999999
   EBCDIC ARRAY OUT[0:100];
   EBCDIC ARRAY A[0:20];
   POINTER P;
   INTEGER YYYYMMDD;
   INTEGER IOD,DOI;
   P := OUT[0];
   CURRENT_DATE(A);
   YYYYMMDD := INTEGER(A[0],8);
   IOD := INTEGER_OF_DATE(YYYYMMDD);
   DOI := DATE_OF_INTEGER(IOD);
   REPLACE P BY "YYYYMMDD=", YYYYMMDD FOR 8 DIGITS,
                " INTEGER_OF_DATE=", IOD FOR 8 DIGITS,
                " DATE_OF_INTEGER=", DOI FOR 8 DIGITS, 0 FOR 1;
   DISPLAY(P);
END. 

If run on July 16, 2012 the program would display:

YYYYMMDD=20120716 INTEGER_OF_DATE=00150312 DATE_OF_INTEGER=20120716