X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=simgear%2Ftiming%2Fsg_time.hxx;h=ba058f4a864b8f600532655ac34db493f1046452;hb=e3fc89890c8f5cb4c09f936209e46878d2f2ea67;hp=bf208475dee4d0475b012cdd803182fa50edd6a7;hpb=51ef4568dd248a6917720a386e658610958e1512;p=simgear.git diff --git a/simgear/timing/sg_time.hxx b/simgear/timing/sg_time.hxx index bf208475..ba058f4a 100644 --- a/simgear/timing/sg_time.hxx +++ b/simgear/timing/sg_time.hxx @@ -5,7 +5,7 @@ // Written by Curtis Olson, started August 1997. // -// Copyright (C) 1997 Curtis L. Olson - curt@flightgear.org +// Copyright (C) 1997 Curtis L. Olson - http://www.flightgear.org/~curt // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Library General Public @@ -17,10 +17,9 @@ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Library General Public License for more details. // -// 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. +// 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. // // $Id$ @@ -29,18 +28,14 @@ #define _SG_TIME_HXX -#ifndef __cplusplus +#ifndef __cplusplus # error This library requires C++ -#endif +#endif #include -#ifdef SG_HAVE_STD_INCLUDES -# include -#else -# include -#endif +#include #include @@ -72,17 +67,13 @@ private: SGTimeZoneContainer* tzContainer; // Points to the current local timezone name; - string zonename; + std::string zonename; // Unix "calendar" time in seconds time_t cur_time; // Break down of equivalent GMT time -#if defined(_MSC_VER) || defined(__MINGW32__) struct tm m_gmt; // copy of system gmtime(&time_t) structure -#else - struct tm *gmt; -#endif // offset of local time relative to GMT time_t local_offset; @@ -104,6 +95,10 @@ private: // gst_diff has pretty good accuracy over the span of a couple hours double gst_diff; + /** init common constructor code */ + void init( double lon_rad, double lat_rad, const std::string& root, + time_t init_time ); + public: /** Default constructor */ @@ -120,25 +115,23 @@ public: * If you don't know your position when you call the SGTime * constructor, you can just use the first form (which assumes 0, * 0). - * @param lon current longitude - * @param lat current latitude + * @param lon_rad current longitude (radians) + * @param lat_rad current latitude (radians) * @param root root path point to data file location (timezone, etc.) * @param init_time provide an initialization time, 0 means use current clock time */ - SGTime( double lon, double lat, const string& root, time_t init_time /* = 0 */ ); + SGTime( double lon_rad, double lat_rad, const std::string& root, + time_t init_time ); /** * Create an instance given a data file path. * @param root root path point to data file location (timezone, etc.) */ - SGTime( const string& root ); + SGTime( const std::string& root ); /** Destructor */ ~SGTime(); - /** init common constructor code */ - void init( double lon, double lat, const string& root, time_t init_time /* = 0 */ ); - /** * Update the time related variables. * The update() method requires you to pass in your position and @@ -146,13 +139,13 @@ public: * you to offset "sim" time relative to "real" time. The update() * method is designed to be called by the host application before * every frame. - * @param lon current longitude - * @param lat current latitude + * @param lon_rad current longitude (radians) + * @param lat_rad current latitude (radians) * @param ct specify a unix time, otherwise specify 0 to use current clock time * @param warp an optional time offset specified in seconds. This * allows us to advance or rewind "time" if we choose to. */ - void update( double lon, double lat, time_t ct /* = 0 */, long int warp /* = 0 */ ); + void update( double lon_rad, double lat_rad, time_t ct, long int warp ); /** * Given lon/lat, update timezone information and local_offset @@ -161,10 +154,10 @@ public: * enough that your timezone may have changed as well. In the * FlightGear project we call updateLocal() every few minutes from * our periodic event manager. - * @param lon current longitude - * @param lat current latitude + * @param lon_rad current longitude (radians) + * @param lat_rad current latitude (radians) * @param root base path containing time zone directory */ - void updateLocal( double lon, double lat, const string& root ); + void updateLocal( double lon_rad, double lat_rad, const std::string& root ); /** @return current system/unix time in seconds */ inline time_t get_cur_time() const { return cur_time; }; @@ -173,11 +166,7 @@ public: inline const char * get_zonename() const { return zonename.c_str(); } /** @return GMT in a "brokent down" tm structure */ -#if defined(_MSC_VER) || defined(__MINGW32__) inline struct tm* getGmt()const { return (struct tm *)&m_gmt; }; -#else - inline struct tm* getGmt()const { return gmt; }; -#endif /** @return julian date */ inline double getJD() const { return jd; }; @@ -190,6 +179,9 @@ public: /** @return grenich side real time (lst when longitude == 0) */ inline double getGst() const { return gst; }; + + /** @return offset in seconds to local timezone time */ + inline time_t get_local_offset() const { return local_offset; }; }; @@ -198,7 +190,7 @@ public: /** * \relates SGTime - * Return unix time in seconds for the given data (relative to GMT) + * Return unix time in seconds for the given date (relative to GMT) * @param year current GMT year * @param month current GMT month * @param day current GMT day