X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=simgear%2Ftiming%2Fsg_time.cxx;h=16d50d3ef3962056c2ee2884f14bca6b1b907c77;hb=9af5f9f094706685bae09a885fb6adf6394124c2;hp=3aa89d92e4d30c1d54cdeadb01912f61dce0b1a9;hpb=82459a2802a939434f9fc5b88d2b2aea58f0043d;p=simgear.git diff --git a/simgear/timing/sg_time.cxx b/simgear/timing/sg_time.cxx index 3aa89d92..16d50d3e 100644 --- a/simgear/timing/sg_time.cxx +++ b/simgear/timing/sg_time.cxx @@ -63,6 +63,11 @@ #define RADHR(x) DEGHR(x*RAD_TO_DEG) +static const double MJD0 = 2415020.0; +static const double J2000 = 2451545.0 - MJD0; +static const double SIDRATE = 0.9972695677; + + SGTime::SGTime( double lon, double lat, const string& root ) { FG_LOG( FG_EVENT, FG_INFO, "Initializing Time" ); @@ -75,18 +80,24 @@ SGTime::SGTime( double lon, double lat, const string& root ) // cout << "Current local time = " // << asctime(localtime(&cur_time)) << endl; - FGPath zone( root ); - zone.append( "zone.tab" ); - FG_LOG( FG_EVENT, FG_DEBUG, "Reading timezone info from: " << zone.str() ); - tzContainer = new TimezoneContainer( zone.c_str() ); + if ( root != "" ) { + FGPath zone( root ); + zone.append( "zone.tab" ); + FG_LOG( FG_EVENT, FG_DEBUG, "Reading timezone info from: " + << zone.str() ); + tzContainer = new TimezoneContainer( zone.c_str() ); - GeoCoord location( RAD_TO_DEG * lat, RAD_TO_DEG * lon ); - GeoCoord* nearestTz = tzContainer->getNearest(location); + GeoCoord location( RAD_TO_DEG * lat, RAD_TO_DEG * lon ); + GeoCoord* nearestTz = tzContainer->getNearest(location); - FGPath name( root ); - name.append( nearestTz->getDescription() ); - zonename = strdup( name.c_str() ); - // cout << "Using zonename = " << zonename << endl; + FGPath name( root ); + name.append( nearestTz->getDescription() ); + zonename = strdup( name.c_str() ); + // cout << "Using zonename = " << zonename << endl; + } else { + tzContainer = NULL; + zonename = NULL; + } } @@ -95,9 +106,16 @@ SGTime::SGTime( const string& root ) { } +SGTime::SGTime() { + SGTime( 0.0, 0.0, "" ); +} + + SGTime::~SGTime() { - delete tzContainer; + if ( tzContainer != NULL ) { + delete tzContainer; + } if ( zonename != NULL ) { delete zonename; @@ -400,7 +418,7 @@ time_t sgTimeGetGMT(int year, int month, int day, int hour, int min, int sec) # define TIMEZONE_OFFSET_WORKS 1 # endif - long int start = mktime(&mt); + time_t start = mktime(&mt); FG_LOG( FG_EVENT, FG_DEBUG, "start1 = " << start ); // the ctime() call can screw up time progression on some versions