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)`?
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at
https://mail.python.org/archives/list/python-ideas@python.org/message/2GZ5BNIGV43224QWTUCYO57MB7E7BDTB/
Code of Conduct: http://python.org/psf/codeofconduct/