This article describes how to retrieve UNIX time values and translate them to COBOL style values using C language functions.
Problem:
UNIX dates and time are frequently stored as a single integer containing the number of seconds since January 1, 1970. It is a convenient way for C language functions to store date and time stamps. The COBOL system uses a different scheme to keep track of date and time and there are times when a bit of translation from one representation to another is required. What special handling is required to transform this time to a useful and readable format?
Resolution:
UNIX time values can be retrieved and translated to COBOL style values by using C language functions which call the ctime() family of functions to manipulate the date and time to and from UNIX time formats. The attached example program uses this method to get the current date and time in UNIX Time form and then translate it to a human readable format.
- Extract the source files from the example and place the files the UNIX machine
- The C language functions are intended to be compiled to .so form using the command cob –z source.c
- The COBOL program should be compiled to interpreted executable form, for example .int
- Compile the example using the command: make –f time.mk
- Execute the example using the command: cobruntesttime