[Python-ideas] Pythonic Dates, Times, and Deltas

Nathan Schneider neatnate at gmail.com
Fri Oct 15 00:01:42 CEST 2010


I'm glad to see there's interest in solving this (seems I'm not alone
in seeing date/time support as the ugly stepchild of the Python
standard library).

For what it's worth, not too long ago I ended up writing a bunch of
convenience functions to instantiate and convert between existing
date/time representations (datetime objects, time tuples, timestamps,
and string representations). The result is here, in case anyone's
interested:

http://www.cs.cmu.edu/~nschneid/docs/temporal.py

Cheers,
Nathan

On Thu, Oct 14, 2010 at 2:54 PM, Daniel G. Taylor
<dan at programmer-art.org> wrote:
> On 10/13/2010 06:16 PM, Dag Odenhall wrote:
>>
>> Not convinced your library is very Pythonic. Why a tuple attribute
>> instead of having date objects be iterable so you can do tuple(Date())?
>
> How do you envision this working for days, weeks, months, years? E.g.
> getting the min/max Date objects for today, for next week, for this current
> month, etc.
>
> I'm very open to ideas here; I just implemented what made sense to me at the
> time.
>
>> How does the fancy formats deal with locales?
>
> It internally uses datetime.strftime, so will behave however that behaves
> with regard to locales.
>
>> Is there support for ISO 8601? Should probably be the __str__.
>
> Not built-in other than supporting a strftime method. This is a good idea
> and I will probably add it.
>
>> +1 on the general idea, though.
>
> Thanks :-)
>
> Take care,
> --
> Daniel G. Taylor
> http://programmer-art.org/
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> http://mail.python.org/mailman/listinfo/python-ideas
>



More information about the Python-ideas mailing list