Converting a TAI date and time to UTC
In order to convert a TAI date and time to UTC, you must first
obtain the leap second data by using one of the methods described
in Obtaining a list of leap seconds. Then, you can use the
LeapSecondData.tai_to_utc() method to convert the date and time.
For example:
from datetime import datetime
from leapseconddata import LeapSecondData, tai
my_date = datetime(2024, 7, 18, 22, 0, 37, tzinfo=tai)
data = LeapSecondData.from_standard_source()
my_tai_date = data.tai_to_utc(my_date)
print(my_tai_date.isoformat())
This program will provide you with the following output:
2024-07-18T22:00:00+00:00