Mapper
ouptime.c
Go to the documentation of this file.
1  /*
2  ouptime
3  is called to compute the number of seconds since jan 1 1980 00:00:00.
4  It returns a long integer.
5  */
6 #include <time.h> /* old time component structure */
7 
8 static int mdays[12] = { 0,31,59,90,120,151,181,212,243,273,304,334 } ;
9 
10 long ouptime(int year, int month, int day, int hour, int minute, int second)
11 
12 {
13 int ndays ;
14 long times ;
15 
16 /* COMPUTE TIME IN SECONDS SINCE JAN 1, 1980 00:00:00 */
17 
18  /* number of seconds for years */
19 /* times = 31536000L * (long)(year - 1980) ; */
20  times = 31536000L * (long)(year - 1970) ;
21 /* times += 86400L * (long)((year - 1977)/4); */ /* account for leap years */
22  times += 86400L * (long)((year - 1969)/4); /* account for leap years */
23 
24  /* number of seconds for days in year */
25  ndays = mdays[month-1] + day - 1 ;
26  times += 86400L * (long)ndays ;
27 
28 
29  /* take into account leap years */
30  if ( year % 4 == 0 && year % 100 != 0 || year % 400 == 0 )
31  if (month > 2)
32  times += 86400L ;
33 
34  /* now add hours, minutes and seconds */
35  times += 3600L * hour ;
36  times += 60L * minute ;
37  times += second ;
38 
39 /* RETURN THE TIME IN SECONDS */
40  return(times) ;
41 }
int hour
Definition: display_data.c:26
int day
Definition: display_data.c:26
int year
Definition: display_data.c:26
int month
Definition: display_data.c:26
long ouptime(int year, int month, int day, int hour, int minute, int second)
Definition: ouptime.c:10
static int mdays[12]
Definition: ouptime.c:8