//
// Copyright (C) 1997 Curtis L. Olson - curt@flightgear.org
//
-// 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$
#include <simgear/compiler.h>
-#ifdef FG_HAVE_STD_INCLUDES
+#ifdef SG_HAVE_STD_INCLUDES
# include <ctime>
#else
# include <time.h>
#endif
-#include "timezone.h"
+#include <simgear/timing/timezone.h>
// Define a structure containing time parameters
public:
+ SGTime( double lon, double lat, const string& root );
SGTime( const string& root );
+ SGTime();
~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, double alt_m, long int warp );
+ void update( double lon, double lat, long int warp = 0 );
// Given lon/lat, update timezone information and local_offset
void updateLocal( double lon, double lat, const string& root );
- // given Julian Date and Longitude (decimal degrees West) compute
- // Local Sidereal Time, in decimal hours.
- //
- // Provided courtesy of ecdowney@noao.edu (Elwood Downey)
- double sidereal_precise( double lng );
-
- // return a courser but cheaper estimate of sidereal time
- double sidereal_course( double lng );
-
- // Some other stuff which were changed to SGTime members on
- // questionable grounds -:)
- time_t get_gmt(int year, int month, int day,
- int hour, int minute, int second);
- time_t get_gmt(struct tm* the_time);
-
+ inline time_t get_cur_time() const { return cur_time; };
+ inline char* get_zonename() const { return zonename; }
+ inline struct tm* getGmt()const { return gmt; };
inline double getJD() const { return jd; };
inline double getMjd() const { return mjd; };
inline double getLst() const { return lst; };
inline double getGst() const { return gst; };
- inline time_t get_cur_time() const { return cur_time; };
- inline struct tm* getGmt()const { return gmt; };
- inline char* get_zonename() const { return zonename; }
};
+// Some useful utility functions that don't make sense to be part of
+// the SGTime class
+
+// Return unix time in seconds for the given data (relative to GMT)
+time_t sgTimeGetGMT(int year, int month, int day,
+ int hour, int minute, int second);
+
// this is just a wrapper
-inline time_t SGTime::get_gmt(struct tm* the_time) {
+inline time_t sgTimeGetGMT(struct tm* the_time) {
// printf("Using: %24s as input\n", asctime(the_time));
- return get_gmt(the_time->tm_year,
- the_time->tm_mon,
- the_time->tm_mday,
- the_time->tm_hour,
- the_time->tm_min,
- the_time->tm_sec);
+ return sgTimeGetGMT(the_time->tm_year,
+ the_time->tm_mon,
+ the_time->tm_mday,
+ the_time->tm_hour,
+ the_time->tm_min,
+ the_time->tm_sec);
}
// given a date in months, mn, days, dy, years, yr, return the