Hey I am working in python with datetime and I am wondering what the best way to parse this timestamp is.
The timestamps are ISO standard, here is an example “2010-06-19T08:17:14.078685237Z”
Now so far I have used
time = datetime.datetime.strptime(timestamp.split(".")[0], "%Y-%m-%dT%H:%M:%S")
precisetime = time + datetime.timedelta(0,float("." + timestamp[:-1].split(".")[0]))
This kind of works, but I feel like there should be a more streamlined way (I am very new to python, and I am sure I am doing this like an ass). Also, I have nanoseconds in my timestamp, but only microseconds in my datetime object, is there a better module to work with? I need to be able to do operations on the time such as subtracting times and putting them in the scheduler.
Any better way to go about this?
There’s nothing inherently ass-like with your approach, but you may like to try pyiso8601 or dateutil