I know that the same questions were asked, but they seem to be related to the way datetime deals (or doesn't) with time zones.
The setup is a bit complicated and probably not related to the problem, but I thought it was important to include the code as is, so a bit of background:
I have a dictionary of arrays. Each of these arrays represents an “attempt” of the same person, but occurs at different times. Ultimately, I will look for the earliest of these dates. This might be a bit of a workaround, but I convert all dates to datetime objects, find the earliest, and then just use this index to pull out the first try:
Here is the code for setting up this datetimes attempt array:
for key in duplicates_set.keys(): attempt_dates = [datetime.strptime(attempt['Attempt Date'], "%-m-%-d-%y %-H:%M:%S") for attempt in duplicates_set[key]]
Here is a format that looks like one of the source lines:
12-5-2016 3:27:58 PM
What I get is:
ValueError: '-' is a bad directive in format '%-m-%d-%y %-H:%M:%S'
I assume that referring to the dashes placed before the "m", "d" and "H" because they are non-zero decimal places. Why does this tell me that?
source share