//
// Copyright (C) 1997 Curtis L. Olson - curt@infoplane.com
//
-// This program is free software; you can redistribute it and/or
-// modify it under the terms of the GNU General Public License as
-// published by the Free Software Foundation; either version 2 of the
-// License, or (at your option) any later version.
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Library General Public
+// License as published by the Free Software Foundation; either
+// version 2 of the License, or (at your option) any later version.
//
-// This program is distributed in the hope that it will be useful, but
-// WITHOUT ANY WARRANTY; without even the implied warranty of
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// General Public License for more details.
+// Library General Public License for more details.
//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+// You should have received a copy of the GNU Library General Public
+// License along with this library; if not, write to the
+// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+// Boston, MA 02111-1307, USA.
//
// $Id$
#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" );
// 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;
+ }
}
}
+SGTime::SGTime() {
+ SGTime( 0.0, 0.0, "" );
+}
+
+
SGTime::~SGTime()
{
- delete tzContainer;
+ if ( tzContainer != NULL ) {
+ delete tzContainer;
+ }
if ( zonename != NULL ) {
delete zonename;
# 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