Add a function to get the timezone description
This commit is contained in:
parent
feaac37705
commit
1ea11d987e
@ -90,7 +90,8 @@ void SGTime::init( const SGGeod& location, const SGPath& root, time_t init_time
|
||||
|
||||
SGTimeZone* nearestTz = static_tzContainer->getNearest(location);
|
||||
if (nearestTz) {
|
||||
SGPath name = root / nearestTz->getDescription();
|
||||
description = nearestTz->getDescription();
|
||||
SGPath name = root / description;
|
||||
zonename = name.utf8Str();
|
||||
SG_LOG( SG_EVENT, SG_DEBUG, "Using zonename = " << zonename );
|
||||
} else {
|
||||
@ -117,11 +118,6 @@ SGTime::SGTime() {
|
||||
}
|
||||
|
||||
|
||||
SGTime::~SGTime()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// given Julian Date and Longitude (decimal degrees West) compute
|
||||
// Local Sidereal Time, in decimal hours.
|
||||
//
|
||||
@ -231,9 +227,10 @@ void SGTime::updateLocal( const SGGeod& aLocation, const SGPath& root ) {
|
||||
time_t currGMT;
|
||||
time_t aircraftLocalTime;
|
||||
SGTimeZone* nearestTz = static_tzContainer->getNearest(location);
|
||||
SGPath zone( root );
|
||||
zone.append ( nearestTz->getDescription() );
|
||||
description = nearestTz->getDescription();
|
||||
SGPath zone = root / description;
|
||||
zonename = zone.utf8Str();
|
||||
SG_LOG( SG_EVENT, SG_DEBUG, "Using zonename = " << zonename );
|
||||
|
||||
//Avoid troubles when zone.tab hasn't got the right line endings
|
||||
if (zonename[zonename.size()-1] == '\r')
|
||||
|
@ -38,7 +38,7 @@
|
||||
// forward decls
|
||||
class SGPath;
|
||||
class SGGeod;
|
||||
|
||||
|
||||
/**
|
||||
* A class to calculate and manage a variety of time parameters.
|
||||
* The SGTime class provides many real-world time values. It
|
||||
@ -63,9 +63,12 @@ class SGTime {
|
||||
|
||||
private:
|
||||
|
||||
// Points to the current local timezone name;
|
||||
// Points to the current local timezone filename
|
||||
std::string zonename;
|
||||
|
||||
// Points to the current local timezone description
|
||||
std::string description;
|
||||
|
||||
// Unix "calendar" time in seconds
|
||||
time_t cur_time;
|
||||
|
||||
@ -129,9 +132,9 @@ public:
|
||||
SGTime( const SGPath& root );
|
||||
|
||||
/** Destructor */
|
||||
~SGTime();
|
||||
~SGTime() = default;
|
||||
|
||||
/**
|
||||
/**
|
||||
* Update the time related variables.
|
||||
* The update() method requires you to pass in your position and
|
||||
* an optional time offset in seconds. The offset (or warp) allows
|
||||
@ -163,9 +166,12 @@ public:
|
||||
/** @return current system/unix time in seconds */
|
||||
inline time_t get_cur_time() const { return cur_time; };
|
||||
|
||||
/** @return time zone name for your current position*/
|
||||
/** @return time zone filename for your current position */
|
||||
inline const char * get_zonename() const { return zonename.c_str(); }
|
||||
|
||||
/** @return time zone description for your current position */
|
||||
inline const char * get_description() const { return description.c_str(); }
|
||||
|
||||
/** @return GMT in a "brokent down" tm structure */
|
||||
inline struct tm* getGmt()const { return (struct tm *)&m_gmt; };
|
||||
|
||||
@ -200,7 +206,7 @@ public:
|
||||
* @param second current second
|
||||
* @return unix/system time in seconds
|
||||
*/
|
||||
time_t sgTimeGetGMT(int year, int month, int day,
|
||||
time_t sgTimeGetGMT(int year, int month, int day,
|
||||
int hour, int minute, int second);
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user