more sensible so we can do a more reasonable external view.
Fixed some const incorrectness.
// Initialize the time dependent variables (maybe I'll put this in the
// constructor later)
-void FGTime::init(FGInterface *f)
+void FGTime::init(const FGInterface& f)
{
FG_LOG( FG_EVENT, FG_INFO, "Initializing Time" );
gst_diff = -9999.0;
// printf ("Current greenwich mean time = %24s", asctime(gmtime(&cur_time)));
// printf ("Current local time = %24s", asctime(localtime(&cur_time)));
// time_t tmp = cur_time;
- GeoCoord location(RAD_TO_DEG * f->get_Latitude(),
- RAD_TO_DEG * f->get_Longitude());
+ GeoCoord location(RAD_TO_DEG * f.get_Latitude(),
+ RAD_TO_DEG * f.get_Longitude());
GeoCoord* nearestTz = tzContainer->getNearest(location);
// Update time variables such as gmt, julian date, and sidereal time
-void FGTime::update(FGInterface *f)
+void FGTime::update(const FGInterface& f)
{
double gst_precise, gst_course;
gst_diff = gst_precise - gst_course;
- lst = sidereal_course(-(f->get_Longitude() * RAD_TO_DEG)) + gst_diff;
+ lst = sidereal_course(-(f.get_Longitude() * RAD_TO_DEG)) + gst_diff;
} else {
// course + difference should drift off very slowly
gst = sidereal_course( 0.00 ) + gst_diff;
- lst = sidereal_course( -(f->get_Longitude() * RAD_TO_DEG)) + gst_diff;
+ lst = sidereal_course( -(f.get_Longitude() * RAD_TO_DEG)) + gst_diff;
}
FG_LOG( FG_EVENT, FG_DEBUG,
" Current lon=0.00 Sidereal Time = " << gst );
FG_LOG( FG_EVENT, FG_DEBUG,
" Current LOCAL Sidereal Time = " << lst << " ("
- << sidereal_precise(-(f->get_Longitude() * RAD_TO_DEG))
+ << sidereal_precise(-(f.get_Longitude() * RAD_TO_DEG))
<< ") (diff = " << gst_diff << ")" );
}
void togglePauseMode() { pause = !pause; };
// Initialize the time dependent variables
- void init(FGInterface *f);
+ void init(const FGInterface& f);
// Update the time dependent variables
- void update(FGInterface *f);
+ void update(const FGInterface& f);
void cal_mjd (int mn, double dy, int yr);
void utc_gst();
static struct leap *leaps = NULL;
-static void fgtzset_internal (int always, char*tz);
+static void fgtzset_internal (int always, const char *tz);
static int fgtz_compute(time_t timer, const struct tm *tm);
static int fgcompute_change(fgtz_rule *rule, int year);
static struct ttinfo *fgfind_transition (time_t timer);
/* Return the `struct tm' representation of *T in local time. */
-struct tm * fgLocaltime (const time_t *t, char *tzName)
+struct tm * fgLocaltime (const time_t *t, const char *tzName)
{
return fgtz_convert (t, 1, &_fgtmbuf, tzName);
}
/* Return the `struct tm' representation of *TIMER in the local timezone.
Use local time if USE_LOCALTIME is nonzero, UTC otherwise. */
-struct tm * fgtz_convert (const time_t *timer, int use_localtime, struct tm *tp, char *tzName)
+struct tm * fgtz_convert (const time_t *timer, int use_localtime, struct tm *tp, const char *tzName)
{
long int leap_correction;
long int offsetCorr; // ADDED TO RESOLVE NON-ANSI FIELDS IN struct tm
/* Interpret the TZ envariable. */
-static void fgtzset_internal (int always, char* tz)
+static void fgtzset_internal (int always, const char *tz)
{
time_t now;
time(&now);
void show (const char *zone, time_t t, int v);
/* adapted from <time.h> */
-struct tm * fgLocaltime (const time_t *t, char *tzName);
+struct tm * fgLocaltime (const time_t *t, const char *tzName);
/* Prototype for the internal function to get information based on TZ. */
extern struct tm *fgtz_convert (const time_t *t, int use_localtime,
- struct tm *tp, char *tzName);
+ struct tm *tp, const char *tzName);
/* This structure contains all the information about a
timezone given in the POSIX standard TZ envariable. */