[Python-ideas] Date/time literals

Mark Dickinson dickinsm at gmail.com
Wed Jun 2 12:50:11 CEST 2010


On Tue, Jun 1, 2010 at 11:40 PM, Guido van Rossum <guido at python.org> wrote:
> Also note that there will be no validation possible for future
> datetimes (and for past dates it would require an up-to-date leap
> second database).

It's even worse than that :(.  Complete validation would also require
timezone knowledge, because leap seconds happen at the same instant
the world over:  e.g., the leap second that occurred at 23:59:60 UTC
on 31st December 2008 occurred at 19:29:60 local time in Caracas.   So
for naive datetime objects validation is going to be difficult.  Given
that timezone offsets can be an arbitrary number of minutes, the only
reasonable options as far as I can see would be either *always* to
accept seconds in the range 0-60, or *always* restrict the range to
0-59, as now.  (Well, you could only accept seconds=60 for timestamps
within 24 hours of midnight on Jun 30 or Dec 31st, but that's fairly
horrible. :-)

I'm still not convinced that incorrectly accepting some invalid UTC
times is worse than incorrectly rejecting some (rare) valid UTC times,
but I'll let it drop for now.

-- 
Mark



More information about the Python-ideas mailing list