[Python-Dev] datetime module enhancements
lists at cheimes.de
Fri Mar 9 17:03:16 CET 2007
This is my first posting to the Python developer list so please forgive
me if I'm doing something wrong.
In the past few weeks I've worked a lot with dates and times. I found
several small annoyances in the datetime module. For example there was
no obvious way to cast a timedelta to an int or float. I'm proposing
some small additions to the datetime module:
>>> td = timedelta(minutes=1, seconds=7, microseconds=500)
datetime.datetime has a method (class factory) fromtimestamp() but its
instances are missing a totimestamp() method that return the Unix
timestamp for a date (seconds since 1970-01-01 00:00:00 UTC).
Some people might miss a from and to julian day number (JDN) and
modified julian day (MJD) converter in datetime.date and
datetime.datetime. MJD is used as base in VMS and JDN, MJD and RJD are
used by astronomers. It's also very useful when one has to deal with
dates before 0 and converting dates between foreign calendars.
November 17, 1858 is the base of the Modified Julian Day system.
The original Julian Day (JD) is used by astronomers and expressed in
days since noon January 1, 4713 B.C. This measure of time was
introduced by Joseph Scaliger in the 16th century. It is named in
honor of his father, Julius Caesar Scaliger (note that this Julian Day
is different from the Julian calendar named for the Roman Emperor
I'm willing to implement the features myself but I need a mentor who
helps me to correct my code and applies it to the Python svn repository.
A patch for timedelta is already available at
More information about the Python-Dev