summaryrefslogtreecommitdiff
path: root/navit
diff options
context:
space:
mode:
authormartin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220>2009-11-13 07:59:59 +0000
committermartin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220>2009-11-13 07:59:59 +0000
commitf6659af57376e9f554cdea65cb7f33ffb77e6687 (patch)
tree0d03c93964eb15aa80c01ec2e3f9b00e3da95e79 /navit
parent31aeeaf4f658028b3d90553403ee7bfedf79f303 (diff)
downloadnavit-f6659af57376e9f554cdea65cb7f33ffb77e6687.tar.gz
Fix:Core:Avoid gmtime_r which isn't available on all platforms
git-svn-id: http://svn.code.sf.net/p/navit/code/trunk/navit@2751 ffa7fe5e-494d-0410-b361-a75ebd5db220
Diffstat (limited to 'navit')
-rw-r--r--navit/navit.c8
-rw-r--r--navit/sunriset.h4
2 files changed, 7 insertions, 5 deletions
diff --git a/navit/navit.c b/navit/navit.c
index bf74984bb..5e9ab6e6f 100644
--- a/navit/navit.c
+++ b/navit/navit.c
@@ -2265,6 +2265,7 @@ navit_layout_switch(struct navit *n)
struct attr iso8601_attr,geo_attr,layout_attr;
double trise,tset,trise_actual;
struct layout *l;
+ int year, month, day;
if (navit_get_attr(n,attr_layout,&layout_attr,NULL)!=1) {
return; //No layout - nothing to switch
@@ -2282,7 +2283,8 @@ navit_layout_switch(struct navit *n)
//We've have to wait a little
return;
}
-
+ if (sscanf(iso8601_attr.u.str,"%d-%02d-%02dT",&year,&month,&day) != 3)
+ return;
if (vehicle_get_attr(n->vehicle->vehicle, attr_position_coord_geo,&geo_attr,NULL)!=1) {
//No position - no sun
return;
@@ -2292,7 +2294,7 @@ navit_layout_switch(struct navit *n)
}
//We calculate sunrise anyway, cause it is need both for day and for night
- if (__sunriset__(currTs,geo_attr.u.coord_geo->lat,geo_attr.u.coord_geo->lng,35,1,&trise,&tset)!=0) {
+ if (__sunriset__(year,month,day,geo_attr.u.coord_geo->lat,geo_attr.u.coord_geo->lng,35,1,&trise,&tset)!=0) {
//near the pole sun never rises/sets, so we should never switch profiles
n->prevTs=currTs;
return;
@@ -2311,7 +2313,7 @@ navit_layout_switch(struct navit *n)
}
}
if (l->nightname) {
- if (__sunriset__(currTs,geo_attr.u.coord_geo->lat,geo_attr.u.coord_geo->lng,-12,0,&trise,&tset)!=0) {
+ if (__sunriset__(year,month,day,geo_attr.u.coord_geo->lat,geo_attr.u.coord_geo->lng,-12,0,&trise,&tset)!=0) {
//near the pole sun never rises/sets, so we should never switch profiles
n->prevTs=currTs;
return;
diff --git a/navit/sunriset.h b/navit/sunriset.h
index 1ccad5797..9df6ca26f 100644
--- a/navit/sunriset.h
+++ b/navit/sunriset.h
@@ -7,7 +7,7 @@ extern long int timezone_offset;
#define HOURS(h) ((int)(floor(h)))
#define MINUTES(h) ((int)(60*(h-floor(h))))
-#define ABS(x) ((x)<0?-(x):(x))
+#define ABS(x) ((x)<0?-(x):(x))
/* A macro to compute the number of days elapsed since 2000 Jan 0.0 */
/* (which is equal to 1999 Dec 31, 0h UT) */
@@ -100,7 +100,7 @@ extern long int timezone_offset;
double __daylen__( int year, int month, int day, double lon, double lat,
double altit, int upper_limb );
-int __sunriset__( time_t ts, double lon, double lat,
+int __sunriset__( int year, int month, int day, double lon, double lat,
double altit, int upper_limb, double *rise, double *set );
void sunpos( double d, double *lon, double *r );