[Python-ideas] datetime: Support infinity

Antoine Pitrou solipsis at pitrou.net
Mon Jan 26 10:14:23 CET 2015


On Mon, 26 Jan 2015 09:24:07 +0100
Thomas Güttler
<guettliml at thomas-guettler.de> 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.
> }}}

Unless someone has a real-world use for the values of date.max,
datetime.max, interval.max, I find it rather counter-productive to not
store them back as infinities.

Adding infinities to the datetime module would probably be possible but
someone has to figure out the arithmetic rules. Do we need "not a time"
when adding infinity to -infinity?

Regards

Antoine.




More information about the Python-ideas mailing list