Mapper
check_24.c
Go to the documentation of this file.
1  /*
2  check_24
3  If the hour is reported as 24 (instead of 00 ), add in one second
4  to change to next day,
5 
6 
7  */
8 #define _POSIX_SOURCE
9 #include <time.h>
10 
11 static int mdays[12] = { 0,31,59,90,120,151,181,212,243,273,304,334 } ;
12 
13 long check_24(year, month, day, hour, minute, second)
14 short int *year, *month, *day, *hour, *minute, *second;
15 {
16 int ndays ;
17 long times ;
18 
19  time_t cal_time;
20  struct tm *bd_time;
21 
22 
23 
24 
25 /* COMPUTE TIME IN SECONDS SINCE JAN 1, 1980 00:00:00 */
26 
27  /* number of seconds for years */
28 
29  times = 31536000L * (long)(*year - 1970) ;
30 
31  times += 86400L * (long)((*year - 1969)/4); /* account for leap years */
32 
33  /* number of seconds for days in year */
34  ndays = mdays[*month-1] + *day - 1 ;
35  times += 86400L * (long)ndays ;
36 
37  /* take into account leap years */
38  if ( *year % 4 == 0 && *year % 100 != 0 || *year % 400 == 0 )
39  if (*month > 2)
40  times += 86400L ;
41 
42  /* now add hours, minutes and seconds */
43  times += 3600L * *hour ;
44  times += 60L * *minute ;
45  times += *second ;
46 
47 /* now add one second to kick past 24 hours */
48  times++;
49  bd_time = gmtime(&times);
50 
51  *year = bd_time->tm_year + 1900;
52  *month = bd_time->tm_mon +1;
53  *day = bd_time->tm_mday;
54  *hour = bd_time->tm_hour;
55  *minute = bd_time->tm_min;
56  *second = bd_time->tm_sec;
57  *second = 0;
58 
59 
60 
61 
62 
63 
64 
65 /* RETURN THE TIME IN SECONDS */
66  return(times) ;
67 }
static int mdays[12]
Definition: check_24.c:11
long check_24(short int *year, short int *month, short int *day, short int *hour, short int *minute, short int *second)
Definition: check_24.c:13
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