Re: [PATCH] Add a new lstat and fstat implementation based on Win32 API
- From
Johannes Sixt <j.sixt@eudaptics.com>
- Date
- Sep 4, 2007, 13:03 UTC
- Message-ID
- <46DD57B7.9090206@eudaptics.com>
- In-Reply-To
- <Pine.LNX.4.64.0709041324420.28586@racer.site>
Johannes Schindelin schrieb:
Show 10 quoted lines
> On Tue, 4 Sep 2007, Johannes Sixt wrote: >> Reading the implementation of time(), it starts with GetLocalTime(), >> determines whether daylight saving is in effect, and continues with >> another round of timezone adjustment - mind you: _not_ a timezone >> reversal (!!). Doesn't this look extremely bogus? >> >> It seems we really need a wrapper for time(). > > I absolutely concur. Something like this (most of it is blatantly copied > from Marius' patch)?
Well, I don't think it'll make a difference. The tiny test program below prints twice the same number. My analysis of the time() implementation is obviously flawed.
-- Hannes
#include <windows.h> #include <stdio.h> #include <time.h>
int main()
{
time_t t = time(NULL);
FILETIME ft;GetSystemTimeAsFileTime(&ft); long long winTime = ((long long)ft.dwHighDateTime << 32) + ft.dwLowDateTime; winTime -= 116444736000000000LL; winTime /= 10000000;
printf("%d %d\n", t, (int) winTime);
return 0;
}