Set type for datetime intervals

Michael Selik michael.selik at gmail.com
Fri Apr 1 16:32:43 EDT 2016


Whoops, I mixed up tasks. Here's what I meant:

    def interval(start, stop, precision=60):
        a, b = start.timestamp(), stop.timestamp()
        return set(range(a, b, precision))

On Fri, Apr 1, 2016 at 4:31 PM Michael Selik <michael.selik at gmail.com>
wrote:

> On Fri, Apr 1, 2016 at 1:32 AM Nagy László Zsolt <gandalf at shopzeus.com>
> wrote:
>
>> Does anyone know a library that already implements these functions?
>>
>
> What do you not like about the ones on PyPI?
> https://pypi.python.org/pypi?%3Aaction=search&term=interval&submit=search
>
> Depending on the resolution you want, you might be able to use builtin
> sets for everything.
>
>     def interval(start, stop, precision=60):
>         a = round(start.timestamp(), precision)
>         b = round(stop.timestamp(), precision)
>         return set(range(a, b, precision))
>



More information about the Python-list mailing list