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
Data science/Analysis Health Care Portfolio

Health-Care-DS-Projects Data Science/Analysis Health Care Portfolio Consists Of 3 Projects: Mexico Covid-19 project, analyze the patient medical histo

Mohamed Abd El-Mohsen 1 Feb 13, 2022
Implementation in Python of the reliability measures such as Omega.

OmegaPy Summary Simple implementation in Python of the reliability measures: Omega Total, Omega Hierarchical and Omega Hierarchical Total. Name Link O

Rafael Valero Fernández 2 Apr 27, 2022
Pypeln is a simple yet powerful Python library for creating concurrent data pipelines.

Pypeln Pypeln (pronounced as "pypeline") is a simple yet powerful Python library for creating concurrent data pipelines. Main Features Simple: Pypeln

Cristian Garcia 1.4k Dec 31, 2022
Project under the certification "Data Analysis with Python" on FreeCodeCamp

Sea Level Predictor Assignment You will anaylize a dataset of the global average sea level change since 1880. You will use the data to predict the sea

Bhavya Gopal 3 Jan 31, 2022
A data parser for the internal syncing data format used by Fog of World.

A data parser for the internal syncing data format used by Fog of World. The parser is not designed to be a well-coded library with good performance, it is more like a demo for showing the data struc

Zed(Zijun) Chen 40 Dec 12, 2022
A program that uses an API and a AI model to get info of sotcks

Stock-Market-AI-Analysis I dont mind anyone using this code but please give me credit A program that uses an API and a AI model to get info of stocks

1 Dec 17, 2021
Automatic earthquake catalog building workflow: EQTransformer + Siamese EQTransformer + PickNet + REAL + HypoInverse

Automatic regional-scale earthquake catalog building workflow: EQTransformer + Siamese EQTransforme

Xiao Zhuowei 9 Nov 27, 2022
Code for the DH project "Dhimmis & Muslims – Analysing Multireligious Spaces in the Medieval Muslim World"

Damast This repository contains code developed for the digital humanities project "Dhimmis & Muslims – Analysing Multireligious Spaces in the Medieval

University of Stuttgart Visualization Research Center 2 Jul 01, 2022
Automated Exploration Data Analysis on a financial dataset

Automated EDA on financial dataset Just a simple way to get automated Exploration Data Analysis from financial dataset (OHLCV) using Streamlit and ta.

Darío López Padial 28 Nov 27, 2022
AWS Glue ETL Code Samples

AWS Glue ETL Code Samples This repository has samples that demonstrate various aspects of the new AWS Glue service, as well as various AWS Glue utilit

AWS Samples 1.2k Jan 03, 2023
This repo contains a simple but effective tool made using python which can be used for quality control in statistical approach.

This repo contains a powerful tool made using python which is used to visualize, analyse and finally assess the quality of the product depending upon the given observations

SasiVatsal 8 Oct 18, 2022
Yet Another Workflow Parser for SecurityHub

YAWPS Yet Another Workflow Parser for SecurityHub "Screaming pepper" by Rum Bucolic Ape is licensed with CC BY-ND 2.0. To view a copy of this license,

myoung34 8 Dec 22, 2022
Data processing with Pandas.

Processing-data-with-python This is a simple example showing how to use Pandas to create a dataframe and the processing data with python. The jupyter

1 Jan 23, 2022
An experimental project I'm undertaking for the sole purpose of increasing my Python knowledge

5ePy is an experimental project I'm undertaking for the sole purpose of increasing my Python knowledge. #Goals Goal: Create a working, albeit lightwei

Hayden Covington 1 Nov 24, 2021
First steps with Python in Life Sciences

First steps with Python in Life Sciences This course material is part of the "First Steps with Python in Life Science" three-day course of SIB-trainin

SIB Swiss Institute of Bioinformatics 22 Jan 08, 2023
Very basic but functional Kakuro solver written in Python.

kakuro.py Very basic but functional Kakuro solver written in Python. It uses a reduction to exact set cover and Ali Assaf's elegant implementation of

Louis Abraham 4 Jan 15, 2022
Udacity - Data Analyst Nanodegree - Project 4 - Wrangle and Analyze Data

WeRateDogs Twitter Data from 2015 to 2017 Udacity - Data Analyst Nanodegree - Project 4 - Wrangle and Analyze Data Table of Contents Introduction Proj

Keenan Cooper 1 Jan 12, 2022
Unsub is a collection analysis tool that assists libraries in analyzing their journal subscriptions.

About Unsub is a collection analysis tool that assists libraries in analyzing their journal subscriptions. The tool provides rich data and a summary g

9 Nov 16, 2022
Mining the Stack Overflow Developer Survey

Mining the Stack Overflow Developer Survey A prototype data mining application to compare the accuracy of decision tree and random forest regression m

1 Nov 16, 2021
CS50 pset9: Using flask API to create a web application to exchange stocks' shares.

C$50 Finance In this guide we want to implement a website via which users can “register”, “login” “buy” and “sell” stocks, like below: Background If y

1 Jan 24, 2022