#include "profile.h"
#include "command.h"
#include "navit_nls.h"
+#include "util.h"
/**
* @defgroup navit the navit core instance. navit is the object containing nearly everything: A set of maps, one or more vehicle, a graphics object for rendering the map, a gui object for displaying the user interface, a route object, a navigation object and so on. Be warned that it is theoretically possible to have more than one navit object
enum projection pro;
int border=16;
time_t fixtime;
- struct tm fixtime_tm;
int recenter = 1; // indicates if we should recenter the map
profile(0,NULL);
cursor_pc.pro = pro;
if (this_->tracking && this_->tracking_flag) {
if (! vehicle_get_attr(nv->vehicle, attr_position_hdop, &attr_hdop, NULL)) {
- attr_hdop.u.numd = -1;
+ attr_hdop.u.numd = NULL;
}
if (! vehicle_get_attr(nv->vehicle, attr_position_time_iso8601, &attr_time, NULL)) {
fixtime = time(NULL);
} else {
- strptime(attr_time.u.str, "%Y-%m-%dT%TZ", &fixtime_tm);
- fixtime = mktime(&fixtime_tm);
+ fixtime = iso8601_to_secs(attr_time.u.str);
}
if (tracking_update(this_->tracking, &cursor_pc, nv->dir, attr_hdop.u.numd, nv->speed, fixtime)) {
#include <glib.h>
#include <ctype.h>
+#include <stdlib.h>
#include <stdarg.h>
#include "util.h"
}
#endif
#endif
+
+unsigned int
+iso8601_to_secs(char *iso8601)
+{
+ int a,b,d,val[6],i=0;
+ char *start=iso8601,*pos=iso8601;
+ while (*pos && i < 6) {
+ if (*pos < '0' || *pos > '9') {
+ val[i++]=atoi(start);
+ pos++;
+ start=pos;
+ }
+ pos++;
+ }
+
+ a=val[0]/100;
+ b=2-a+a/4;
+
+ if (val[1] < 2) {
+ val[0]--;
+ val[1]+=12;
+ }
+
+ d=1461*(val[0]+4716)/4+306001*(val[1]+1)/10000+val[2]+b-2442112;
+
+ return ((d*24+val[3])*60+val[4])*60+val[5];
+}
GList * g_hash_to_list(GHashTable *h);
GList * g_hash_to_list_keys(GHashTable *h);
gchar * g_strconcat_printf(gchar *buffer, gchar *fmt, ...);
+unsigned int iso8601_to_secs(char *iso8601);
#endif