/*
 * mktime.c
 */


#include<sys/user_config.h>
#include<sys/types.h>
#include<callgate.h>

#include<errno.h>
#include<stdio.h>
#include<string.h>
#include<sys/times.h>
#include<sys/time.h>
#include<time.h>


time_t mktime(struct tm *tm)
{
	static ushort sumMonthDay[13]={0,31,59,90,120,151,181,212,243,273,304,334};	/* 月の日数の合計。 */
	int days;


	days=(tm->tm_year-70)*365;
	days+=(tm->tm_year-1-70)/4;
	days+=sumMonthDay[tm->tm_mon]+tm->tm_mday-1;
	if((tm->tm_year%4==0)&&(tm->tm_mon>2))++days;
	return ((days*24+tm->tm_hour)*60+tm->tm_min)*60+tm->tm_sec-timezone;
}
