]> git.mxchange.org Git - simgear.git/blobdiff - simgear/timing/sg_time.hxx
MacOS tweaks contributed by Darrell Walisser.
[simgear.git] / simgear / timing / sg_time.hxx
index 5a6da887ae7dc65d6e2155e0702f9b2c6479badb..319afec61df0207dd0e28b2f06344a512ad383ea 100644 (file)
@@ -4,19 +4,20 @@
 //
 // 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$
 
@@ -42,7 +43,7 @@
 #  include <time.h>
 #endif
 
-#include "timezone.h"
+#include <simgear/timing/timezone.h>
 
 
 // Define a structure containing time parameters
@@ -83,52 +84,43 @@ private:
 
 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