Python Time classes

Warren Postma embed at geocities.com
Thu Apr 27 13:46:55 EDT 2000


"phil hunt" <philh at vision25.demon.co.uk> wrote in message
news:slrn8ge5b0.1gu.philh at vision25.demon.co.uk...
> Is there a high-level Time class for Python?
>
> I'm aware of the 'time' module in the standard library. But I'm
> looking for something more high-level (I can't find anything
> relevant on Parnassus or Freshmeat). What I want is roughly the
> ability to say things like:
>
>    t1 = Time.now()
>    # (t1) is an instance of Time containing the time now
>
>    t2 = Time(2000, 4, 26, 17, 4, 0)


mxDateTime does exactly this and more. It even comes with nifty code to
synchronize you with an atomic clock, and a variety of wrapper classes
designed for various purposes. It can handle historical dates (dates before
the Unix epoch, Jan 1, 1970) and can handle the milliseconds component of
Time values without problems, as well as handling day of week, leap-years,
and even includes code for algorithms for moveable feasts (When is Easter
Sunday in the year 2143, for instance.)

The core date time object is written in C, and all the extraneous stuff is
in Python modules (.py), which is pretty nice.

I hope they rename mxDateTime to DateTime and roll it right into the stock
Python distribution at some point. It just seems "right" to me that Python
should include a powerful date and time handling object as a native type,
along with lists, dictionaries, tuples, and other objects.

Warren





More information about the Python-list mailing list