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

Carl Meyer carl at oddbird.net
Tue Aug 25 22:33:57 CEST 2015

On 08/25/2015 02:30 PM, Carl Meyer wrote:
> On 08/25/2015 02:24 PM, Alexander Belopolsky wrote:
>> On Tue, Aug 25, 2015 at 4:13 PM, Carl Meyer <carl at oddbird.net
>> <mailto: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
> 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.

To further explain this requirement: days can be displayed adjacent to
each other in a weekly view, so the server must provide to the client
exactly 48 slot data structures per day (including DST transition days),
which can be laid out in a strict grid, where all the days share the
same set of time labels on the left.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP digital signature
URL: <http://mail.python.org/pipermail/datetime-sig/attachments/20150825/54b4bc4c/attachment.sig>

More information about the Datetime-SIG mailing list