Hi,
On Tue, 4 Sep 2007, Johannes Sixt wrote:
Johannes Schindelin schrieb:
quoted
On Tue, 4 Sep 2007, Johannes Sixt wrote:
quoted
Therefore, I've pushed out a fixup patch at the top of mingw.git's devel
branch that converts mtime to local time
On Linux, we compare to UTC to begin with, right? We should do that here,
too... So if time(NULL) does not return UTC on MinGW, we have to wrap that
function, too.
According to MSDN, time(NULL) returns "the number of seconds elapsed since
[epoch] according to the system clock". Please don't ask me what "the system
clock" is.
I think I know. From my QEmu adventures I know that DOS/Windows expects
the system clock to be set to local time, in contrast to _all_ other
operating systems.
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)?
-- snip --
diff --git a/git-compat-util.h b/git-compat-util.h
index 172e828..2984319 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -470,6 +470,17 @@ static inline int git_unlink(const char *pathname)
{
#include <time.h>
struct tm *gmtime_r(const time_t *timep, struct tm *result);
struct tm *localtime_r(const time_t *timep, struct tm *result);
+static inline time_t mingw_time(void *dummy)
+{
+ FILETIME ft;
+ GetSystemTimeAsFileTime(&ft);
+ long long winTime = ((long long)ft.dwHighDateTime << 32) +
ft.dwLowDateTime;
+ winTime -= 116444736000000000LL; /* Windows to Unix Epoch
conversion */
+ winTime /= 10000000; /* Nano to seconds resolution
*/
+ return (time_t)winTime;
+
+}
+#define time mingw_time
#define hstrerror strerror
char *mingw_getcwd(char *pointer, int len);
-- snap --
Ciao,
Dscho