[Python-ideas] datetime: Support infinity

M.-A. Lemburg mal at egenix.com
Mon Jan 26 09:36:52 CET 2015


On 26.01.2015 09:24, Thomas Güttler wrote:
> Hi,
> 
> postgreSQL supports infinity for datetime:
> 
> http://www.postgresql.org/docs/current/static/datatype-datetime.html#AEN6027
> 
> {{{
> infinity     date, timestamp     later than all other time stamps
> -infinity     date, timestamp     earlier than all other time stamps
> }}}
> 
> 
> Mapping this to python is not possible at the moment.
> 
> See:
> 
> http://initd.org/psycopg/docs/usage.html#infinite-dates-handling
> 
> {{{
> PostgreSQL can store the representation of an “infinite” date, timestamp, or interval. Infinite
> dates are not available to Python, so these objects are mapped to date.max, datetime.max,
> interval.max. Unfortunately the mapping cannot be bidirectional so these dates will be stored back
> into the database with their values, such as 9999-12-31.
> }}}
> 
> I don't know the internals of the datetime module. I guess it is not possible to support infinity.
> 
> What do you think?

Leaving aside the question of how useful such date/time values
would be, you can use the PG work-around for supporting these
in Python as well.

In mxDateTime, we have special values which can be used for this:

>>> mx.DateTime.MaxDateTime
<mx.DateTime.DateTime object for '25200470046051299-12-31 00:00:00.00' at 7fd7c4b3b2b8>
>>> mx.DateTime.MinDateTime
<mx.DateTime.DateTime object for '-25200470046051299-01-01 00:00:00.00' at 7fd7c4b3b390>

-- 
Marc-Andre Lemburg
eGenix.com

Professional Python Services directly from the Source  (#1, Jan 26 2015)
>>> Python Projects, Coaching and Consulting ...  http://www.egenix.com/
>>> mxODBC Plone/Zope Database Adapter ...       http://zope.egenix.com/
>>> mxODBC, mxDateTime, mxTextTools ...        http://python.egenix.com/
________________________________________________________________________

::::: Try our 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/


More information about the Python-ideas mailing list