diff --git a/ChangeLog b/ChangeLog index 955c1239f..3e6760584 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,8 +1,8 @@ 2007-01-16 Tor Lillqvist * glib/gthread.c (gettime): GetSystemTimeAsFileTime() returns 100s - of nanoseconds, so multiply by 100 to get nanoseconds which is - what we want. + of nanoseconds since 1601, so offset to Unix epoch (1970) and + multiply by 100 to get nanoseconds which is what we want. 2005-01-15 Matthias Clasen diff --git a/glib/gthread.c b/glib/gthread.c index 683ad4a47..116c2af25 100644 --- a/glib/gthread.c +++ b/glib/gthread.c @@ -554,7 +554,12 @@ gettime (void) #ifdef G_OS_WIN32 guint64 v; + /* Returns 100s of nanoseconds since start of 1601 */ GetSystemTimeAsFileTime ((FILETIME *)&v); + + /* Offset to Unix epoch */ + v -= G_GINT64_CONSTANT (116444736000000000); + /* Convert to nanoseconds */ v *= 100; return v; diff --git a/gthread/ChangeLog b/gthread/ChangeLog index 2a7f562a7..22d32271a 100644 --- a/gthread/ChangeLog +++ b/gthread/ChangeLog @@ -1,8 +1,9 @@ 2007-01-16 Tor Lillqvist * gthread-win32.c (g_gettime_win32_impl): - GetSystemTimeAsFileTime() returns 100s of nanoseconds, so multiply - by 100 to get nanoseconds which is what we want. + GetSystemTimeAsFileTime() returns 100s of nanoseconds since 1601, + so offset to Unix epoch (1970) and multiply by 100 to get + nanoseconds which is what we want. 2005-01-15 Matthias Clasen diff --git a/gthread/gthread-win32.c b/gthread/gthread-win32.c index 6aead761e..90d2779c3 100644 --- a/gthread/gthread-win32.c +++ b/gthread/gthread-win32.c @@ -550,7 +550,12 @@ g_gettime_win32_impl (void) { guint64 v; + /* Returns 100s of nanoseconds since start of 1601 */ GetSystemTimeAsFileTime ((FILETIME *)&v); + + /* Offset to Unix epoch */ + v -= G_GINT64_CONSTANT (116444736000000000); + /* Convert to nanoseconds */ v *= 100; return v;