mirror of
https://github.com/pocoproject/poco.git
synced 2025-05-02 15:41:36 +02: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
|
Poco::Timestamp NTPPacket::convertTime(Poco::Int64 tm) const
|
||||||
{
|
{
|
||||||
const unsigned long seventyYears = 2208988800UL;
|
const unsigned long seventyYears = 2208988800UL;
|
||||||
Poco::UInt32 secsSince1900 = UInt32(Poco::ByteOrder::toLittleEndian(tm) >> 32);
|
Poco::UInt64 ntpTime = Poco::ByteOrder::toLittleEndian(tm);
|
||||||
unsigned long epoch = secsSince1900 - seventyYears;
|
Poco::UInt64 secs = ((ntpTime >> 32) - seventyYears) * 1000000;
|
||||||
return Poco::Timestamp::fromEpochTime(epoch);
|
Poco::UInt64 frac = ((ntpTime & 0xFFFFFFFF) * 1000000) >> 32;
|
||||||
|
return Poco::Timestamp(secs+frac);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user