CEEDATE—Convert Lilian date to character format

CEEDATE converts a number representing a Lilian date to a date written in character format. The output is a character string, such as 1993/09/09.

Do not use CEEDATE in combination with COBOL intrinsic functions.

The inverse of CEEDATE is CEEDAYS, which converts character dates to the Lilian format.

CEEDATE 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

>>-CEEDATE--(--input_Lilian_date--,--picture_string--,---------->

>--output_char_date--,--fc--)----------------------------------><

input_Lilian_date (input)
A 32-bit integer representing the Lilian date. The Lilian date is the number of days since 14 October 1582. For example, 16 May 1988 is Lilian day number 148138. The valid range of Lilian dates is 1 to 3,074,324 (15 October 1582 to 31 December 9999).
picture_string (input)
A halfword length-prefixed character string (VSTRING), representing the desired format of output_char_date, for example MM/DD/YY. Each character in picture_string represents a character in output_char_date. If delimiters such as the slash (/) appear in the picture string, they are copied to output_char_date.

See Table 1 for a list of valid picture characters, and Table 2 for examples of valid picture strings.

If picture_string is null or blank, CEEDATE 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 format would be MM/DD/YY. If the current COUNTRY value is FR (France), the date format would be MM/DD/YY HH:MM:SS AM (or PM), for example: 09/09/93 4:56:29 PM. This default mechanism makes it easy for translation centers to specify the preferred date, and for applications and library routines to use this format automatically.

If picture_string includes a Japanese Era symbol <JJJJ>, the YY position in output_char_date is replaced by the year number within the Japanese Era. For example, the year 1988 equals the Japanese year 63 in the Showa era. See Table 2 for an additional example. Also see Table 3 for a list of Japanese Eras supported by CEEDATE.

If picture_string includes a era symbol <CCCC> or <CCCCCCCC>, the YY position in output_char_date is replaced by the year number within the era. See Table 2 for an example.

output_char_date (output)
A fixed-length 80-character string (VSTRING), is the result of converting input_Lilian_date to the format specified by picture_string. See Table 1 for sample output dates. If input_Lilian_date is not valid, output_char_date is set to all blanks. CEEDATE 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.
CEE2EG 3 2512 The Lilian date value was not within the supported range.
CEE2EM 3 2518 An incorrect picture string was specified.
CEE2EQ 3 2522 <JJJJ>, <CCCC> or <CCCCCCCC> was used in a picture string passed to CEEDATE, but the Lilian date value was not within the supported range. The Era could not be determined.
CEE2EU 2 2526 The date string returned by CEEDATE was truncated.

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, CEEDATE applies to the enclave.

For more information

  • See the INTDATE COBOL compiler installation option in the appropriate version of the COBOL programming guide in the COBOL library at Enterprise COBOL for z/OS library for information about how to get Lilian integer values from COBOL intrinsic functions that are compatible with the Language Environment callable services CEEDAYS and CEEDATE.
  • See CEEDAYS—Convert date to Lilian format for more information about the CEEDAYS callable service.
  • See COUNTRY for more information about the COUNTRY runtime option.
  • See CEEFMDA—Get default date format for information about how to get the default format for a given country code.

Examples

  1. Following is an example of CEEDATE called by C/C++.
    /*Module/File Name: EDCDATE   */
    
    #include <leawi.h>
    #include <stdio.h>
    #include <string.h>
    #include <stdlib.h>
    #include <ceeedcct.h>
    
    int main(void) {
    
       _FEEDBACK fc;
       _INT4 lil_date = 139370;   /* May 14, 1964 */
       _VSTRING date_pic,date;
       _CHAR80 date_out;
    
       strcpy(date_pic.string,
         "The date is Wwwwwwwwwz, Mmmmmmmmmz ZD, YYYY");
       date_pic.length = strlen(date_pic.string);
    
       CEEDATE(&lil_date,&date_pic,date_out,&fc);
       if ( _FBCHECK ( fc , CEE000 ) != 0 ) {
          printf("CEEDATE failed with message number %d\n",
                  fc.tok_msgno);
          exit(2999);
       }
       printf("%.80s\n",date_out);
    }
  2. Following is an example of CEEDATE called by COBOL.
    CBL LIB,QUOTE
          *Module/File Name: IGZTDATE
          ************************************************
          **                                            **
          ** Function: CEEDATE - convert Lilian date to **
          **                     character format       **
          **                                            **
          ** In this example, a call is made to CEEDATE **
          ** to convert a Lilian date (the number of    **
          ** days since 14 October 1582) to a character **
          ** format (such as 6/22/88). The result is    **
          ** displayed.  The Lilian date is obtained    **
          ** via a call to CEEDAYS.                     **
          **                                            **
          ************************************************
           IDENTIFICATION DIVISION.
           PROGRAM-ID. CBLDATE.
           DATA DIVISION.
           WORKING-STORAGE SECTION.
           01  LILIAN                  PIC S9(9) BINARY.
           01  CHRDATE                 PIC X(80).
           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  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-CBLDAYS.
          *************************************************
          ** Call CEEDAYS to convert date of 6/2/88 to   **
          **     Lilian representation                   **
          *************************************************
               MOVE 6 TO Vstring-length of IN-DATE.
               MOVE "6/2/88" TO Vstring-text of IN-DATE(1:6).
               MOVE 8 TO Vstring-length of PICSTR.
               MOVE "MM/DD/YY" TO Vstring-text of PICSTR(1:8).
               CALL "CEEDAYS" USING IN-DATE, PICSTR,
                                    LILIAN, FC.
    
          *************************************************
          ** If CEEDAYS runs successfully, display result**
          *************************************************
               IF  CEE000 of FC  THEN
                   DISPLAY Vstring-text of IN-DATE
                       " is Lilian day: " LILIAN
               ELSE
                   DISPLAY "CEEDAYS failed with msg "
                       Msg-No of FC UPON CONSOLE
                   STOP RUN
               END-IF.
    
          *************************************************
          ** Specify picture string that describes the   **
          **  desired format of the output from CEEDATE, **
          **  and the picture string's length.           **
          *************************************************
               MOVE 23 TO Vstring-length OF PICSTR.
               MOVE "ZD Mmmmmmmmmmmmmmz YYYY" TO
                            Vstring-text OF PICSTR(1:23).
    
          *************************************************
          ** Call CEEDATE to convert the Lilian date     **
          **     to  a picture string.                   **
          *************************************************
               CALL "CEEDATE" USING LILIAN, PICSTR,
                                    CHRDATE, FC.
          *************************************************
          ** If CEEDATE runs successfully, display result**
          *************************************************
               IF CEE000 of FC  THEN
                   DISPLAY "Input Lilian date of " LILIAN
                       " corresponds to:  " CHRDATE
               ELSE
                   DISPLAY "CEEDATE failed with msg "
                       Msg-No of FC UPON CONSOLE
                   STOP RUN
               END-IF.
    
               GOBACK.
  3. Following is an example of CEEDATE called by PL/I.
    *PROCESS MACRO;
     /*Module/File Name: IBMDATE                    */
     /***********************************************/
     /**                                            */
     /** Function: CEEDATE - convert Lilian date to */
     /**                     character format       */
     /**                                            */
     /** In this example, a call is made to CEEDATE */
     /** to convert a date in the Lilian format     */
     /** (the number of days since 14 October 1582) */
     /** to a date in character format. This date   */
     /** is then printed out.                       */
     /**                                            */
     /********************************************* */
     PLIDATE: PROC OPTIONS(MAIN);
    
        %INCLUDE  CEEIBMAW;
        %INCLUDE  CEEIBMCT;
    
        DCL LILIAN  REAL FIXED BINARY(31,0) ;
        DCL PICSTR  CHAR(255) VARYING;
        DCL CHRDATE 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);
    
        LILIAN = 152385;  /* input date in Lilian format */
        /* picture string that describes how converted   */
        /* date is to be formatted                       */
        PICSTR = 'ZD Mmmmmmmmmmmmmmz YYYY';
    
        /* Call CEE3DATE to convert input Lilian date to */
        /* a date in the character format specified in   */
        /* PICSTR                                        */
        CALL CEEDATE ( LILIAN , PICSTR , CHRDATE , FC );
    
        /* Print results if call to CEEDATE succeeds     */
        IF  FBCHECK( FC, CEE000)  THEN  DO;
            PUT SKIP LIST( 'Lilian day ' || LILIAN
               || ' is equivalent to ' || CHRDATE );
           END;
        ELSE  DO;
           DISPLAY( 'CEEDATE failed with msg '
              || FC.MsgNo );
           STOP;
           END;
    
     END PLIDATE;

Table 1 shows the sample output from CEEDATE.

Table 1. Sample output of CEEDATE
input_Lilian_date picture_string output_char_date
148138
YY
YYMM
YY-MM
YYMMDD
YYYYMMDD
YYYY-MM-DD
YYYY-ZM-ZD

 JJJJ  YY.MM.DD

 CCCC  YY.MM.DD
88
8805
88-05
880516 
19880516
1988-05-16
1988-5-16 
Showa 63.05.16
(in a DBCS string) 
Min Guo 77.05.16
(in a DBCS string)
148139
MM
MMDD
MM/DD
MMDDYY
MM/DD/YYYY
ZM/DD/YYYY
05
0517
05/17
051788
05/17/1988
5/17/1988
148140
DD
DDMM
DDMMYY
DD.MM.YY
DD.MM.YYYY
DD Mmm YYYY
18
1805
180588
18.05.88
18.05.1988
18 May 1988
148141
DDD
YYDD
YY.DDD
YYYY.DDD
140
88148
88.140
1988.140
148142
YY/MM/DD HH:MI:SS.99

YYYY/ZM/ZD ZH:MI AP
88/05/20 
00:00:00.00
1988/5/20 0:00 AM
148143
WWW., MMM DD, YYYY

Www.,  Mmm DD, YYYY
Wwwwwwwwww  Mmmmmmmmmm
 DD, YYYY

Wwwwwwwwwz, Mmmmmmmmmz
 DD, YYYY
SAT., MAY 21, 
1988 
Sat., May 21, 1988
Saturday␢␢,
May␢␢␢␢␢␢␢ 21, 
1988
Saturday, May 21,
1988