
16.06.20 13:54, Alexander Hill пише:
I’d like to propose support for infinite dates, datetimes and timedeltas. They're very useful when you need to model ranges with one or both ends unbounded (e.g. “forever starting from June 15th 2020”).
Without first-class infinite values, you can use None, or you can use the `min` and `max` attributes of Python’s datetime types, or some other arbitrary large values. Using None means you need to implement a path for None, and a path for everything else, and your various infinite values are indistinguishable. Using max/min means comparisons just work, but calculations need special treatment and you’re fundamentally misrepresenting your meaning.
Temporal infinities give the best of both worlds: infinite values that interoperate seamlessly with the built-in types and behave sensibly and predictably. They’re also supported by Postgres!
First we need to solve some problems. 1. Parsing dates with more than 4-digit year. Note that many external implementations do not support such data, so we need a way to restrict the data range when convert them to string representation. 2. String representations and parsing for negative data. 3. String representations and parsing for infinity data (positive and negative). 4. If datetime.min will be the negative infinity, then what will be the result of `datetime.now() - datetime.min`? Or `(datetime.now() - datetime.min) // timedelta(days=1)`?