On Tue, Aug 25, 2015 at 4:30 PM, Carl Meyer <[email protected]> wrote:

> > 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
>
> On DST transition days, this code does not generate exactly 48 slots,
> displayable to the user in a schedule that includes all hours from 0 to
> 23 labeled exactly once.
>
> That introduces an unacceptable level of additional display-layer
> complexity, and remains inferior to the "strict checking" solution I chose.


OK.  So you just want [datetime.combine(date, time(0)) +
timedelta(hours=0.5*i)) for i in range(48)] but detect those that are
either in the fold or in the gap?  Just check for dt.astimezone() !=
dt.replace(fold=1).astimezone() instead of catching the strict exceptions.
_______________________________________________
Datetime-SIG mailing list
[email protected]
https://mail.python.org/mailman/listinfo/datetime-sig
The PSF Code of Conduct applies to this mailing list: 
https://www.python.org/psf/codeofconduct/

Reply via email to