head 1.4; access; symbols; locks; strict; comment @# @; 1.4 date 2002.09.07.01.50.40; author curt; state Exp; branches; next 1.3; 1.3 date 2002.08.31.19.01.57; author curt; state Exp; branches; next 1.2; 1.2 date 2002.08.31.18.54.04; author curt; state Exp; branches; next 1.1; 1.1 date 2002.02.15.17.22.01; author curt; state Exp; branches; next ; desc @@ 1.4 log @Updated doxygen docs. @ text @
Main Page Class Hierarchy Compound List File List Compound Members File Members

# sg_time.hxx

Go to the documentation of this file.

    00001
    00006 // Written by Curtis Olson, started August 1997.
    00007 //
    00008 // Copyright (C) 1997  Curtis L. Olson  - curt@@flightgear.org
    00009 //
    00010 // This library is free software; you can redistribute it and/or
    00011 // modify it under the terms of the GNU Library General Public
    00012 // License as published by the Free Software Foundation; either
    00013 // version 2 of the License, or (at your option) any later version.
    00014 //
    00015 // This library is distributed in the hope that it will be useful,
    00016 // but WITHOUT ANY WARRANTY; without even the implied warranty of
    00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    00018 // Library General Public License for more details.
    00019 //
    00020 // You should have received a copy of the GNU Library General Public
    00021 // License along with this library; if not, write to the
    00022 // Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    00023 // Boston, MA  02111-1307, USA.
    00024 //
    00025 // $Id: sg_time.hxx,v 1.18 2002/02/11 22:27:28 curt Exp $
    00026
    00027
    00028 #ifndef _SG_TIME_HXX
    00029 #define _SG_TIME_HXX
    00030
    00031
    00032 #ifndef __cplusplus
    00033 # error This library requires C++
    00034 #endif
    00035
    00036
    00037 #include <simgear/compiler.h>
    00038
    00039 #ifdef SG_HAVE_STD_INCLUDES
    00040 #  include <ctime>
    00041 #else
    00042 #  include <time.h>
    00043 #endif
    00044
    00045 #include <simgear/timing/timezone.h>
    00046
    00047
    00068 class SGTime {
    00069
    00070 private:
    00071     // tzContainer stores all the current Timezone control points/
    00072     TimezoneContainer* tzContainer;
    00073
    00074     // Points to the current local timezone name;
    00075     char *zonename;
    00076
    00077     // Unix "calendar" time in seconds
    00078     time_t cur_time;
    00079
    00080     // Break down of equivalent GMT time
    00081 #if defined(_MSC_VER) || defined(__MINGW32__)
    00082     struct tm m_gmt;    // copy of system gmtime(&time_t) structure
    00083 #else
    00084     struct tm *gmt;
    00085 #endif
    00086
    00087     // offset of local time relative to GMT
    00088     time_t local_offset;
    00089
    00090     // Julian date
    00091     double jd;
    00092
    00093     // modified Julian date
    00094     double mjd;
    00095
    00096     // side real time at prime meridian
    00097     double gst;
    00098
    00099     // local sidereal time
    00100     double lst;
    00101
    00102     // the difference between the precise / expensive sidereal time
    00103     // algorithm result and the quick course result.  course_gst +
    00104     // gst_diff has pretty good accuracy over the span of a couple hours
    00105     double gst_diff;
    00106
    00107 public:
    00108
    00110     SGTime();
    00111
    00128     SGTime( double lon, double lat, const string& root, time_t init_time /* = 0 */ );
    00129
    00134     SGTime( const string& root );
    00135
    00137     ~SGTime();
    00138
    00140     void init( double lon, double lat, const string& root, time_t init_time /* = 0 */ );
    00141
    00155     void update( double lon, double lat, time_t ct /* = 0 */, long int warp /* = 0 */ );
    00156
    00167     void updateLocal( double lon, double lat, const string& root );
    00168
    00170     inline time_t get_cur_time() const { return cur_time; };
    00171
    00173     inline char* get_zonename() const { return zonename; }
    00174
    00176 #if defined(_MSC_VER) || defined(__MINGW32__)
    00177     inline struct tm* getGmt()const { return (struct tm *)&m_gmt; };
    00178 #else
    00179     inline struct tm* getGmt()const { return gmt; };
    00180 #endif
    00181
    00183     inline double getJD() const { return jd; };
    00184
    00186     inline double getMjd() const { return mjd; };
    00187
    00189     inline double getLst() const { return lst; };
    00190
    00192     inline double getGst() const { return gst; };
    00193 };
    00194
    00195
    00196 // Some useful utility functions that don't make sense to be part of
    00197 // the SGTime class
    00198
    00210 time_t sgTimeGetGMT(int year, int month, int day,
    00211                     int hour, int minute, int second);
    00212
    00220 inline time_t sgTimeGetGMT(struct tm* the_time) {
    00221     // printf("Using: %24s as input\n", asctime(the_time));
    00222     return sgTimeGetGMT(the_time->tm_year,
    00223                         the_time->tm_mon,
    00224                         the_time->tm_mday,
    00225                         the_time->tm_hour,
    00226                         the_time->tm_min,
    00227                         the_time->tm_sec);
    00228 }
    00229
    00239 double sgTimeCalcMJD(int mn, double dy, int yr);
    00240
    00250 double sgTimeCurrentMJD( time_t ct /* = 0 */, long int warp /* = 0 */ );
    00251
    00257 double sgTimeCalcGST( double mjd );
    00258
    00266 char* sgTimeFormatTime( const struct tm* p, char* buf );
    00267
    00268
    00269 #endif // _SG_TIME_HXX

@ 1.3 log @Oops, try again. @ text @d153 1 a153 1