I'm actually looking for the opposite of this question: Converting string into datetime
I have a list of datetime objects and I want to create a human-friendly string from them, e.g., "Jan 27 and 30, Feb 4, 2012". Any ideas?
Note that strftime only works on a single datetime object. The problem here is that you have a list of datetimes that might not be evenly spaced, might cross month or year boundaries, but the entire range of dates has to be expressed in a single, concise string.
This.
UPDATE: You need list comprehension to do it in one line.
Or, use a for loop:
UPDATE 2: This I believe is closer to what you expect, but still what you want, only you knows it: when do you want to show the year, when not? when to show the month or the day only, etc... But this is basically an idea. You'll have maybe to do some kind of a class to represent the ranges, where you could choose the format there, comparing months and years between the ranges, ... That's what I came up with now. Hope it helps: