'Convert NTP timestamp to Unix time

I am getting the current time from an NTP server. The reference epoch of NTP is 0:00:00.000 on 1 January 1900 and the library I use for NTP returns the number of seconds that elapsed since that reference epoch. As you can see, it works similarily to Unix time, except that it uses a different reference epoch. My goal is therefore to convert this NTP timestamp to a unix timestamp, while avoiding all those weird things like leap years, leap seconds and all those other weird things that humans did to their time scale.

The naive approach would obviously be to calculate the number of seconds that happened between the NTP reference epoch and the Unix reference epoch, store that as a constant and subtract that from the NTP timestamp, but I have a feeling that I would be too stupid for that and forget some of the aforementioned oddities. My question is therefore whether Python has some built-in function or whether there's a library to do just that.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source