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
ForecastGA is a Python tool to forecast Google Analytics data using several popular time series models.

ForecastGA is a tool that combines a couple of popular libraries, Atspy and googleanalytics, with a few enhancements.

JR Oakes 36 Jan 3, 2023
PyEmits, a python package for easy manipulation in time-series data.

PyEmits, a python package for easy manipulation in time-series data. Time-series data is very common in real life. Engineering FSI industry (Financial

Thompson 5 Sep 23, 2022
A Python 3 library making time series data mining tasks, utilizing matrix profile algorithms

MatrixProfile MatrixProfile is a Python 3 library, brought to you by the Matrix Profile Foundation, for mining time series data. The Matrix Profile is

Matrix Profile Foundation 302 Dec 29, 2022
Average time per match by division

HW_02 Unzip matches.rar to access .json files for matches. Get an API key to access their data at: https://developer.riotgames.com/ Average time per m

null 11 Jan 7, 2022
Working Time Statistics of working hours and working conditions by industry and company

Working Time Statistics of working hours and working conditions by industry and company

Feng Ruohang 88 Nov 4, 2022
Integrate bus data from a variety of sources (batch processing and real time processing).

Purpose: This is integrate bus data from a variety of sources such as: csv, json api, sensor data ... into Relational Database (batch processing and r

null 1 Nov 25, 2021
An Integrated Experimental Platform for time series data anomaly detection.

Curve Sorry to tell contributors and users. We decided to archive the project temporarily due to the employee work plan of collaborators. There are no

Baidu 486 Dec 21, 2022
Leverage Twitter API v2 to analyze tweet metrics such as impressions and profile clicks over time.

Tweetmetric Tweetmetric allows you to track various metrics on your most recent tweets, such as impressions, retweets and clicks on your profile. The

Mathis HAMMEL 29 Oct 18, 2022
A real-time financial data streaming pipeline and visualization platform using Apache Kafka, Cassandra, and Bokeh.

Realtime Financial Market Data Visualization and Analysis Introduction This repo shows my project about real-time stock data pipeline. All the code is

null 6 Sep 7, 2022
Example Of Splunk Search Query With Python And Splunk Python SDK

SSQAuto (Splunk Search Query Automation) Example Of Splunk Search Query With Python And Splunk Python SDK installation: ➜ ~ git clone https://github.c

AmirHoseinTangsiriNET 1 Nov 14, 2021
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
Incubator for useful bioinformatics code, primarily in Python and R

Collection of useful code related to biological analysis. Much of this is discussed with examples at Blue collar bioinformatics. All code, images and

Brad Chapman 560 Jan 3, 2023
Karate Club: An API Oriented Open-source Python Framework for Unsupervised Learning on Graphs (CIKM 2020)

Karate Club is an unsupervised machine learning extension library for NetworkX. Please look at the Documentation, relevant Paper, Promo Video, and Ext

Benedek Rozemberczki 1.8k Jan 9, 2023
Probabilistic Programming in Python: Bayesian Modeling and Probabilistic Machine Learning with Theano

PyMC3 is a Python package for Bayesian statistical modeling and Probabilistic Machine Learning focusing on advanced Markov chain Monte Carlo (MCMC) an

PyMC 7.2k Dec 30, 2022
Statsmodels: statistical modeling and econometrics in Python

About statsmodels statsmodels is a Python package that provides a complement to scipy for statistical computations including descriptive statistics an

statsmodels 8k Dec 29, 2022
A computer algebra system written in pure Python

SymPy See the AUTHORS file for the list of authors. And many more people helped on the SymPy mailing list, reported bugs, helped organize SymPy's part

SymPy 9.9k Dec 31, 2022
Multiple Pairwise Comparisons (Post Hoc) Tests in Python

scikit-posthocs is a Python package that provides post hoc tests for pairwise multiple comparisons that are usually performed in statistical data anal

Maksim Terpilowski 264 Dec 30, 2022
Hidden Markov Models in Python, with scikit-learn like API

hmmlearn hmmlearn is a set of algorithms for unsupervised learning and inference of Hidden Markov Models. For supervised learning learning of HMMs and

null 2.7k Jan 3, 2023