CEEDATM: convert seconds to character time stamp

CEEDATM converts a number that represents the number of seconds since 00:00:00 14 October 1582 to a character string. The output is a character string time stamp such as 1988/07/26 20:37:00.

CALL CEEDATM syntax

Read syntax diagramSkip visual syntax diagramCALL"CEEDATM"USINGinput_seconds,picture_string,output_timestamp,fc.
input_seconds (input)
A 64-bit long floating-point number that represents the number of seconds since 00:00:00 on 14 October 1582, not counting leap seconds.

For example, 00:00:01 on 15 October 1582 is second number 86,401 (24*60*60 + 01). The valid range of input_seconds is 86,400 to 265,621,679,999.999 (23:59:59.999 31 December 9999).

picture_string (input)
A halfword length-prefixed character string that represents the required format of output_timestamp, for example, MM/DD/YY HH:MI AP.

Each character in the picture_string represents a character in output_timestamp. If delimiters such as a slash (/) are used in the picture string, they are copied as is to output_timestamp.

If picture_string includes the Japanese Era symbol <JJJJ>, the YY position in output_timestamp represents the year within Japanese Era.

output_timestamp (output)
A fixed-length 80-character string that is the result of converting input_seconds to the format specified by picture_string.

If necessary, the output is truncated to the length of output_timestamp.

If input_seconds is invalid, output_timestamp is set to all blanks and CEEDATM terminates with a non-CEE000 symbolic feedback code.

fc (output)
A 12-byte feedback code (optional) that indicates the result of this service.
Table 1. CEEDATM symbolic conditions
Symbolic feedback code Severity Message number Message text
CEE000 0 -- The service completed successfully.
CEE2E9 3 2505 The input_seconds value in a call to CEEDATM or CEESECI was not within the supported range.
CEE2EA 3 2506 An era (<JJJJ>, <CCCC>, or <CCCCCCCC>) was used in a picture string passed to CEEDATM, but the input number-of-seconds value was not within the supported range. The era could not be determined.
CEE2EM 3 2518 An invalid picture string was specified in a call to a date or time service.
CEE2EV 2 2527 The time-stamp string returned by CEEDATM was truncated.
CEE2F6 1 2534 Insufficient field width was specified for a month or weekday name in a call to CEEDATE or CEEDATM. Output set to blanks.

Usage note: The inverse of CEEDATM is CEESECS, which converts a time stamp to number of seconds.

Example


*************************************************
**                                             **
** Function: CEEDATM - convert seconds to      **
**                     character time stamp    **
**                                             **
** In this example, a call is made to CEEDATM  **
** to convert a date represented in Lilian     **
** seconds (the number of seconds since        **
** 00:00:00 14 October 1582) to a character    **
** format (such as 06/02/88 10:23:45). The     **
** result is displayed.                        **
**                                             **
*************************************************
 IDENTIFICATION DIVISION.
 PROGRAM-ID. CBLDATM.
 DATA DIVISION.
 WORKING-STORAGE SECTION.
 01  DEST          PIC S9(9) BINARY VALUE 2.
 01  SECONDS                 COMP-2.
 01  IN-DATE.
     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 IN-DATE.
 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  TIMESTP                 PIC X(80).
 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-CBLDATM.
*************************************************
** Call CEESECS to convert time stamp of 6/2/88**
**     at 10:23:45 AM to Lilian representation **
*************************************************
     MOVE 20 TO Vstring-length of IN-DATE.
     MOVE '06/02/88 10:23:45 AM'
         TO Vstring-text of IN-DATE.
     MOVE 20 TO Vstring-length of PICSTR.
     MOVE 'MM/DD/YY HH:MI:SS AP'
         TO Vstring-text of PICSTR.
     CALL 'CEESECS' USING IN-DATE, PICSTR,
                          SECONDS, FC.

*************************************************
** If CEESECS runs successfully, display result**
*************************************************
     IF  CEE000 of FC  THEN
         DISPLAY Vstring-text of IN-DATE
             ' is Lilian second:  ' SECONDS
     ELSE
         DISPLAY 'CEESECS failed with msg '
             Msg-No of FC UPON CONSOLE
         STOP RUN
     END-IF.

*************************************************
** Specify required format of the output.       **
*************************************************
     MOVE 35 TO Vstring-length OF PICSTR.
     MOVE 'ZD Mmmmmmmmmmmmmmz YYYY at HH:MI:SS'
             TO Vstring-text OF PICSTR.

*************************************************
** Call CEEDATM to convert Lilian seconds to   **
**     a character time stamp                  **
*************************************************
     CALL 'CEEDATM' USING SECONDS, PICSTR,
                          TIMESTP, FC.

*************************************************
** If CEEDATM runs successfully, display result**
*************************************************
     IF CEE000 of FC  THEN
         DISPLAY 'Input seconds of ' SECONDS
             ' corresponds to: ' TIMESTP
     ELSE
         DISPLAY 'CEEDATM failed with msg '
             Msg-No of FC UPON CONSOLE
         STOP RUN
     END-IF.

     GOBACK.

The following tables show sample output of CEEDATM.

input_seconds picture_string output_timestamp
12,799,191,601.000 YYMMDD 880516
HH:MI:SS 19:00:01
YY-MM-DD 88-05-16
YYMMDDHHMISS 880516190001
YY-MM-DD HH:MI:SS 88-05-16 19:00:01
YYYY-MM-DD HH:MI:SS AP 1988-05-16 07:00:01 PM
12,799,191,661.986 DD Mmm YY 16 May 88
DD MMM YY HH:MM 16 MAY 88 19:01
WWW, MMM DD, YYYY MON, MAY 16, 1988
ZH:MI AP 7:01 PM
Wwwwwwwwwz, ZM/ZD/YY Monday, 5/16/88
HH:MI:SS.99 19:01:01.98
12,799,191,662.009 YYYY 1988
YY 88
Y 8
MM 05
ZM 5
RRRR
input_seconds picture_string output_timestamp
12,799,191,662.009 MMM MAY
Mmm May
Mmmmmmmmmm May
Mmmmmmmmmz May
DD 16
ZD 16
DDD 137
HH 19
ZH 19
MI 01
SS 02
99 00
999 009
AP PM
WWW MON
Www Mon
Wwwwwwwwww Monday
Wwwwwwwwwz Monday

Example: date-and-time picture strings

Related references  
Picture character terms and strings