-
Notifications
You must be signed in to change notification settings - Fork 38
Open
Description
See https://projects.engineering.redhat.com/browse/ERRATA-9192 .
I believe just adding a '%f' to the format string is enough to get it working. You could consider trying to make it work with either format to make the transition easier, maybe with a wrapper function.
Question: Is there any particular reason why datetime.datetime.strptime is used in some places and time.strptime in others? Could it be made consistent for all the timestamp parsing?
Actually we might still change Errata Tool back to use the old format in the short term, which would mean this isn't needed.
import time
import datetime
short_format = "2019-12-05T00:00:00"
long_format = "2019-12-05T00:00:00.000Z"
#d = short_format
d = long_format
print(time.strptime(str(d), '%Y-%m-%dT%H:%M:%S.%fZ'))
#=> time.struct_time(tm_year=2019, tm_mon=12, tm_mday=5, tm_hour=0, tm_min=0, tm_sec=0, tm_wday=3, tm_yday=339, tm_isdst=-1)
print(datetime.datetime.strptime(str(d), '%Y-%m-%dT%H:%M:%S.%fZ'))
#=> 2019-12-05 00:00:00
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels