# include <stdlib.h>
#endif
+#include <string>
+
#ifdef HAVE_SYS_TIME_H
# include <sys/time.h> // for get/setitimer, gettimeofday, struct timeval
#endif
#include "timezone.h"
#include "lowleveltime.h"
-
#define DEGHR(x) ((x)/15.)
#define RADHR(x) DEGHR(x*SGD_RADIANS_TO_DEGREES)
cur_time = time(NULL);
}
- cout << "Current greenwich mean time = " << asctime(gmtime(&cur_time))
- << endl;
- cout << "Current local time = "
- << asctime(localtime(&cur_time)) << endl;
+ SG_LOG( SG_EVENT, SG_INFO,
+ "Current greenwich mean time = " << asctime(gmtime(&cur_time)));
+ SG_LOG( SG_EVENT, SG_INFO,
+ "Current local time = " << asctime(localtime(&cur_time)));
- if ( root != (string)"" ) {
+ if ( !root.empty()) {
SGPath zone( root );
zone.append( "zone.tab" );
SG_LOG( SG_EVENT, SG_INFO, "Reading timezone info from: "
SGPath name( root );
name.append( nearestTz->getDescription() );
- zonename = strdup( name.c_str() );
+ zonename = name.str();
SG_LOG( SG_EVENT, SG_INFO, "Using zonename = " << zonename );
} else {
SG_LOG( SG_EVENT, SG_INFO, "*** NO TIME ZONE NAME ***" );
tzContainer = NULL;
- zonename = NULL;
+ zonename.erase();
}
}
tzContainer = NULL;
delete tmp;
}
-
- if ( zonename != NULL ) {
- char *tmp = zonename;
- zonename = NULL;
- delete tmp;
- }
}
GeoCoord* nearestTz = tzContainer->getNearest(location);
SGPath zone( root );
zone.append ( nearestTz->getDescription() );
- if ( zonename ) {
- char *ptr = zonename;
- zonename = NULL;
- delete ptr;
- }
- zonename = strdup( zone.c_str() );
+ zonename = zone.str();
//Avoid troubles when zone.tab hasn't got the right line endings
- if (zonename[strlen(zonename)-1] == '\r')
+ if (zonename[zonename.size()-1] == '\r')
{
- zonename[strlen(zonename)-1]=0;
+ zonename[zonename.size()-1]=0;
zone.set( zonename );
}