Standard class for time *period*?
Cameron Simpson
cs at cskk.id.au
Wed Mar 29 19:13:42 EDT 2023
On 29Mar2023 08:17, Loris Bennett <loris.bennett at fu-berlin.de> wrote:
>I am glad to hear that I am not alone :-) However, my use-case is fairly
>trivial, indeed less complicated than yours. So, in truth I don't
>really need a Period class. I just thought it might be a sufficiently
>generic itch that someone else with a more complicated use-case could
>have already scratched.
Well, my attitude to time spans is to get the start and end (or start
and length, but I prefer the former) as UNIX timestamps and work from
that. I try to stay as far from datetimes as possible, because of their
foibles (particularly timezones, but really the whole calendar
decomposition etc) and use them only for presentation.
I do in fact have a `TimePartition` in my timeseries module; it
presently doesn't do comparisons because I'm not comparing them - I'm
just using them as slices into the timeseries data on the whole.
https://github.com/cameron-simpson/css/blob/0ade6d191833b87cab8826d7ecaee4d114992c45/lib/python/cs/timeseries.py#L2163
But it would be easy to give that class `__lt__` etc methods.
You're welcome to use it, or anything from the module (it's on PyPI).
Cheers,
Cameron Simpson <cs at cskk.id.au>
More information about the Python-list
mailing list