datetime-interval now on PyPI
datetime module provides useful representations of points in time (
datetime) as well as durations of time (
timedelta). However, it does not provide a representation of an interval of time, starting at a specific point and lasting for a duration. A representation such as this would be useful for representing calendar events. To fill this need, I’ve implemented
datetime-interval provides two classes:
Interval provides a structure for keeping track of events with start and end times.
PeriodicInterval provides a representation for recurring events, with a period and a count of occurrences.
I’ve not yet tested it or used it too extensively, so caveat operator. There are a few things that I’d like to add in before using it more:
- Interval should have an
isoformatmethod which returns strings of the form “start/end”.
- This wouldn’t work on PeriodicInterval, as recurring intervals have a different semantics in ISO 8601.
- Property-based testing with
- Add operators (in, +, -, *, , etc.).
- How to account for recurrences such as every Tuesday and Thursday.