gmt_mktime.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* Copyright 2004 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/* This code placed in the public domain by Mark W. Eichin */
#include <stdio.h>
#include <k5-int.h>
#ifdef HAVE_SYS_TYPES_H
#endif
#ifdef HAVE_SYS_TIME_H
#ifdef TIME_WITH_SYS_TIME
#include <time.h>
#endif
#else
#include <time.h>
#endif
/* take a struct tm, return seconds from GMT epoch */
/* like mktime, this ignores tm_wday and tm_yday. */
/* unlike mktime, this does not set them... it only passes a return value. */
static const int days_in_month[12] = {
0, /* jan 31 */
31, /* feb 28 */
59, /* mar 31 */
90, /* apr 30 */
120, /* may 31 */
151, /* jun 30 */
181, /* jul 31 */
212, /* aug 31 */
243, /* sep 30 */
273, /* oct 31 */
304, /* nov 30 */
334 /* dec 31 */
};
time_t gmt_mktime(t)
struct tm* t;
{
assert_time(t->tm_mon>=0);
assert_time(t->tm_hour>=0);
assert_time(t->tm_min>=0);
assert_time(t->tm_sec>=0);
/* add in leap day for all previous years */
/* add in leap day for this year */
return accum;
}