mirror of
https://github.com/pocoproject/poco.git
synced 2025-02-21 06:37:42 +01:00
fix(NTPClient): NTPClient ignores second fractions #2614
This commit is contained in:
parent
6dc79c05f9
commit
aa71874f2c
@ -149,9 +149,10 @@ Poco::Timestamp NTPPacket::transmitTime() const
|
||||
Poco::Timestamp NTPPacket::convertTime(Poco::Int64 tm) const
|
||||
{
|
||||
const unsigned long seventyYears = 2208988800UL;
|
||||
Poco::UInt32 secsSince1900 = UInt32(Poco::ByteOrder::toLittleEndian(tm) >> 32);
|
||||
unsigned long epoch = secsSince1900 - seventyYears;
|
||||
return Poco::Timestamp::fromEpochTime(epoch);
|
||||
Poco::UInt64 ntpTime = Poco::ByteOrder::toLittleEndian(tm);
|
||||
Poco::UInt64 secs = ((ntpTime >> 32) - seventyYears) * 1000000;
|
||||
Poco::UInt64 frac = ((ntpTime & 0xFFFFFFFF) * 1000000) >> 32;
|
||||
return Poco::Timestamp(secs+frac);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user