Postgres asside, a infinity and minus infinity datetime would be generally useful, Useful enough that I wrote them for my code base. And early the postgress folks think it's a useful construct. So +1 on adding this -- and not just hacked into the postgress adapter. My use case is thus: We have a model that does a computation through time. Various objects can be active for a given time period. We use datetimes to store the active_start and active_stop. For objects that are always active up to a particular stop time, or become active at a particular time, and then stay active forever, we needed a way to express -infTime and infTime. It probably would have mostly worked to use the min and max datetime values, but then we lose information to pass back to the user. We also convert to-from numpy datetimes, which have a different range. I have a sample implementation if anyone wants to look amateur it, though I don't think it does reflected comparisons correctly. it's really only just good enough for our use case. -Chris
On Jan 26, 2015, at 12:31 AM, "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?
Thomas Güttler _______________________________________________ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/