Calls to CEEDAYS, CEEDATE, and CEEDYWK for C or C++

/*Module/File Name:  EDCDT4   */
 /**********************************************************/
 /*                                                        */
 /*Function       : CEEDAYS - convert date to Lilian date  */
 /*               : CEEDATE - convert Lilian date to date  */
 /*               : CEEDYWK - find day-of-week from Lilian */
 /*               :                                        */
 /*CEEDAYS is passed the calander date "11/09/92". The date*/
 /*is originally in YYMMD format and conversion to Lilian  */
 /*format takes place. On return, a varying number of days */
 /*is added to or subtracted from the Lilian date.         */
 /*CEEDATE is called to convert the Lilian dates to the    */
 /*calendar format "MM/DD/YY".                             */
 /*CEEDYWK is called to return the day of the week for     */
 /*each derived Lilian date.                               */
 /*                                                        */
 /*The results are tested for accuracy.                    */
 /*                                                        */
 /**********************************************************/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>
#include <leawi.h>
#include <ceeedcct.h>
  char PastFuture;
  int NumberOfDays[5] = { 80, 20, 10, 5, 4};
  int i;
void main ()
{
  _CHAR80 chrdate;
  _VSTRING  picstr;
  _VSTRING CurrentDate;
  _INT4 Current_Lilian;
  _INT4 Displaced_Lilian;
  _INT4 WeekDay;
  _INT4 ChkWeekDay[5] = { 6, 1, 5, 4, 6 };
  _FEEDBACK FC;
  char Entered_Date[8];
  _INT4 dest=2;

  struct tm *timeptr;
  char   Current_Date[6];
  time_t current_time;
  char *ChkDates[] = {
                  "08/21/92",
                  "11/29/92",
                  "11/19/92",
                  "11/04/92",
                  "11/13/92",
                 };
  /**********************************************************/
  /* Set current date to 11/09/92 in YYMMDD format          */
  /**********************************************************/

   strncpy (CurrentDate.string,"921109",6);
   CurrentDate.length = 6;

  /***************************************************************/
  /* The date picstr must be adjusted to fit the current date    */
  /* format.                                                     */
  /***************************************************************/
   strncpy (picstr.string,"YYMMDD",6);
   picstr.length = 6;
  /**************************************************************/
  /*Call CEEDAYS to convert the date in Current_Date to its     */
  /*corresponding Lilian date format.                           */
  /**************************************************************/
   CEEDAYS ( &CurrentDate, &picstr , &Current_Lilian , &FC );
   if ( _FBCHECK (FC , CEE000) != 0 )
     {
      printf ("Error in converting current date.\n");
      CEEMSG(&FC, &dest, NULL);
      exit(99);
     }

  /**************************************************************/
  /*Modify the date picstr to the familiar MM/DD/YY format.     */
  /**************************************************************/
   strncpy (picstr.string,"MM/DD/YY",8);
   picstr.length = 8;

  /*************************************************************/
  /* In the following loop, add or subtract the number         */
  /* of days in each element of the NumberOfDays array to the  */
  /* Lilian date.  Determine the day of the week for each      */
  /* Lilian date and convert each date back to "MM/DD/YY"      */
  /* format. Issue a message if anything goes wrong.           */
  /*************************************************************/
   for (i=0; i < 5; i++)
    {
     if (i == 0 || i == 3)
        Displaced_Lilian = Current_Lilian - NumberOfDays[i];
     else
        Displaced_Lilian = Current_Lilian + NumberOfDays[i];
   /************************************************************/
   /*Call CEEDATE to convert the Lilian dates to MM/DD/YY      */
   /*format.                                                   */
   /************************************************************/
     CEEDATE ( &Displaced_Lilian, &picstr , chrdate , &FC );
     if ( _FBCHECK (FC , CEE000) == 0 )
     {
        chrdate[8] = '\0';
   /************************************************************/
   /*Compare the dates to an array of expected values.         */
   /*Issue an error message if any conversion is incorrect.    */
   /************************************************************/
        if ( memcmp ( &chrdate, ChkDates[i] , 8) != 0)
          printf (
           "Error  in returned date %8s for displacement %d\n",
              chrdate,NumberOfDays[i]);

   /****************************************************************/
   /*Call CEEDYWK to return the day-of-the-week value (1 thru 7)   */
   /*for each calculated Lilian date. Compare results to an array  */
   /*of expected returned values and issue an error message for any*/
   /*incorrect values.                                             */
   /****************************************************************/
        CEEDYWK ( &Displaced_Lilian , &WeekDay , &FC );
        if ( _FBCHECK (FC , CEE000) == 0 )
        {
          if ( WeekDay != ChkWeekDay[i])
           printf ( "Error in day of the week for %s\n",
                    chrdate);
        }
        else
        {
          printf ("Error finding day of the week\n");
          CEEMSG(&FC, &dest, NULL);
        }
     }
     else
     {
       printf ( "Error converting Lilian date to date.\n" );
       CEEMSG(&FC, &dest, NULL);
     }
    } /* for loop */
}