1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-25 23:21:54 +03:00

r19403: try to fix the crashes in the buildfarm related to timegm

This commit is contained in:
Andrew Tridgell 2006-10-18 22:33:20 +00:00 committed by Gerald (Jerry) Carter
parent 1347ad254e
commit c4e1d2c5ae

View File

@ -44,13 +44,22 @@ static int is_leap(unsigned y)
return (y % 4) == 0 && ((y % 100) != 0 || (y % 400) == 0);
}
time_t timegm(struct tm *tm)
time_t rep_timegm(struct tm *tm)
{
static const unsigned ndays[2][12] ={
{31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31},
{31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}};
time_t res = 0;
unsigned i;
if (tm->tm_mon > 12 ||
tm->tm_mday > 31 ||
tm->tm_min > 60 ||
tm->tm_sec > 60 ||
tm->tm_hour > 24) {
/* invalid tm structure */
return 0;
}
for (i = 70; i < tm->tm_year; ++i)
res += is_leap(i) ? 366 : 365;