CEESECS converts a string that represents a timestamp into Lilian seconds (the number of seconds since 00:00:00 14 October 1582). This service makes it easier to perform time arithmetic, such as calculating the elapsed time between two timestamps.
| CALL CEESECS syntax |
|---|
|
The character string must contain between 5 and 80 picture characters, inclusive. input_timestamp can contain leading or trailing blanks. Parsing begins with the first nonblank character (unless the picture string itself contains leading blanks; in this case, CEESECS skips exactly that many positions before parsing begins).
After a valid date is parsed, as determined by the format of the date you specify in picture_string, all remaining characters are ignored by CEESECS. Valid dates range between and including the dates 15 October 1582 to 31 December 9999. A full date must be specified. Valid times range from 00:00:00.000 to 23:59:59.999.
If any part or all of the time value is omitted, zeros are substituted for the remaining values. For example:
1992-05-17-19:02 is equivalent to 1992-05-17-19:02:00 1992-05-17 is equivalent to 1992-05-17-00:00:00
Each character in the picture_string represents a character in input_timestamp. For example, if you specify MMDDYY HH.MI.SS as the picture_string, CEESECS reads an input_char_date of 060288 15.35.02 as 3:35:02 PM on 02 June 1988. If delimiters such as the slash (/) appear in the picture string, leading zeros can be omitted. For example, the following calls to CEESECS all assign the same value to data item secs:
CALL CEESECS USING '92/06/03 15.35.03',
'YY/MM/DD HH.MI.SS', secs, fc.
CALL CEESECS USING '92/6/3 15.35.03',
'YY/MM/DD HH.MI.SS', secs, fc.
CALL CEESECS USING '92/6/3 3.35.03 PM',
'YY/MM/DD HH.MI.SS AP', secs, fc.
CALL CEESECS USING '92.155 3.35.03 pm',
'YY.DDD HH.MI.SS AP', secs, fc.
The largest value represented is 23:59:59.999 on 31 December 9999, which is second 265,621,679,999.999 in the Lilian format.
A 64-bit long floating-point value can accurately represent approximately 16 significant decimal digits without loss of precision. Therefore, accuracy is available to the nearest millisecond (15 decimal digits).
If input_timestamp does not contain a valid date or timestamp, output_seconds is set to 0 and CEESECS terminates with a non-CEE000 symbolic feedback code.
Elapsed time calculations are performed easily on the output_seconds, because it represents elapsed time. Leap year and end-of-year anomalies do not affect the calculations.
| Symbolic feedback code | Severity | Message number | Message text |
|---|---|---|---|
| CEE000 | 0 | — | The service completed successfully. |
| CEE2EB | 3 | 2507 | Insufficient data was passed to CEEDAYS or CEESECS. The Lilian value was not calculated. |
| CEE2EC | 3 | 2508 | The date value passed to CEEDAYS or CEESECS was invalid. |
| CEE2ED | 3 | 2509 | The era passed to CEEDAYS or CEESECS was not recognized. |
| CEE2EE | 3 | 2510 | The hours value in a call to CEEISEC or CEESECS was not recognized. |
| CEE2EH | 3 | 2513 | The input date passed in a CEEISEC, CEEDAYS, or CEESECS call was not within the supported range. |
| CEE2EK | 3 | 2516 | The minutes value in a CEEISEC call was not recognized. |
| CEE2EL | 3 | 2517 | The month value in a CEEISEC call was not recognized. |
| CEE2EM | 3 | 2518 | An invalid picture string was specified in a call to a date/time service. |
| CEE2EN | 3 | 2519 | The seconds value in a CEEISEC call was not recognized. |
| CEE2EP | 3 | 2521 | The <JJJJ>, <CCCC>, or <CCCCCCCC> year-within-era value passed to CEEDAYS or CEESECS was zero. |
| CEE2ET | 3 | 2525 | CEESECS detected nonnumeric data in a numeric field, or the timestamp string did not match the picture string. |
Usage notes
CBL LIB
************************************************
** **
** Function: Call CEESECS to convert **
** timestamp to number of seconds **
** **
** In this example, calls are made to CEESECS **
** to convert two timestamps to the number of **
** seconds since 00:00:00 14 October 1582. **
** The Lilian seconds for the earlier **
** timestamp are then subtracted from the **
** Lilian seconds for the later timestamp **
** to determine the number of between the **
** two. This result is displayed. **
** **
************************************************
IDENTIFICATION DIVISION.
PROGRAM-ID. CBLSECS.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 SECOND1 COMP-2.
01 SECOND2 COMP-2.
01 TIMESTP.
02 Vstring-length PIC S9(4) BINARY.
02 Vstring-text.
03 Vstring-char PIC X,
OCCURS 0 TO 256 TIMES
DEPENDING ON Vstring-length
of TIMESTP.
01 TIMESTP2.
02 Vstring-length PIC S9(4) BINARY.
02 Vstring-text.
03 Vstring-char PIC X,
OCCURS 0 TO 256 TIMES
DEPENDING ON Vstring-length
of TIMESTP2.
01 PICSTR.
02 Vstring-length PIC S9(4) BINARY.
02 Vstring-text.
03 Vstring-char PIC X,
OCCURS 0 TO 256 TIMES
DEPENDING ON Vstring-length
of PICSTR.
01 FC.
02 Condition-Token-Value.
COPY CEEIGZCT.
03 Case-1-Condition-ID.
04 Severity PIC S9(4) COMP.
04 Msg-No PIC S9(4) COMP.
03 Case-2-Condition-ID
REDEFINES Case-1-Condition-ID.
04 Class-Code PIC S9(4) COMP.
04 Cause-Code PIC S9(4) COMP.
03 Case-Sev-Ctl PIC X.
03 Facility-ID PIC XXX.
02 I-S-Info PIC S9(9) COMP.
PROCEDURE DIVISION.
PARA-SECS1.
************************************************
** Specify first timestamp and a picture string
** describing the format of the timestamp
** as input to CEESECS
************************************************
MOVE 25 TO Vstring-length of TIMESTP.
MOVE '1969-05-07 12:01:00.000'
TO Vstring-text of TIMESTP.
MOVE 25 TO Vstring-length of PICSTR.
MOVE 'YYYY-MM-DD HH:MI:SS.999'
TO Vstring-text of PICSTR.
************************************************
** Call CEESECS to convert the first timestamp
** to Lilian seconds
************************************************
CALL 'CEESECS' USING TIMESTP, PICSTR,
SECOND1, FC.
IF NOT CEE000 of FC THEN
DISPLAY 'CEESECS failed with msg '
Msg-No of FC UPON CONSOLE
STOP RUN
END-IF.
PARA-SECS2.
************************************************
** Specify second timestamp and a picture string
** describing the format of the timestamp as
** input to CEESECS.
************************************************
MOVE 25 TO Vstring-length of TIMESTP2.
MOVE '2004-01-01 00:00:01.000'
TO Vstring-text of TIMESTP2.
MOVE 25 TO Vstring-length of PICSTR.
MOVE 'YYYY-MM-DD HH:MI:SS.999'
TO Vstring-text of PICSTR.
************************************************
** Call CEESECS to convert the second timestamp
** to Lilian seconds
************************************************
CALL 'CEESECS' USING TIMESTP2, PICSTR,
SECOND2, FC.
IF NOT CEE000 of FC THEN
DISPLAY 'CEESECS failed with msg '
Msg-No of FC UPON CONSOLE
STOP RUN
END-IF.
PARA-SECS2.
************************************************
** Subtract SECOND2 from SECOND1 to determine the
** number of seconds between the two timestamps
************************************************
SUBTRACT SECOND1 FROM SECOND2.
DISPLAY 'The number of seconds between '
Vstring-text OF TIMESTP ' and '
Vstring-text OF TIMESTP2 ' is: ' SECOND2.
GOBACK.
Example: date-and-time picture strings
related references
Picture character terms and strings