Time ranges with python

Overview

Discord

Badges
Build Python package semantic-release PyPI Read the Docs
Tests coverage pre-commit
Standards SemVer 2.0.0 Conventional Commits
Code Code style: black Imports: isort Checked with mypy
Repo GitHub issues GitHub stars GitHub license All Contributors Contributor Covenant

timeranges

Time ranges.

Read the Docs

Installation

pip

timeranges is available on pip:

pip install timeranges

GitHub

You can also install the latest version of the code directly from GitHub:

pip install git+git://github.com/MicaelJarniac/timeranges

Usage

For more examples, see the full documentation.

10:00" time_range = TimeRange(time(0), time(10)) # Check if these times are contained in `time_range` assert time(0) in time_range assert time(5) in time_range assert time(10) in time_range # Check if these times aren't contained in `time_range` assert time(10, 0, 1) not in time_range assert time(11) not in time_range assert time(20) not in time_range time_range_2 = TimeRange(time(15), time(20)) time_ranges = TimeRanges([time_range, time_range_2]) assert time(0) in time_ranges assert time(5) in time_ranges assert time(10) in time_ranges assert time(12) not in time_ranges assert time(15) in time_ranges assert time(17) in time_ranges assert time(20) in time_ranges assert time(22) not in time_ranges ">
from datetime import time

from timeranges import TimeRange, TimeRanges, WeekRange, Weekday


# Create a `TimeRange` instance with the interval "0:00 -> 10:00"
time_range = TimeRange(time(0), time(10))

# Check if these times are contained in `time_range`
assert time(0) in time_range
assert time(5) in time_range
assert time(10) in time_range

# Check if these times aren't contained in `time_range`
assert time(10, 0, 1) not in time_range
assert time(11) not in time_range
assert time(20) not in time_range


time_range_2 = TimeRange(time(15), time(20))
time_ranges = TimeRanges([time_range, time_range_2])

assert time(0) in time_ranges
assert time(5) in time_ranges
assert time(10) in time_ranges
assert time(12) not in time_ranges
assert time(15) in time_ranges
assert time(17) in time_ranges
assert time(20) in time_ranges
assert time(22) not in time_ranges

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

More details can be found in CONTRIBUTING.

Contributors

License

MIT

Created from cookiecutter-python-project.

Comments
  • fix: proper handling with empty structures

    fix: proper handling with empty structures

    As presented in https://github.com/tractian/tractian-python-sdk/issues/30#issuecomment-993901186,

    • empty dictionary in day_ranges means all days, with this, any datetime should return True in __contains__
    • empty list in time_ranges means all hours, with this, any datetime at the same weekday should return True in __contains__ The actual PR is a suggestion to this behavior works, which is not working properly.

    Examples of misleading behavior:

    • Datetime in a weekday with empty list as time_ranges image
    • Datetime not in a empty dict as day_ranges image
    opened by lucascust2 1
  • docs: add MicaelJarniac as a contributor for bug, code, doc, example, ideas, maintenance, projectManagement, review, tool, test

    docs: add MicaelJarniac as a contributor for bug, code, doc, example, ideas, maintenance, projectManagement, review, tool, test

    Add @MicaelJarniac as a contributor for bug, code, doc, example, ideas, maintenance, projectManagement, review, tool, test.

    This was requested by MicaelJarniac in this comment

    opened by allcontributors[bot] 0
  • Fix public API

    Fix public API

    On VS Code, if I type

    from timeranges import
    

    it doesn't auto-complete.

    Something about the way I'm "exporting" the public items on __init__.py isn't quite right.

    bug 
    opened by MicaelJarniac 0
  • Create a method for getting a fully-filled object

    Create a method for getting a fully-filled object

    Something like TimeRanges.full() that'd return TimeRanges([TimeRange()]), and WeekRange.full() that'd return WeekRange({Weekday.MONDAY: TimeRanges.full(), ...}) (with all days of the week).

    enhancement 
    opened by MicaelJarniac 0
  • Make `TimeRanges` and `WeekRange` behave more like native collections

    Make `TimeRanges` and `WeekRange` behave more like native collections

    TimeRanges could behave like a list, and WeekRange like a dict.

    https://docs.python.org/3/reference/datamodel.html#emulating-container-types

    • [ ] __bool__
    enhancement 
    opened by MicaelJarniac 1
  • Compare multiple times at once

    Compare multiple times at once

    assert (time(...), time(...)) in TimeRange(...)
    assert (time(...), time(...)) in TimeRanges(...)
    assert (datetime(...), datetime(...)) in WeekRange(...)
    
    enhancement 
    opened by MicaelJarniac 0
Releases(v1.0.2)
Owner
Micael Jarniac
Micael Jarniac
yt is an open-source, permissively-licensed Python library for analyzing and visualizing volumetric data.

The yt Project yt is an open-source, permissively-licensed Python library for analyzing and visualizing volumetric data. yt supports structured, varia

The yt project 367 Dec 25, 2022
ToeholdTools is a Python package and desktop app designed to facilitate analyzing and designing toehold switches, created as part of the 2021 iGEM competition.

ToeholdTools Category Status Repository Package Build Quality A library for the analysis of toehold switch riboregulators created by the iGEM team Cit

0 Dec 01, 2021
Template for a Dataflow Flex Template in Python

Dataflow Flex Template in Python This repository contains a template for a Dataflow Flex Template written in Python that can easily be used to build D

STOIX 5 Apr 28, 2022
A set of functions and analysis classes for solvation structure analysis

SolvationAnalysis The macroscopic behavior of a liquid is determined by its microscopic structure. For ionic systems, like batteries and many enzymes,

MDAnalysis 19 Nov 24, 2022
Used for data processing in machine learning, and help us to construct ML model more easily from scratch

Used for data processing in machine learning, and help us to construct ML model more easily from scratch. Can be used in linear model, logistic regression model, and decision tree.

ShawnWang 0 Jul 05, 2022
Convert monolithic Jupyter notebooks into Ploomber pipelines.

Soorgeon Join our community | Newsletter | Contact us | Blog | Website | YouTube Convert monolithic Jupyter notebooks into Ploomber pipelines. soorgeo

Ploomber 65 Dec 16, 2022
Intercepting proxy + analysis toolkit for Second Life compatible virtual worlds

Hippolyzer Hippolyzer is a revival of Linden Lab's PyOGP library targeting modern Python 3, with a focus on debugging issues in Second Life-compatible

Salad Dais 6 Sep 01, 2022
Python Library for learning (Structure and Parameter) and inference (Statistical and Causal) in Bayesian Networks.

pgmpy pgmpy is a python library for working with Probabilistic Graphical Models. Documentation and list of algorithms supported is at our official sit

pgmpy 2.2k Dec 25, 2022
Synthetic data need to preserve the statistical properties of real data in terms of their individual behavior and (inter-)dependences

Synthetic data need to preserve the statistical properties of real data in terms of their individual behavior and (inter-)dependences. Copula and functional Principle Component Analysis (fPCA) are st

32 Dec 20, 2022
Business Intelligence (BI) in Python, OLAP

Open Mining Business Intelligence (BI) Application Server written in Python Requirements Python 2.7 (Backend) Lua 5.2 or LuaJIT 5.1 (OML backend) Mong

Open Mining 1.2k Dec 27, 2022
simple way to build the declarative and destributed data pipelines with python

unipipeline simple way to build the declarative and distributed data pipelines. Why you should use it Declarative strict config Scaffolding Fully type

aliaksandr-master 0 Jan 26, 2022
Elementary is an open-source data reliability framework for modern data teams. The first module of the framework is data lineage.

Data lineage made simple, reliable, and automated. Effortlessly track the flow of data, understand dependencies and analyze impact. Features Visualiza

898 Jan 09, 2023
Catalogue data - A Python Scripts to prepare catalogue data

catalogue_data Scripts to prepare catalogue data. Setup Clone this repo. Install

BigScience Workshop 3 Mar 03, 2022
Stream-Kafka-ELK-Stack - Weather data streaming using Apache Kafka and Elastic Stack.

Streaming Data Pipeline - Kafka + ELK Stack Streaming weather data using Apache Kafka and Elastic Stack. Data source: https://openweathermap.org/api O

Felipe Demenech Vasconcelos 2 Jan 20, 2022
A set of procedures that can realize covid19 virus detection based on blood.

A set of procedures that can realize covid19 virus detection based on blood.

Nuyoah-xlh 3 Mar 07, 2022
Tools for analyzing data collected with a custom unity-based VR for insects.

unityvr Tools for analyzing data collected with a custom unity-based VR for insects. Organization: The unityvr package contains the following submodul

Hannah Haberkern 1 Dec 14, 2022
Advanced Pandas Vault — Utilities, Functions and Snippets (by @firmai).

PandasVault ⁠— Advanced Pandas Functions and Code Snippets The only Pandas utility package you would ever need. It has no exotic external dependencies

Derek Snow 374 Jan 07, 2023
Developed for analyzing the covariance for OrcVIO

about This repo is developed for analyzing the covariance for OrcVIO environment setup platform ubuntu 18.04 using conda conda env create --file envir

Sean 1 Dec 08, 2021
A Streamlit web-app for a data-science project that aims to evaluate if the answer to a question is helpful.

How useful is the aswer? A Streamlit web-app for a data-science project that aims to evaluate if the answer to a question is helpful. If you want to l

1 Dec 17, 2021
Projeto para realizar o RPA Challenge . Utilizando Python e as bibliotecas Selenium e Pandas.

RPA Challenge in Python Projeto para realizar o RPA Challenge (www.rpachallenge.com), utilizando Python. O objetivo deste desafio é criar um fluxo de

Henrique A. Lourenço 1 Apr 12, 2022