I am parsing some data that has the leapsecond timestampe datetime 2012-06-30T23:59:60.209215. I used following code to parse that string and convert to a datet
Do this:
import time
import datetime
t = '2012-06-30T23:59:60.209215'
nofrag, frag = t.split('.')
nofrag_dt = time.strptime(nofrag, "%Y-%m-%dT%H:%M:%S")
ts = datetime.datetime.fromtimestamp(time.mktime(nofrag_dt))
dt = ts.replace(microsecond=int(frag))
print(dt)
Output is:
2012-07-01 00:00:00.209215