Spans is a pure Python implementation of PostgreSQL's range types. Range types are conveinent when working with intervals of any kind. Every time you've found yourself working with
date_end, an interval like Spans' range may have been what you were actually looking for.
I originally made Spans back in 2013 as part of my company's workshift management application Permutar. After realizing its usefulness I refactored it into a library and put it on PyPI. I don't have any user statistics, but before download statistics were disabled in June 2016 it had been downloaded at least 18,000 times.
>>> from spans import daterange >>> daterange.from_month(2000, 1) daterange([datetime.date(2000, 1, 1),datetime.date(2000, 2, 1)))
>>> from psycospans import connect >>> from spans import intrange >>> conn = connect("dbname=test") >>> cur = conn.cursor() >>> test_range = intrange(1, 10) >>> cur.execute("SELECT int4range(5, NULL), %s", (test_range,)) >>> a, b = cur.fetchone() >>> a intrange([5,)) >>> b intrange([1,10))