[Datetime-SIG] PEP-495 - Strict Invalid Time Checking

Alexander Belopolsky alexander.belopolsky at gmail.com
Tue Aug 25 22:24:58 CEST 2015


On Tue, Aug 25, 2015 at 4:13 PM, Carl Meyer <carl at oddbird.net> wrote:

> You are missing the crux of my use case, which is that I need to
> generate a calendar to display to the user, with all the half-hour slots
> from midnight to midnight for one day in it
>

Got it.  How is this then

start = datetime.combine(date, time(0)).astimezone()
while True:
    end = (start + timedelta(hours=0.5)).astimezone()
    print(start, end)
    start = end
    if end.time() == time(0):
        break
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/datetime-sig/attachments/20150825/4c3c9f79/attachment.html>


More information about the Datetime-SIG mailing list