Fix:Android:Corrected and added keycodes
[navit-package] / navit / util.c
index 6a8e710..3f1fdd6 100644 (file)
@@ -21,6 +21,7 @@
 #include <ctype.h>
 #include <stdlib.h>
 #include <stdarg.h>
+#include <time.h>
 #include "util.h"
 
 void
@@ -100,6 +101,9 @@ g_utf8_strlen_force_link(gchar *buffer, int max)
 
 #if defined(_WIN32) || defined(__CEGCC__)
 #include <windows.h>
+#endif
+
+#if defined(_WIN32) || defined(__CEGCC__) || defined (__APPLE__)
 #include <stdio.h>
 char *stristr(const char *String, const char *Pattern)
 {
@@ -281,3 +285,31 @@ iso8601_to_secs(char *iso8601)
 
        return ((d*24+val[3])*60+val[4])*60+val[5];
 }
+
+char *
+current_to_iso8601(void)
+{
+       char buffer[32];
+       char *timep=NULL;
+#ifdef HAVE_GLIB
+       GTimeVal time; 
+       g_get_current_time(&time); 
+       timep = g_time_val_to_iso8601(&time);
+#else
+#ifdef HAVE_API_WIN32_BASE
+       SYSTEMTIME ST;
+       GetSystemTime(&ST);
+       timep=g_strdup_printf("%d-%02d-%02dT%02d:%02d:%02dZ",ST.wYear,ST.wMonth,ST.wDay,ST.wHour,ST.wMinute,ST.wSecond);
+#else
+       time_t tnow;
+       struct tm *tm;
+       tnow = time(0);
+       tm = gmtime(&tnow);
+       if (tm) {
+               strftime(buffer, sizeof(buffer), "%Y-%m-%dT%TZ", tm);
+               timep=g_strdup(buffer); 
+       }
+#endif
+#endif
+       return timep;
+}