Skip to main content

A Python package for working with timedelta objects and more

Project description

EasyChrono

EasyChrono is a python package for working with Timedelta objects, including parsing, formatting, manipulations of time intervals, parsing relative dates, and integration with databases.

Installation

You can install EasyChrono using pip:

pip install easychrono

Parsing Timedelta

from easychrono.parser import parse_delta

td = parse_delta("5h3h19m45s")
print(td) # Outputs: 5 days, 3:19:45

Formatting Timedelta

from easychrono.formatter import format_timedelta

formatted_td = format_timedelta(timedelta(days=5, hours=3, minutes=19, seconds=45))
print(formatted_td)  # Outputs: 5 days, 3 hours, 19 minutes, 45 seconds

Adding and Subtracting Timedeltas

from easychrono.operations import add_timedelta, subtract_timedelta

td1 = timedelta(days=5)
td2 = timedelta(days=3)
result = add_timedelta(td1, td2)
print(result)  # Outputs: 8 days, 0:00:00

result = subtract_timedelta(td1, td2)
print(result)  # Outputs: 2 days, 0:00:00

Parsing Relative Dates

from easychrono.utils import parse_relative_date

date = parse_relative_date("next Monday")
print(date)  # Outputs: Date of next Monday

Database Integration

Setting Up the Database

from easychrono.database import setup_database

setup_database("MyDatabase.db")

Storing a Timedelta

from datetime import timedelta
from easychrono import save_timedelta

my_timedelta = timedelta(hours=5, minutes=19, seconds=45)
description = "Work Hours"

save_timedelta(description, my_timedelta)

Retriving a Timedelta

from easychrono import load_timedelta
try:
    stored_timedelta, description = load_timedelta(1)
    print(f"Loaded timedelta: {stored_timedelta}")
    print(f"Description: {description}")
except ValueError as e:
    print(e)

Contributing

We welcome contributions to EasyChrono. If you'd like to contribute, please follow the guidelines in our CONTRIBUTING.md file.

License

This project is licensed under the MIT License - see the LICENSE file for details.

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

easychrono-0.1.3.tar.gz (7.2 kB view details)

Uploaded Source

Built Distribution

easychrono-0.1.3-py3-none-any.whl (8.6 kB view details)

Uploaded Python 3

File details

Details for the file easychrono-0.1.3.tar.gz.

File metadata

  • Download URL: easychrono-0.1.3.tar.gz
  • Upload date:
  • Size: 7.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.11

File hashes

Hashes for easychrono-0.1.3.tar.gz
Algorithm Hash digest
SHA256 5c44597dfd8ce19ddb1ee8e45646c4231415cf031adf80261fe2df2f4569ea5b
MD5 f0dd1d85eb68f03b4dc95fd98ea056cf
BLAKE2b-256 b1801b40d9020c5b75190556419c7eac3037b48cb50552fc1c61850a8e6761bb

See more details on using hashes here.

File details

Details for the file easychrono-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: easychrono-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 8.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.11

File hashes

Hashes for easychrono-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 2ecbba7ddff7c3c07c54bc78f8304267deb251f867c3abf29f7bdb05da55dde2
MD5 7796703af56cc2abb8b812826aa8c208
BLAKE2b-256 5890fbe8dceb778704608787dea12725e3ca236b524a8a4013370fcbd1516494

See more details on using hashes here.

Supported by

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