Skip to main content

Utility for generating datetimes within given constraints

Project description

secondstate

GitHub release PyPI version GitHub pull-requests Build Release GitHub license

Requirements

  • Python >= 3.8
  • Docker (for development only)

Installation

pip install secondstate

Usage

Lets say you want to figure out the availability of a haircut with a particular barber:

from secondstate import SecondState

# We want all available appointments from now until the next 7 days
barber = SecondState(start="2021-05-23T11:17:49", finish="2021-05-30T11:17:49")

# The barber works Monday 10:00-16:00
barber.set(start="2021-05-24T10:00:00", finish="2021-05-24T16:00:00")

# Looks like the barber already has appointments on Monday at 10:30 and 15:00
barber.unset(start="2021-05-24T10:30:00", finish="2021-05-24T11:00:00")
barber.unset(start="2021-05-24T15:00:00", finish="2021-05-24T15:30:00")

# Haircut takes 30 minutes
print(barber.get(minutes=30))

Result:

[
    ["2021-05-24T10:00:00", "2021-05-24T10:30:00"],
    ["2021-05-24T11:00:00", "2021-05-24T11:30:00"],
    ["2021-05-24T11:30:00", "2021-05-24T12:00:00"],
    ["2021-05-24T12:00:00", "2021-05-24T12:30:00"],
    ["2021-05-24T12:30:00", "2021-05-24T13:00:00"],
    ["2021-05-24T13:00:00", "2021-05-24T13:30:00"],
    ["2021-05-24T13:30:00", "2021-05-24T14:00:00"],
    ["2021-05-24T14:00:00", "2021-05-24T14:30:00"],
    ["2021-05-24T14:30:00", "2021-05-24T15:00:00"],
    ["2021-05-24T15:30:00", "2021-05-24T16:00:00"],
]

To use the development environment:

make dev

Releasing

poetry version major | minor | patch
make release

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

secondstate-2.0.0.tar.gz (4.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

secondstate-2.0.0-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

File details

Details for the file secondstate-2.0.0.tar.gz.

File metadata

  • Download URL: secondstate-2.0.0.tar.gz
  • Upload date:
  • Size: 4.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.6 CPython/3.8.10 Linux/5.4.0-1047-azure

File hashes

Hashes for secondstate-2.0.0.tar.gz
Algorithm Hash digest
SHA256 fe8673909b1a575b43b761c84db450a588b75a12ac3dd1eaef1cdc96a18fe88d
MD5 1d99416c2f7dd44d055aa36eb2967c3c
BLAKE2b-256 25fcb55c3406abbe30ca202b6a9cd6edb91798a774329f180b52b67ebfaa6d19

See more details on using hashes here.

File details

Details for the file secondstate-2.0.0-py3-none-any.whl.

File metadata

  • Download URL: secondstate-2.0.0-py3-none-any.whl
  • Upload date:
  • Size: 4.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.6 CPython/3.8.10 Linux/5.4.0-1047-azure

File hashes

Hashes for secondstate-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 371e03a1a18098a749a346d7c7f35fe90dabe77c7f46c1a8d601b8fccb2aefe3
MD5 4b5420a93ea3b80add9f572394f2e277
BLAKE2b-256 b40538a26e7911e8e9cad0bc55cb794409c85beff5c3a374416ba384935730f7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page