Y2K Date Routines

 

Thirteen programs provide just about any date conversion function that could possibly be required:

Y2KATOG Converts astronomical number to Gregorian format.
Y2KCONV Uses a conversion point to convert a 2 digit year to a 4 digit year.
Y2KDFMT Formats a Gregorian date into a variety of formats.
Y2KDOWN Returns day of week number for Gregorian date.
Y2KESTR Returns Gregorian date of Easter for any given year.
Y2KGETD Returns current date in Gregorian, Julian and astrological number formats.
Y2KGTOA Converts Gregorian format date to astronomical number.
Y2KGTOJ Converts Gregorian format date to Julian format.
Y2KJTOG Converts Julian format date to Gregorian format.
Y2KLAGE Computes number of years, months, days between two Gregorian format dates.
Y2KPROJ Returns Gregorian format date using specified Gregorian format date plus/minus offset.
Y2KSAGE Computes number of days between two Gregorian format dates.
Y2KTDOW Returns next/previous specified day of week from Gregorian format date.

Using the intrinsic functions of GnuCOBOL, some of these routines are now redundant, but at the time I wrote them, they all provided very useful functionality.

There is also an installation verification program provided, Y2KIVP, along with a set of test data to verify that the expected results are obtained from the execution of the program.

To install all fourteen source programs and the test data file, and compile the programs, execute the bash script: Y2Ksetup [md5: 7c21070ff8d6a92258eb5c136fec7438].  Right click on the link and save the script in the location where you want the source programs to reside, then execute it.  It will create files containing the fourteen source programs, plus the one data file, then execute the GnuCOBOL compiler to compile the fourteen programs.  The GnuCOBOL compiler must be installed prior to executing the bash script.

To verify the programs are functioning correctly, execute the program Y2KIVP, which will read the data file Y2KIVP.dat and produce a report Y2KIVP.rpt.  The report will include expected and actual results for a variety of test dates:

DATE: 05/15/2016                              YEAR 2000 COMPLIANT DATE SUBROUTINES                                   PROGRAM: Y2KIVP
TIME: 17:30                                    INSTALLATION VERIFICATION PROGRAM                                        PAGE:      1

TEST DATA INPUT RECORD                                       ROUTINE  R/C
ATOG 2$%D000           INVALID CHARACTERS (ZD)               Y2KATOG  *2*  INVALID ZONED-DECIMAL DATA
ATOG 2304000           INVALID VALUE (RANGE)                 Y2KATOG  *4*  INVALID VALUE (OUT OF RANGE)
ATOG 2305813           INVALID VALUE (RANGE)                 Y2KATOG  *4*  INVALID VALUE (OUT OF RANGE)
ATOG 2305814           01/01/1601                            Y2KATOG   0   01/01/1601
ATOG 2962884           12/31/3399                            Y2KATOG   0   12/31/3399
ATOG 2962885           INVALID VALUE (RANGE)                 Y2KATOG  *4*  INVALID VALUE (OUT OF RANGE)
ATOG 2980000           INVALID VALUE (RANGE)                 Y2KATOG  *4*  INVALID VALUE (OUT OF RANGE)
ATOG 2451544           12/31/1999                            Y2KATOG   0   12/31/1999
ATOG 2451545           01/01/2000                            Y2KATOG   0   01/01/2000
ATOG 2451546           01/02/2000                            Y2KATOG   0   01/02/2000
ATOG 2451547           01/03/2000                            Y2KATOG   0   01/03/2000
CONV 010197 1 70       01/01/1997  1997/001  2,450,450       Y2KCONV   0   01/01/1997  1997/001  2,450,450
CONV 310197 2 70       01/31/1997  1997/031  2,450,480       Y2KCONV   0   01/31/1997  1997/031  2,450,480
CONV 970103 3 70       01/03/1997  1997/003  2,450,452       Y2KCONV   0   01/03/1997  1997/003  2,450,452
CONV 97004  4 70       01/04/1997  1997/004  2,450,453       Y2KCONV   0   01/04/1997  1997/004  2,450,453
CONV 060195 1 97       06/01/2095  2095/152  2,486,395       Y2KCONV   0   06/01/2095  2095/152  2,486,395
CONV 01A597 1 70       INVALID CHARACTERS (ZD)(DATE)         Y2KCONV  *2*  INVALID ZONED-DECIMAL DATA (DATE)
CONV 010197 8 70       INVALID VALUE (FORMAT)                Y2KCONV  *5*  INVALID DATE FORMAT CODE
CONV 010197 1 B7       INVALID CHARACTERS (ZD)(BREAK)        Y2KCONV  *3*  INVALID ZONED-DECIMAL DATA (BREAK)
CONV 130197 1 70       INVALID VALUE (MONTH)                 Y2KCONV  *6*  INVALID VALUE (MONTH)
CONV 023197 1 70       INVALID VALUE (DAY)                   Y2KCONV  *8*  INVALID VALUE (DAY)
CONV 131397 2 70       INVALID VALUE (MONTH)                 Y2KCONV  *6*  INVALID VALUE (MONTH)
CONV 300297 2 70       INVALID VALUE (DAY)                   Y2KCONV  *8*  INVALID VALUE (DAY)

... report continues for six pages

Since these routines are intended to be called by other programs to provide the date conversion functionality, you should move the object modules (ending with .so extension) to the location specified for your COB_LIBRARY_PATH. 

To facility building your own COBOL programs using the library of routines, a Y2K.cpy member is also created in the installation directory and should be copied to the location pointed to by your COB_COPY_DIR variable.

Update 18 September 2017: The 2.2 release of GnuCOBOL had a bug that reared its head when the INITIAL operand was included on PROGRAM-ID. The bug will be fixed, but the use of INITIAL was probably a poor choice by me and I decided to remove the INITIAL operand and instead utilize LOCAL-STORAGE for fields that were in WORKING-STORAGE for all the subprograms. I did leave constant fields in the WORKING-STORAGE section in the few programs where there were constant fields defined/used. I also modified the day and month names in the constant tables of Y2KDFMT from UPPER to Mixed case. The environment in which these routines were developed was an IBM Mainframe, where UPPER case was the expected norm. In any modern environment, Mixed case will be expected, so this is a logical change to make at this time, as I am already making the other change. Functionally, the only change that will be evident is the case of the day and month names returned from Y2KDFMT.


This page was last updated on September 18, 2017.