Christian Heimes wrote: > M.-A. Lemburg schrieb: >> Christian Heimes wrote: >>> Ben Finney wrote: >>>> If you're committed to changing the epoch anyway, I would recommend >>>> using <URL:http://en.wikipedia.org/wiki/Astronomical_year_numbering> >>>> (epoch at 4004 BCE) since it is widely used to unify dates referring to >>>> human history. >>> I prefer JDN or MJD (http://en.wikipedia.org/wiki/JDN) for dates long >>> before or after the unix epoch. The conversion from JDN as float to a >>> datetime object is trivial. >> >> FWIW, mxDateTime can help you with all of those: >> >>>>> import mx.DateTime >>>>> mx.DateTime.DateTimeFrom('1.1.4004 BCE') >> <mx.DateTime.DateTime object for '-4003-01-01 00:00:00.00' at 2b534a46a2f0> >>>>> mx.DateTime.DateTimeFrom('1.1.4004 BCE').jdn >> 258994.5 >>>>> mx.DateTime.DateTimeFromJDN(258994.5) >> <mx.DateTime.DateTime object for '-4003-01-01 00:00:00.00' at 2b534aeb72f0> >>>>> mx.DateTime.DateTimeFrom('1.1.4004 BCE').mjd >> -2141006.0 >>>>> mx.DateTime.DateTimeFromMJD(-2141006.0) >> <mx.DateTime.DateTime object for '-4003-01-01 00:00:00.00' at 2b534a46a2f0> >> >> The supported date range is limited by the number of days >> that fit into a C long. Should be enough for most use cases :-) > > Nice ... :) I didn't know that mxDateTime has support for Julian Date.
It also implements the TJD that's sometimes used in the US (the NIST definition of it): >>> mx.DateTime.DateTimeFrom('1.1.4004 BCE').tjd -1006.0 >>> mx.DateTime.DateTimeFrom('1.1.4004 BCE').tjd_myriad 26 >>> mx.DateTime.DateTimeFromTJD(-1006.0, 26) <mx.DateTime.DateTime object for '-4003-01-01 00:00:00.00' at 2b81d4a58558> And has support for the Julian calendar: >>> mx.DateTime.JulianDateTime(1752, 9, 2).Gregorian() <mx.DateTime.DateTime object for '1752-09-13 00:00:00.00' at 2b81d4a6eb88> which is sometimes handy for historical dates: http://en.wikipedia.org/wiki/Julian_calendar -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Oct 07 2009) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ ::: Try our new mxODBC.Connect Python Database Interface for free ! :::: eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48 D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg Registered at Amtsgericht Duesseldorf: HRB 46611 http://www.egenix.com/company/contact/ -- http://mail.python.org/mailman/listinfo/python-list