2 Copyright © 1995-2004, The AROS Development Team. All rights reserved.
5 Convert a broken-down time into calendar time.
9 static char monthtable
[] =
11 /* JanFebMarAprMayJunJulAugSepOktNov */
12 31,28,31,30,31,30,31,31,30,31,30
15 /*****************************************************************************
26 The mktime() function converts the broken-down time utim to
27 calendar time representation.
30 utim - The broken-down time to convert
33 The converted calendar time
41 //Computation which results in a tm
48 At the moment sanity check is not performed nor a normalization on the
52 time(), ctime(), asctime(), localtime(), gmtime()
57 1. every 4th year is a leap year
59 2. every 100th year is none
63 4. 1900 was none, 2000 is one
65 ******************************************************************************/
73 /* TODO: Add struct tm normalization code here */
75 /* Compute number of days in the years before this year and after 1970.
76 * 1972 is the first leapyear
78 year
= utim
->tm_year
-1;
79 days
= 365*(year
-69) + (year
-68)/4 - year
/100 + (year
+300)/400;
81 /* Add the day of the months before this month */
82 for (i
=0; i
<utim
->tm_mon
; i
++)
84 days
+= monthtable
[i
];
87 /* Is this a leapyear ? */
89 leapyear
= year
%4==0 && (year
%100!=0 || (year
+300)%400==0);
90 if (leapyear
&& utim
->tm_mon
>1) days
++;
92 /* Add day in the current month */
93 days
+= utim
->tm_mday
- 1;
95 tt
= ( (days
*24+utim
->tm_hour
)*60 + utim
->tm_min
)*60 + utim
->tm_sec
;