/* Demonstration of bug in (probably) mktime */
/* the returned seconds is not correct for the date and time enetred in the
/* structure below.
/* Sept 97 00:44:36
*/

#include <stdlib.h>
#include <stdio.h>
#include <time.h>


main(int argc, char *argv[])
{
struct tm *pdtm;/* disconnect time*/
struct tm *loctime;

time_t disconnecttime;

pdtm = (struct tm *) malloc(sizeof(struct tm) );

pdtm -> tm_sec = 36;
pdtm -> tm_min = 44;
pdtm -> tm_hour = 0;
pdtm -> tm_mday = 1;
pdtm -> tm_mon = 0;
pdtm -> tm_year = 97;
pdtm -> tm_isdst = -1;/* daylight savings time n.a. */
/* the following are not implemented (see /usr/include/time.h) */
/* pdtm -> tm_gmtoff = 0;*/
/* strcp(pdtm -> tm_zone, "");/* time zone 3 letters */

fprintf(stdout, "DISCONNECT:\n");
fprintf(stdout, "pdtm->tm_year=%d\n", pdtm -> tm_year);
fprintf(stdout, "pdtm->tm_mon=%d\n", pdtm -> tm_mon);
fprintf(stdout, "pdtm->tm_mday=%d\n", pdtm -> tm_mday);
fprintf(stdout, "pdtm->tm_hour=%d\n", pdtm -> tm_hour);
fprintf(stdout, "pdtm->tm_min=%d\n", pdtm -> tm_min);
fprintf(stdout, "pdtm->tm_sec=%d\n", pdtm -> tm_sec);
fprintf(stdout, "pdtm->tm_isdst=%d\n", pdtm -> tm_isdst);

disconnecttime = mktime(( struct tm *) pdtm);

fprintf(stdout, "AFTER mktime structure pdtm:\n");
fprintf(stdout, "pdtm->tm_year=%d\n", pdtm -> tm_year);
fprintf(stdout, "pdtm->tm_mon=%d\n", pdtm -> tm_mon);
fprintf(stdout, "pdtm->tm_mday=%d\n", pdtm -> tm_mday);
fprintf(stdout, "pdtm->tm_hour=%d\n", pdtm -> tm_hour);
fprintf(stdout, "pdtm->tm_min=%d\n", pdtm -> tm_min);
fprintf(stdout, "pdtm->tm_sec=%d\n", pdtm -> tm_sec);
fprintf(stdout, "pdtm->tm_isdst=%d\n", pdtm -> tm_isdst);

fprintf(stdout, "disconnect time time_t seconds=%lu\n", disconnecttime);

/* Convert it to local time representation. */
     
/* Print out the date and time in the standard format. */

loctime = localtime (&disconnecttime);

fputs (asctime (loctime), stdout);

/* Print it out in a nice format. */
/*strftime (buffer, SIZE, "Today is %A, %B %d.\n", disconnecttime);
/*fputs (buffer, stdout);
/*strftime (buffer, SIZE, "The time is %I:%M %p.\n", disconnecttime);
/*fputs (buffer, stdout);
*/
    
}/* end main */


