From f0081c769716eb9bbb27c8ccef109a0aac2ad118 Mon Sep 17 00:00:00 2001 From: curt Date: Sat, 8 Jul 2000 13:54:06 +0000 Subject: [PATCH] Collapsed the init() method into the constructor. --- simgear/timing/sg_time.cxx | 69 +++++++++++++------------------------- simgear/timing/sg_time.hxx | 4 +-- 2 files changed, 24 insertions(+), 49 deletions(-) diff --git a/simgear/timing/sg_time.cxx b/simgear/timing/sg_time.cxx index a0353d4e..81da6722 100644 --- a/simgear/timing/sg_time.cxx +++ b/simgear/timing/sg_time.cxx @@ -62,15 +62,35 @@ #define RADHR(x) DEGHR(x*RAD_TO_DEG) -SGTime::SGTime( const string& root ) +SGTime::SGTime( double lon, double lat, const string& root ) { + FG_LOG( FG_EVENT, FG_INFO, "Initializing Time" ); + + gst_diff = -9999.0; + + cur_time = time(NULL); + // cout << "Current greenwich mean time = " << asctime(gmtime(&cur_time)) + // << endl; + // 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() ); - zonename = NULL; + 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; +} + + +SGTime::SGTime( const string& root ) { + SGTime( 0.0, 0.0, root ); } @@ -84,49 +104,6 @@ SGTime::~SGTime() } -// Initialize the time related variables -void SGTime::init( double lon, double lat, const string& root ) -{ - FG_LOG( FG_EVENT, FG_INFO, "Initializing Time" ); - gst_diff = -9999.0; - - // time_t currGMT; - // time_t systemLocalTime; - // time_t aircraftLocalTime; - - // would it be better to put these sanity checks in the options - // parsing code? (CLO) - - cur_time = time(NULL); - - // printf ("Current greenwich mean time = %24s", asctime(gmtime(&cur_time))); - // printf ("Current local time = %24s", asctime(localtime(&cur_time))); - // time_t tmp = cur_time; - GeoCoord location( RAD_TO_DEG * lat, RAD_TO_DEG * lon ); - - GeoCoord* nearestTz = tzContainer->getNearest(location); - - FGPath zone( root ); - zone.append( nearestTz->getDescription() ); - - // cout << "Using " << zone.str() << " for timezone information" << endl; - zonename = strdup( zone.c_str() ); - // cout << "zonename = " << zonename << endl; - //show( buffer.c_str(), cur_time, 1); - //printf ("Current greenwich mean time = %24s", asctime(gmtime(&cur_time))); - //printf ("Current local time = %24s", asctime(localtime(&cur_time))); - // currGMT = get_gmt( gmtime(&cur_time) ); - // cout << "currGMT = " << currGMT << endl; - - // systemLocalTime = get_gmt( localtime(&cur_time) ); - // cout << "systemLocalTime = " << systemLocalTime << endl; - - // aircraftLocalTime = get_gmt( fgLocaltime(&cur_time, zone.c_str()) ); - //printf ("Current greenwich mean time = %24s", asctime(gmtime(&cur_time))); - //printf ("Current local time = %24s", asctime(localtime(&cur_time))); -} - - // given Julian Date and Longitude (decimal degrees West) compute // Local Sidereal Time, in decimal hours. // diff --git a/simgear/timing/sg_time.hxx b/simgear/timing/sg_time.hxx index 938501c4..3712928d 100644 --- a/simgear/timing/sg_time.hxx +++ b/simgear/timing/sg_time.hxx @@ -83,12 +83,10 @@ private: public: + SGTime( double lon, double lat, const string& root ); SGTime( const string& root ); ~SGTime(); - // Initialize the time related variables - void init( double lon, double lat, const string& root ); - // Update the time related variables void update( double lon, double lat, long int warp = 0 );