3 #include <utl/UTCDate.h>
4 #include <utl/LeapSeconds.h>
16 if (low != fGPSToUnixLeaps.end())
17 leap = (low->first == gpsSecond && low->second.first == 1);
19 unixSecond = fGPSEpochInUnixSeconds + gpsSecond + low->second.second;
30 gpsSecond = unixSecond - fGPSEpochInUnixSeconds + up->second;
51 const DateLeap leaps[] = {
72 const int n =
sizeof(leaps) /
sizeof(DateLeap);
75 fGPSToUnixLeaps[0] = make_pair(0, 0);
76 fUnixToGPSLeaps[0] = 0;
78 for (
int i = 0; i < n; ++i) {
79 const time_t unixSecond = leaps[i].fNextDay.GetUnixSecond();
80 const unsigned long gpsSecond = unixSecond - fGPSEpochInUnixSeconds + totalLeaps;
81 const int leap = leaps[i].fLeap;
83 fGPSToUnixLeaps[gpsSecond] = make_pair(leap, -totalLeaps);
84 fUnixToGPSLeaps[unixSecond] = totalLeaps;
93 cout <<
"GPS->Unix\n";
95 it != fGPSToUnixLeaps.end(); ++it)
96 cout << it->first <<
": "
97 << it->second.first <<
' ' << it->second.second <<
'\n';
98 cout <<
"Unix->GPS\n";
100 it != fUnixToGPSLeaps.end(); ++it)
101 cout << it->first <<
" (" << (it->first - fGPSEpochInUnixSeconds) <<
"): "
102 << it->second <<
'\n';
109 const char*
const tz = getenv(
"TZ");
111 fTZ =
new string(tz);
121 setenv(
"TZ", fTZ->c_str(), 1);
std::time_t GetUnixSecond() const
Relative to Unix epoch (1 Jan 1970 00:00:00 UTC) without leap corrections.
UnixToGPSMap::const_iterator UnixToGPSIterator
static UTCDate GetGPSEpoch()
bool ConvertGPSToUnix(const unsigned long gpsSecond, time_t &unixSecond) const
returns true if the GPS second is an UTC leap second
GPSToUnixMap::const_iterator GPSToUnixIterator
void ConvertUnixToGPS(const time_t unixSecond, unsigned long &gpsSecond) const