On 2013-03-02 00:12, andydtay...@gmail.com wrote:
Hi,
I need to create a list of equally spaced times (as in hh:mm AM/PM) within a
day to loop through. Having selected 30 minute intervals I figured I could:
* Create a list from 1 to 48
* Multiply each value by 30
* Convert minutes to a time. datetime.timedelta seems to do this, but it's not
a full timestamp which means strftime can't format me a time with am/pm.
can anyone suggest a good approach to use? Ultimately I'd like to generate an
equivalent to this text/format:'2:30 pm'
You can still use strftime, just pick a day but don't include it in the
format.
You can make the list like this:
[(datetime.datetime(2000, 1, 1) + datetime.timedelta(minutes=30) *
i).strftime("%H:%M%p") for i in range(48)]
--
http://mail.python.org/mailman/listinfo/python-list