diff options
author | Jeremy Allison <jra@samba.org> | 1998-11-11 20:03:19 +0000 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 1998-11-11 20:03:19 +0000 |
commit | 751856a09d4fa112ce2fedd963b42ae5f63c89c1 (patch) | |
tree | 123ff8584b62eef974b9dcefc60d7dd2d57939d8 /source/lib/replace.c | |
parent | abdc9d790b7d27b70aaf88451f5c82c99c94ca6e (diff) | |
download | samba-751856a09d4fa112ce2fedd963b42ae5f63c89c1.tar.gz samba-751856a09d4fa112ce2fedd963b42ae5f63c89c1.tar.xz samba-751856a09d4fa112ce2fedd963b42ae5f63c89c1.zip |
Fix from richard.kettlewell@kewill.com for leapyear bugs.
Jeremy.
Diffstat (limited to 'source/lib/replace.c')
-rw-r--r-- | source/lib/replace.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/source/lib/replace.c b/source/lib/replace.c index 56f6b9c6379..b0adb72fd24 100644 --- a/source/lib/replace.c +++ b/source/lib/replace.c @@ -48,7 +48,9 @@ ftruncate for operating systems that don't have it /******************************************************************* a mktime() replacement for those who don't have it - contributed by C.A. Lademann <cal@zls.com> +Corrections by richard.kettlewell@kewill.com ********************************************************************/ + #define MINUTE 60 #define HOUR 60*MINUTE #define DAY 24*HOUR @@ -57,14 +59,16 @@ C.A. Lademann <cal@zls.com> { struct tm *u; time_t epoch = 0; + int n; int mon [] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }, y, m, i; if(t->tm_year < 70) return((time_t)-1); + n = t->tm_year + 1900 - 1; epoch = (t->tm_year - 70) * YEAR + - (t->tm_year / 4 - 70 / 4 - t->tm_year / 100) * DAY; + ((n / 4 - n / 100 + n / 400) - (1969 / 4 - 1969 / 100 + 1969 / 400)) * DAY; y = t->tm_year; m = 0; |