mktime() failure vs 31-DEC-1969 23:59:59 GMT

tomp at zk3.dec.com tomp at zk3.dec.com
Tue Feb 13 21:19:36 UTC 1996


This has probably been discussed before, but perhaps someone can bring
me up to speed.  The standards for mktime() define a return value of
(time_t)-1 as indicating that the time specified cannot be
represented.  However, a return value of -1 is also a valid time_t
corresponding to 31-DEC-1969 23:59:59 GMT.  How do we distinguish
between the two?  Here's a sample program:

#include <time.h>
#include <strings.h>
#include <string.h>
#include <stdio.h>
main()
{
    struct tm   stm;
    time_t      timet;

    memset(&stm, 0, sizeof(stm));
    putenv("TZ=GMT0");

    stm.tm_sec = 59;
    stm.tm_min = 59;
    stm.tm_hour = 23;
    stm.tm_mday = 31;
    stm.tm_mon = 11;
    stm.tm_year = 69;
    stm.tm_isdst = -1;

    timet = mktime(&stm);
    printf("timet = %ld\n",timet);
}

thanks,
- Tom



More information about the tz mailing list