Skip to content

Commit

Permalink
add getBeiDouDate and note some more leap second errors
Browse files Browse the repository at this point in the history
  • Loading branch information
berthubert committed Aug 2, 2021
1 parent aa8c3b2 commit 07c07dd
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
17 changes: 14 additions & 3 deletions navmon.cc
Original file line number Diff line number Diff line change
Expand Up @@ -292,22 +292,33 @@ std::string makeSatPartialName(const SatID& satid)
return fmt::sprintf("%c%02d", getGNSSChar(satid.gnss), satid.sv);
}

int g_dtLS{18}, g_dtLSBeidou{4};

void getGPSDateFromUTC(time_t t, int& wn, int& tow)
{
t -= 315964800;
t += 18;
t += 18; // XXXXXX LEAP SECOND
wn = t/(7*86400);
tow = t%(7*86400);
}
void getGalDateFromUTC(time_t t, int& wn, int& tow)
{
t -= 935280000;
t += 18;
t += 18; // XXXXXXX LEAP SECOND
wn = t/(7*86400);
tow = t%(7*86400);
}

int g_dtLS{18}, g_dtLSBeidou{4};
void getBeiDouDateFromUTC(time_t t, int&wn, int& sow)
{
// Week number count started from zero at 00:00:00 on Jan. 1, 2006 of BDT
t -= 1136070000;
t+= g_dtLSBeidou;
wn = t/(7*86400);
sow = t%(7*86400);
}


uint64_t utcFromGST(int wn, int tow)
{
return (935280000 + wn * 7*86400 + tow - g_dtLS);
Expand Down
2 changes: 1 addition & 1 deletion navmon.hh
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ double utcFromGPS(int wn, double tow);

void getGPSDateFromUTC(time_t t, int& wn, int& tow);
void getGalDateFromUTC(time_t t, int& wn, int& tow);

void getBeiDouDateFromUTC(time_t t, int&wn, int& sow);

std::string makeHexDump(const std::string& str);
std::string makeHexDump(const std::basic_string<uint8_t>& str);
Expand Down

0 comments on commit 07c07dd

Please sign in to comment.