CEEDATM—Convert seconds to character timestamp

CEEDATM converts a number representing the number of seconds since 00:00:00 14 October 1582 to a character string format. The format of the output is a character string timestamp, for example: 1988/07/26 20:37:00.

The inverse of CEEDATM is CEESECS, which converts a timestamp to number of seconds.

CEEDATM is affected only by the country code setting of the COUNTRY runtime option or CEE3CTY callable service, not the CEESETL callable service or the setlocale() function.
Read syntax diagramSkip visual syntax diagram
Syntax

>>-CEEDATM--(--input_seconds--,--picture_string--,-------------->

>--output_timestamp--,--fc--)----------------------------------><

input_seconds (input)
A 64-bit double floating-point number representing 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 (VSTRING), representing the desired 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 (/) appear in the picture string, they are copied as is to output_timestamp.

See Table 1 for a list of valid picture character terms and Table 2 for examples of valid picture strings.

If picture_string is null or blank, CEEDATM gets picture_string based on the current value of the COUNTRY runtime option. For example, if the current value of the COUNTRY runtime option is US (United States), the date-time format would be "MM/DD/YY HH:MI:SS AP"; if the current COUNTRY value is FR (France), however, the date-time format would be "DD.MM.YYYY HH:MI:SS".

If picture_string includes the Japanese Era symbol <JJJJ>, the YY position in output_timestamp represents the year within Japanese Era. See Table 2 for an example. See Table 3 for a list of Japanese Eras supported by CEEDATM.

If picture_string includes era symbol <CCCC> or <CCCCCCCC>, the YY position in output_timestamp represents the year within the era. See Table 2 for an example.

output_timestamp (output)
A fixed-length 80-character string (VSTRING), 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. See Table 1 for sample output.

If input_seconds is not valid, 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 in some languages, that indicates the result of this service. If you choose to omit this parameter, refer to Invoking callable services for the appropriate syntax to indicate that the feedback code was omitted.
The following symbolic conditions can result from this service:
Code Severity Message number Message text
CEE000 0 The service completed successfully.
CEE2E9 3 2505 The number-of-seconds value was not within the supported range.
CEE2EA 3 2506 <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.
CEE2EV 2 2527 The timestamp string returned by CEEDATM was truncated.
CEE3CF 2 3471 The country code country-code was not valid for CEEFMDT. The default date and time picture string datetime-string was returned.

Usage notes

  • The probable cause for receiving message number 2518 is a picture string that contains a DBCS string that is not valid. You should verify that the data in the picture string is correct.
  • To create a null VSTRING, set the length to zero; the content of the text portion does not matter. To create a blank VSTRING, any length greater than zero can be used; the content of the text portion must be spaces or blanks.
  • z/OS UNIX consideration—In multithread applications, CEEDATM applies to the enclave.

For more information

Examples

  1. Following is an example of CEEDATM called by C/C++.
    /*Module/File Name: EDCDATM   */
    
    #include <leawi.h>
    #include <stdio.h>
    #include <string.h>
    #include <stdlib.h>
    #include <ceeedcct.h>
    
    int main(void) {
    
                 /* September 13, 1991 at 11:23:23 PM */
       _FLOAT8 seconds = 12904183403.0;
       _VSTRING date,date_pic;
       _CHAR80 out_date;
       _FEEDBACK fc;
    
       strcpy(date_pic.string,
       "Mmmmmmmmmmmz DD, YYYY at ZH:MI:.SS AP");
       date_pic.length = strlen(date_pic.string);
    
       CEEDATM(&seconds,&date_pic,out_date,&fc);
       if ( _FBCHECK ( fc , CEE000 ) != 0 ) {
          printf("CEEDATM failed with message number %d\n",
                 fc.tok_msgno);
          exit(2999);
       }
    
       printf("%.80s\n",out_date);
    }
  2. Following is an example of CEEDATM called by COBOL.
    CBL LIB,QUOTE
          *Module/File Name: IGZTDATM
          *************************************************
          **                                             **
          ** Function: CEEDATM - convert seconds to      **
          **                     character timestamp     **
          **                                             **
          ** 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) BINARY.
                       04  Msg-No      PIC S9(4) BINARY.
                   03  Case-2-Condition-ID
                             REDEFINES Case-1-Condition-ID.
                       04  Class-Code  PIC S9(4) BINARY.
                       04  Cause-Code  PIC S9(4) BINARY.
                   03  Case-Sev-Ctl    PIC X.
                   03  Facility-ID     PIC XXX.
               02  I-S-Info            PIC S9(9) BINARY.
    
           PROCEDURE DIVISION.
           PARA-CBLDATM.
          *************************************************
          ** Call CEESECS to convert timestamp 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 desired 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 timestamp                   **
          *************************************************
               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.
  3. Following is an example of CEEDATM called by PL/I.
    *PROCESS MACRO;
     /*Module/File Name: IBMDATM
    
     /****************************************************/
     /**                                                **/
     /** Function: CEEDATM - Convert seconds to         **/
     /**                     character timestamp        **/
     /**                                                **/
     /** In this example, CEEDATM is called to convert  **/
     /** the number of seconds since 00:00:00 14        **/
     /** October 1582 to the character format specified **/
     /** in PICSTR.                                     **/
     /**                                                **/
     /****************************************************/
    
     PLIDATM: PROC OPTIONS(MAIN);
    
        %INCLUDE  CEEIBMAW;
        %INCLUDE  CEEIBMCT;
    
        DCL SECONDS REAL FLOAT DECIMAL(16);
        DCL PICSTR  CHAR(255) VARYING;
        DCL TIMESTP CHAR(80);
        DCL 01 FC,                     /* Feedback token */
               03 MsgSev    REAL FIXED BINARY(15,0),
               03 MsgNo     REAL FIXED BINARY(15,0),
               03 Flags,
                  05 Case      BIT(2),
                  05 Severity  BIT(3),
                  05 Control   BIT(3),
               03 FacID     CHAR(3),    /* Facility ID */
               03 ISI   /* Instance-Specific Information */
                            REAL FIXED BINARY(31,0);
    
        SECONDS = 13166064060; /* Input is Lilian seconds*/
    
        PICSTR = 'ZD Mmmmmmmmmmmmmmz YYYY';  /* Picture  */
              /* string describing desired output format */
    
        /* Call CEEDATM to convert Lilian seconds to     */
        /*    format specified in PICSTR                 */
        CALL CEEDATM ( SECONDS , PICSTR , TIMESTP , FC );
    
        /* If CEEDATM ran successfully, print result     */
        IF  FBCHECK( FC, CEE000)  THEN  DO;
           PUT SKIP LIST(
              'Input Lilian seconds correspond to '
              || TIMESTP);
           END;
        ELSE  DO;
           DISPLAY( 'CEEDATM failed with msg '
              || FC.MsgNo );
           STOP;
           END;
    
      END PLIDATM;

Table 1 shows the sample output of CEEDATM.

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