ariebovenberg / whenever

⏰ Modern datetime library for Python, available in Rust or pure Python
https://whenever.rtfd.io
MIT License
831 stars 13 forks source link

An interval type #37

Open ariebovenberg opened 8 months ago

ariebovenberg commented 8 months ago

Something that's quite common in datetime libraries is an 'interval' type.

It's not the question whether such a thing could be implemented, but whether it is possible to define the 'just right' abstraction that supports the common use cases without being overly complex.

Questions that come to mind:

simon04 commented 2 months ago

are intervals always closed-open, or are other variants possible?

Citing from https://www.reddit.com/r/ISO8601/comments/1beahww/intervals/:

ISO 8601-1:2019 states

3.1.1.6 time interval part of the time axis limited by two instants and, unless otherwise stated, the limiting instants themselves

so it's inclusive-inclusive by default, but it's probably better to specify it yourself because it's not reasonable for someone to expect 12:00/13:00 to be 61 minutes long