CEEDAYS—Convert date to Lilian format

CEEDAYS converts a string representing a date into a Lilian format, which represents a date as the number of days from the beginning of the Gregorian calendar. CEEDAYS converts the specified input_char_date to a number representing the number of days since day one in the Lilian format: Friday, 14 October, 1582.

The inverse of CEEDAYS is CEEDATE, which converts output_Lilian_date from Lilian format to character format.

Do not use CEEDAYS in combination with COBOL intrinsic functions unless the programs are compiled with the INTDATE(LILIAN) compiler option. Use CEECBLDY for COBOL programs that use intrinsic functions and that are compiled with INTDATE(ANSI).

To handle dates earlier than 1601, it is possible to add 4000 to each year, convert to Lilian, calculate, subtract 4000 from the result, and then convert back to character format.

By default, 2-digit years lie within the 100-year range starting 80 years prior to the system date. Thus, in 1995, all 2-digit years represent dates between 1915 and 2014, inclusive. This default range is changed by using the callable service CEESCEN.
Read syntax diagramSkip visual syntax diagram
Syntax

>>-CEEDAYS--(--input_char_date--,--picture_string--,------------>

>--output_Lilian_date--,--fc--)--------------------------------><

input_char_date (input)
A halfword length-prefixed character string (VSTRING), representing a date or timestamp, in a format conforming to that specified by picture_string.

The character string must contain between 5 and 255 characters, inclusive. input_char_date can contain leading or trailing blanks. Parsing for a date begins with the first nonblank character (unless the picture string itself contains leading blanks, in which case CEEDAYS skips exactly that many positions before parsing begins).

After parsing a valid date, as determined by the format of the date specified in picture_string, CEEDAYS ignores all remaining characters. Valid dates range between and include 15 October 1582 to 31 December 9999. See Table 1 for a list of valid picture character terms that can be specified in input_char_date.

picture_string (input)
A halfword length-prefixed character string (VSTRING), indicating the format of the date specified in input_char_date.

Each character in the picture_string corresponds to a character in input_char_date. For example, if you specify MMDDYY as the picture_string, CEEDAYS reads an input_char_date of 060288 as 02 June 1988.

If delimiters such as a slash (/) appear in the picture string, leading zeros can be omitted. For example, the following calls to CEEDAYS, would each assign the same value, 148155 (02 June 1988), to lildate.

CALL CEEDAYS('6/2/88'  , 'MM/DD/YY', lildate, fc);
CALL CEEDAYS('06/02/88', 'MM/DD/YY', lildate, fc);
CALL CEEDAYS('060288'  , 'MMDDYY'  , lildate, fc);
CALL CEEDAYS('88154'   , 'YYDDD'   , lildate, fc);
CALL CEEDAYS('1988154' , 'YYYYDDD' , lildate, fc);

Whenever characters such as colons or slashes are included in the picture_string (such as HH:MI:SS YY/MM/DD), they count as placeholders but are otherwise ignored. See Table 1 for a list of valid picture character terms and Table 2 for examples of valid picture strings.

If picture_string includes a Japanese Era symbol <JJJJ>, the YY position in input_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. See also Table 3 for a list of Japanese Eras supported by CEEDATE.

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

output_Lilian_date (output)
A 32-bit binary integer representing the Lilian date, the number of days since 14 October 1582. For example, 16 May 1988 is day number 148138.

If input_char_date does not contain a valid date, output_Lilian_date is set to 0 and CEEDAYS terminates with a non-CEE000 symbolic feedback code.

Date calculations are performed easily on the output_Lilian_date, because it is an integer. Leap year and end-of-year anomalies do not affect the calculations.

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.
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 not valid.
CEE2ED 3 2509 Tbe era passed to CEEDAYS or CEESECS was not recognized.
CEE2EH 3 2513 The input date was not within the supported range.
CEE2EL 3 2517 The month value was not recognized.
CEE2EM 3 2518 An incorrect picture string was specified.
CEE2EO 3 2520 CEEDAYS detected non-numeric data in a numeric field, or the date string did not match the picture string.
CEE2EP 3 2521 The year-within-era value passed to CEEDAYS or CEESECS was zero.

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.
  • z/OS UNIX consideration—In multithread applications, CEEDAYS applies to the enclave.

For more information

Examples

  1. Following is an example of CEEDAYS called by C/C++.
    /*Module/File Name: EDCDAYS   */
    
    #include <leawi.h>
    #include <stdio.h>
    #include <string.h>
    #include <stdlib.h>
    #include <ceeedcct.h>
    
    int main(void) {
    
       _FEEDBACK fc;
       _INT4 lil_date1,lil_date2;
       _VSTRING date,date_pic;
    
       /* use CEEDAYS to get the Lilian format */
       strcpy(date.string,"05/14/64");
       date.length = strlen(date.string);
       strcpy(date_pic.string,"MM/DD/YY");
       date_pic.length = strlen(date_pic.string);
    
       CEEDAYS(&date,&date_pic,&lil_date1,&fc);
       if ( _FBCHECK ( fc , CEE000 ) != 0 ) {
          printf("CEEDAYS failed with message number %d\n",
                 fc.tok_msgno);
          exit(2999);
       }
    
       /* use CEEDAYS to get the Lilian format */
       strcpy(date.string,"August 14, 1966");
       date.length = strlen(date.string);
       strcpy(date_pic.string,"Mmmmmmmmmmmz DD, YYYY");
       date_pic.length = strlen(date_pic.string);
    
       CEEDAYS(&date,&date_pic,&lil_date2,&fc);
       if ( _FBCHECK ( fc , CEE000 ) != 0 ) {
          printf("CEEDAYS failed with message number %d\n",
                 fc.tok_msgno);
          exit(2999);
       }
    
       /* subtract the two Lilian dates to find out */
       /* difference in days */
       printf("The number of days between"
       " May 14, 1964 and August 14, 1966"
       " is: %d\n",lil_date2 - lil_date1);
    }
  2. Following is an example of CEEDAYS called by COBOL.
    CBL LIB,QUOTE
          *Module/File Name: IGZTDAYS
          *******************************************
          **                                       **
          ** Function: CEEDAYS - convert date to   **
          **                     Lilian format     **
          **                                       **
          *******************************************
           IDENTIFICATION DIVISION.
           PROGRAM-ID. CBLDAYS.
           DATA DIVISION.
           WORKING-STORAGE SECTION.
           01  CHRDATE.
               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 CHRDATE.
           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  LILIAN                  PIC S9(9) BINARY.
           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.
          *************************************************
          ** Specify input date and length               **
          *************************************************
               MOVE 16 TO Vstring-length of CHRDATE.
               MOVE "1 January 2000"
                   TO Vstring-text of CHRDATE.      
          *************************************************
          ** Specify a picture string that describes     **
          ** input date, and the picture string's length.**
          *************************************************
               MOVE 25 TO Vstring-length of PICSTR.
               MOVE "ZD Mmmmmmmmmmmmmmz YYYY"
                       TO Vstring-text of PICSTR.
    
          *************************************************
          ** Call CEEDAYS to convert input date to a     **
          ** Lilian date                                 **
          *************************************************
               CALL "CEEDAYS" USING CHRDATE, PICSTR,
                                    LILIAN, FC.
    
          *************************************************
          ** If CEEDAYS runs successfully, display result**
          *************************************************
               IF  CEE000 of FC  THEN
                   DISPLAY Vstring-text of CHRDATE
                       " is Lilian day: " LILIAN
               ELSE
                   DISPLAY "CEEDAYS failed with msg "
                       Msg-No of FC UPON CONSOLE
                   STOP RUN
               END-IF.
    
               GOBACK.
  3. Following is an example of CEEDAYS called by PL/I.
    *PROCESS MACRO;
     /*Module/File Name: IBMDAYS                        */
     /***************************************************/
     /**                                               **/
     /** Function     : CEEDAYS - Convert date to      **/
     /**                          Lilian format        **/
     /**                                               **/
     /** This example converts two dates to the Lilian **/
     /** format in order to calculate the number of    **/
     /** days between them.                            **/
     /**                                               **/
     /***************************************************/
    
     PLIDAYS: PROC OPTIONS(MAIN);
    
        %INCLUDE  CEEIBMAW;
        %INCLUDE  CEEIBMCT;
    
        DCL CHRDATE  CHAR(255) VARYING;
        DCL CHRD2    CHAR(255) VARYING;
        DCL PICSTR   CHAR(255) VARYING;
        DCL PICST2   CHAR(255) VARYING;
        DCL LILIAN   REAL FIXED BINARY(31,0);
        DCL LIL2     REAL FIXED BINARY(31,0);
        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);
    
        /* First date to be converted to Lilian format   */
        CHRDATE = '5/7/69';
    
        /* Picture string of first input date            */
        PICSTR = 'ZM/ZD/YY';
    
        /* Call CEEDAYS to convert input date to the     */
        /*    Lilian format                              */
        CALL CEEDAYS ( CHRDATE , PICSTR , LILIAN , FC );
        IF  FBCHECK( FC, CEE000)  THEN  DO;
           PUT SKIP LIST( 'The Lilian date for ' || CHRDATE
              || ' is ' || LILIAN );
           END;
        ELSE  DO;
           DISPLAY( 'CEEDAYS failed with msg '
              || FC.MsgNo );
           STOP;
           END;
    
        /* Second date to be converted to Lilian format  */
        CHRD2 = '1 January 2000';
    
        /* Picture string of second input date           */
        PICST2 = 'ZD Mmmmmmmmmmmmmmz YYYY';
    
        /* Call CEEDAYS to convert input date to the     */
        /*    Lilian format                              */
        CALL CEEDAYS ( CHRD2 , PICST2 , LIL2 , FC );
        IF  FBCHECK( FC, CEE000)  THEN  DO;
           PUT SKIP LIST( 'The Lilian date for ' || CHRD2
              || ' is ' || LIL2 );
           END;
        ELSE  DO;
           DISPLAY( 'CEEDAYS failed with msg '
              || FC.MsgNo );
           STOP;
           END;
    
        /* Subtract the two Lilian dates to find out     */
        /*    the difference in days between the two     */
        /*    input dates                                */
        PUT SKIP LIST( 'The number of days between '
           || CHRDATE || ' and ' || CHRD2 || ' is'
           || LIL2 - LILIAN || '.');
    
     END PLIDAYS;