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.4.tar.gz (7.2 kB view details)

Uploaded Source

Built Distribution

easychrono-0.1.4-py3-none-any.whl (8.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: easychrono-0.1.4.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.4.tar.gz
Algorithm Hash digest
SHA256 918553becd010386b8a7f6386c6262298e01938c76a40f9c6181aafc95136da2
MD5 7f476a48225272f5bbe775eda29489e1
BLAKE2b-256 f7515a27f41a623c18775c9f570708b3e2304f864dbf69a76e4887797da22d19

See more details on using hashes here.

File details

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

File metadata

  • Download URL: easychrono-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 8.7 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.4-py3-none-any.whl
Algorithm Hash digest
SHA256 26eac0b0e5237adfeadacf15e5d494c9a09058b75398da433c4dcf1370cfabfb
MD5 f4696885e1c43e78cb0cb1052c186f1a
BLAKE2b-256 14aab2c7d97586d5f98d52b202f4da46dce30dedb888d422bd1ccf19779a72a1

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