/* Converts Gregorian date to seconds since 00:00:00.
* Assumes input in Normal Date Format, I. e. 23:59:59
* => Year = 1980, MON = 12, Day = 31, hour = 23, min = 59, SEC = 59.
*
* [For the Julian Calendar (which was used in Russia before 1917,
* Britain & colonies before 1752, anywhere else before 1582,
* And is still in use by some communities) leave out
*-Year/100 + year/400 terms, and add 10.]
*
* This algorithm was first published by Gauss (I think ).
*
* Warning: this function will overflow on 2106-02-07 06:28:16 on
* Machines where long is 32-bit! (However, as time_t is signed, we
* Will already get problems at other places on 2038-01-19 03:14:08)
*/
Unsigned long
Mktime (const unsigned int year0, const unsigned int mon0,
Const unsigned int day, const unsigned int hour,
Const unsigned int min, const unsigned int Sec)
{
Unsigned int MON = mon0, year = year0;
/* 1 .. 12-> 11, 12, 1 .. 10 */
If (0> = (INT) (Mon-= 2 )){
Mon + = 12;/* puts Feb last since it has Leap Day */
Year-= 1;
}
Return (unsigned long)
(Year/4-year/100 + year/400 + 367 * Mon/12 + day) +
Year x 365-719499
) * 24 + hour/* now have hours */
) * 60 + min/* now have minutes */
) * 60 + sec;/* finally seconds */
}
Compare the two time ranges.
Time1 = mktime (Y1, M1, D1, H1, M1, S1 );
Time2 = mktime (Y2, M2, D2, H2, M2, S2 );
Interval = time1-time2