1 // fg_time.hxx -- data structures and routines for managing time related stuff.
3 // Written by Curtis Olson, started August 1997.
5 // Copyright (C) 1997 Curtis L. Olson - curt@infoplane.com
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License as
9 // published by the Free Software Foundation; either version 2 of the
10 // License, or (at your option) any later version.
12 // This program is distributed in the hope that it will be useful, but
13 // WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 // General Public License for more details.
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software
19 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
29 # error This library requires C++
43 #include "Include/compiler.h"
44 #ifdef FG_HAVE_STD_INCLUDES
50 #include <FDM/flight.hxx>
53 #include "lowleveltime.h"
55 // Define a structure containing global time parameters
59 // tzContainer stores all the current Timezone control points/
60 TimezoneContainer* tzContainer;
62 //Store the current local timezone name;
65 // Unix "calendar" time in seconds
68 // Break down of GMT time
74 // modified Julian date
77 double last_mjd, last_dy;
80 // side real time at prime meridian
83 // local side real time
86 // the difference between the precise sidereal time algorithm
87 // result and the course result. course + diff has good accuracy
91 // An offset in seconds from the true time. Allows us to adjust
92 // the effective time of day.
95 // How much to change the value of warp each iteration. Allows us
96 // to make time progress faster than normal.
102 void local_update_sky_and_lighting_params( void );
109 inline double getMjd() const { return mjd; };
110 inline double getLst() const { return lst; };
111 inline double getGst() const { return gst; };
112 inline time_t get_cur_time() const { return cur_time; };
113 inline struct tm* getGmt()const { return gmt; };
114 inline bool getPause() const { return pause; };
116 void adjust_warp(int val) { warp += val; };
117 void adjust_warp_delta(int val) { warp_delta += val; };
118 void togglePauseMode() { pause = !pause; };
120 // Initialize the time dependent variables
121 void init(const FGInterface& f);
123 // Update the time dependent variables
124 void update(const FGInterface& f);
126 void cal_mjd (int mn, double dy, int yr);
128 double sidereal_precise (double lng);
129 double sidereal_course(double lng);
130 static FGTime *cur_time_params;
132 // Some other stuff which were changed to FGTime members on
133 // questionable grounds -:)
134 // time_t get_start_gmt(int year);
135 time_t get_gmt(int year, int month, int day,
136 int hour, int minute, int second);
137 time_t get_gmt(struct tm* the_time);
139 char* format_time( const struct tm* p, char* buf );
140 long int fix_up_timezone( long int timezone_orig );
144 inline time_t FGTime::get_gmt(struct tm* the_time) // this is just a wrapper
146 //printf("Using: %24s as input\n", asctime(the_time));
147 return get_gmt(the_time->tm_year,
156 #endif // _FG_TIME_HXX