IBM Support

Program Examples for ILE IBM C/400 Using CEEDAYS, CEEDAYS, and CEEDYWK

Troubleshooting


Problem

This document explains the use and explanation of what a Lilian date is and how it is used in CEE APIs.

Resolving The Problem

Question:
Why does the Lilian date start on October 14, 1582? The PC time functions are all based on January 1, 1970. Why is IBM i using something different?


Answer:
October 14, 1582 is the date the Gregorian calendar was established (by Pope Gregory XIII) as a revision to the Julian calendar.

A Lilian date is the number of days since that base date. Therefore, Lilian date 0 is Oct 14, 1582, Lilian date 1 is Oct 15, 1582, and so on. The CEE bindable date and time APIs make use of Lilian dates.

The following are simple examples put together for a presentation some time ago to illustrate the use of some of the CEE API.
Source CEEDATE1:
#include <stdio.h>
#include <leawi.h>
#include <time.h>

_INT4       lilian_date;
_CHAR       date_string[12];
_FEEDBACK  *fc;
struct tm  *timeptr;
time_t      temp;

int main(void) {

lilian_date = 1;

CEEDATE( &lilian_date, "MM/DD/YYYY", date_string, fc );
printf("Lilian Date %6d is:         %s \n", lilian_date, date_string );

lilian_date = 150000;
CEEDATE( &lilian_date, "MM/DD/YYYY", date_string, fc );
printf("Lilian Date %6d is:         %s \n", lilian_date, date_string );

temp = time(NULL);
timeptr = localtime( &temp );
strftime(date_string,sizeof(date_string)-1,"%x", timeptr );
printf("Today's date is:               %s \n", date_string );

CEEDAYS( date_string, "MM/DD/YY", &lilian_date, fc );
printf("and in Lilian is:              %d  \n", lilian_date );
} 
Compile CRTBNDC  PGM(<yourlib>/CEEDATE1) SRCFILE(<yourlib>/QCSRC)
Call from command line:
CALL CEEDATE1
   Lilian Date      1 is:         10/15/158
   Lilian Date 150000 is:         06/21/199
   Today's date is:               05/07/25 
   and in Lilian is:              161643   
   Press ENTER to end terminal session.    

Source CEEDATE2:
#include <stdio.h>
#include <leawi.h>
#include <ledate.h>

_INT4    lildate;
_FEEDBACK  fc;

main() {

CEEDAYS("50-01-01","YY-MM-DD", &lildate,&fc);
printf("The lildate is : %d\n", lildate);

CEEDAYS("6/2/88","ZM/ZD/YY", &lildate,&fc);
printf("The lildate is : %d\n", lildate);

CEEDAYS("06/02/88","MM/DD/YY", &lildate,&fc);
printf("The lildate is : %d\n", lildate);

CEEDAYS("060288","MMDDYY", &lildate,&fc);
printf("The lildate is : %d\n", lildate);

CEEDAYS("88154","YYDDDD", &lildate,&fc);
printf("The lildate is : %d\n", lildate);

CEEDAYS("9JUNE88","ZDMMMMMMMMZYY", &lildate,&fc);
printf("The lildate is : %d\n", lildate);

CEEDAYS("Showa 63.05.16","<JJJJ> YY.MM.DD", &lildate,&fc);
printf("The lildate is : %d\n", lildate);

}   
Compile using CRTBNDC PGM(<yourlib>/CEEDATE2) SRCFILE(<yourlib>/QCSRC)
Call from command line:
CALL CEEDATE2
The lildate is : 134123             
The lildate is : 148155             
The lildate is : 148155             
The lildate is : 148155             
The lildate is : 148155             
The lildate is : 148162             
The lildate is : 0                  
Press ENTER to end terminal session.

Source CEEDATE3:
#include <stdio.h>
#include <leawi.h>

_INT4     lildate;
_INT4     output_day;
_FEEDBACK  fc;

main() {

for(lildate=143198; lildate < 143250; lildate++)
{

 CEEDYWK(&lildate, &output_day, &fc);
 printf("The day %d of the week for %d\n",output_day,lildate);
}
} 
Compile using CRTBNDC PGM(<yourlib>/CEEDATE3) SRCFILE(<yourlib>/QCSRC)
Call from command line:
CALL CEEDATE3
The day 4 of the week for 143198
The day 5 of the week for 143199
The day 6 of the week for 143200
The day 7 of the week for 143201
The day 1 of the week for 143202
The day 2 of the week for 143203
The day 3 of the week for 143204
The day 4 of the week for 143205
The day 5 of the week for 143206
The day 6 of the week for 143207
The day 7 of the week for 143208
The day 1 of the week for 143209
The day 2 of the week for 143210
The day 3 of the week for 143211
The day 4 of the week for 143212
The day 5 of the week for 143213
The day 6 of the week for 143214
The day 7 of the week for 143215
The day 1 of the week for 143216
The day 2 of the week for 143217
The day 3 of the week for 143218
The day 4 of the week for 143219
The day 5 of the week for 143220
The day 6 of the week for 143221
The day 7 of the week for 143222
The day 1 of the week for 143223
The day 2 of the week for 143224
The day 3 of the week for 143225
The day 4 of the week for 143226
The day 5 of the week for 143227
The day 6 of the week for 143228
The day 7 of the week for 143229
The day 1 of the week for 143230
The day 2 of the week for 143231
The day 3 of the week for 143232
The day 4 of the week for 143233
The day 5 of the week for 143234
The day 6 of the week for 143235
The day 7 of the week for 143236
The day 1 of the week for 143237
The day 2 of the week for 143238
The day 3 of the week for 143239
The day 4 of the week for 143240
The day 5 of the week for 143241
The day 6 of the week for 143242
The day 7 of the week for 143243
The day 1 of the week for 143244
The day 2 of the week for 143245
The day 3 of the week for 143246
The day 4 of the week for 143247
The day 5 of the week for 143248
The day 6 of the week for 143249
Press ENTER to end terminal session.

Source CEEDATE4:
#include <stdio.h>
#include <leawi.h>

_INT4   lildate;
_CHAR   date_string[80];
_FEEDBACK fc;

main() {

signed int date_value =148138;

date_string[0] = '\0';

lildate = date_value;

CEEDATE(&lildate, "MM/DD/YYYY", date_string, &fc);
printf("The date is : %s format MM/DD/YYYY\n", date_string);

CEEDATE(&lildate, "ZM/DD/YYYY", date_string, &fc);
printf("The date is : %s format ZM/DD/YYYY\n", date_string);

CEEDATE(&lildate, "DD.MM.YYYY", date_string, &fc);
printf("The date is : %s format DD.MM.YYYY\n", date_string);

CEEDATE(&lildate, "DD.MM.YY", date_string, &fc);
printf("The date is : %s format DD.MM.YY\n", date_string);

CEEDATE(&lildate, "DD Mmm YYYY", date_string, &fc);
printf("The date is : %s format DD Mmm YYYY\n", date_string);

CEEDATE(&lildate, "YYYYMMDD", date_string, &fc);
printf("The date is : %s format YYYYMMDD\n", date_string);

CEEDATE(&lildate, "YYYY-MM-DD", date_string, &fc);
printf("The date is : %s format YYYY-MM-DD\n", date_string);

CEEDATE(&lildate, "YY/MM/DD HH:MI:SS.999", date_string, &fc);
printf("The date is : %s format YY/MM/DD HH:MI:SS.999\n", date_string);

CEEDATE(&lildate, "WWW., MMM DD, YYYY", date_string, &fc);
printf("The date is : %s format WWW., MMM DD, YYYY\n", date_string);

CEEDATE(&lildate, "Wwwwwwwwwz, Mmmmmmmmmz DD, YYYY", date_string, &fc);
printf("The date is : %s format Wwwwwwwwz, Mmmmmmmmz DD, YYYY\n", date_string);
} 
Compile using CRTBNDC PGM(<yourlib>/CEEDATE4) SRCFILE(<yourlib>/QCSRC)
Call from command line:
CALL CEEDATE4
The date is : 05/16/1988 format MM/DD/YYYY                              
The date is : 5/16/1988 format ZM/DD/YYYY                               
The date is : 16.05.1988 format DD.MM.YYYY                              
The date is : 16.05.88 format DD.MM.YY                                  
The date is : 16 May 1988 format DD Mmm YYYY                            
The date is : 19880516 format YYYYMMDD                                  
The date is : 1988-05-16 format YYYY-MM-DD                              
The date is : 88/05/16 00:00:00.000 format YY/MM/DD HH:MI:SS.999        
The date is : MON., MAY 16, 1988 format WWW., MMM DD, YYYY              
The date is : Monday, May 16, 1988 format Wwwwwwwwz, Mmmmmmmmz DD, YYYY 
Press ENTER to end terminal session.                                    

[{"Type":"MASTER","Line of Business":{"code":"LOB68","label":"Power HW"},"Business Unit":{"code":"BU070","label":"IBM Infrastructure"},"Product":{"code":"SWG60","label":"IBM i"},"ARM Category":[{"code":"a8m3p000000hB4rAAE","label":"API"},{"code":"a8m0z0000000CHtAAM","label":"Programming ILE Languages"}],"ARM Case Number":"","Platform":[{"code":"PF012","label":"IBM i"}],"Version":"All Versions"}]

Historical Number

8135353

Document Information

Modified date:
07 May 2025

UID

nas8N1010190