summaryrefslogtreecommitdiff
path: root/navit/support/libc/localtime.c
diff options
context:
space:
mode:
Diffstat (limited to 'navit/support/libc/localtime.c')
-rw-r--r--navit/support/libc/localtime.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/navit/support/libc/localtime.c b/navit/support/libc/localtime.c
new file mode 100644
index 000000000..245b51c5a
--- /dev/null
+++ b/navit/support/libc/localtime.c
@@ -0,0 +1,38 @@
+/*
+ * localtime.c: localtime implementation for WinCE.
+ *
+ * This file has no copyright assigned and is placed in the Public Domain.
+ * This file is a part of the mingw-runtime package.
+ * No warranty is given; refer to the file DISCLAIMER within the package.
+ *
+ * Written by Pedro Alves <pedro_alves@portugalmail.pt> Feb 2007
+ *
+ */
+
+#include "timeutil.h"
+
+struct tm *
+localtime(const time_t *timer)
+{
+ SYSTEMTIME ss, ls, s;
+ FILETIME sf, lf, f;
+ long long t, diff;
+
+ static struct tm tms;
+
+ GetSystemTime (&ss);
+ GetLocalTime (&ls);
+
+ SystemTimeToFileTime (&ss, &sf);
+ SystemTimeToFileTime (&ls, &lf);
+
+ diff = __FILETIME_to_ll (&sf) - __FILETIME_to_ll (&lf);
+
+ __time_t_to_FILETIME (*timer, &f);
+ t = __FILETIME_to_ll (&f) - diff;
+ __ll_to_FILETIME (t, &f);
+ FileTimeToSystemTime (&f, &s);
+ __SYSTEMTIME_to_tm (&s, &tms);
+
+ return &tms;
+}