Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #106255

Re: Set type for datetime intervals

From Michael Selik <michael.selik@gmail.com>
Newsgroups comp.lang.python
Subject Re: Set type for datetime intervals
Date 2016-04-01 20:31 +0000
Message-ID <mailman.328.1459542711.28225.python-list@python.org> (permalink)
References <56FE0625.5030901@shopzeus.com>

Show all headers | View raw


On Fri, Apr 1, 2016 at 1:32 AM Nagy László Zsolt <gandalf@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))

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: Set type for datetime intervals Michael Selik <michael.selik@gmail.com> - 2016-04-01 20:31 +0000

csiph-web