FreeNOS
time.cpp
Go to the documentation of this file.
1 
18 #include <time.h>
19 
20 unsigned long mktime(const unsigned int year, const unsigned int month,
21  const unsigned int day, const unsigned int hour,
22  const unsigned int min, const unsigned int sec)
23 {
24  unsigned int monthVal = month, yearVal = year;
25 
26  // 1..12 -> 11,12,1..10
27  if( 0 >= (int) (monthVal -= 2))
28  {
29  monthVal += 12; // Puts Feb last since it has leap day
30  yearVal -= 1;
31  }
32 
33  return ((((unsigned long)
34  (yearVal/4 - yearVal/100 + yearVal/400 + 367*monthVal/12 + day) +
35  yearVal*365 - 719499
36  )*24 + hour // now have hours
37  )*60 + min // now have minutes
38  )*60 + sec; // finally seconds
39 }
mktime
unsigned long mktime(const unsigned int year, const unsigned int month, const unsigned int day, const unsigned int hour, const unsigned int min, const unsigned int sec)
Copyright (C) 2009 Coen Bijlsma.
Definition: time.cpp:20