A Python library for performing arithmetic with HH:MM[:SS] formatted time strings.
Project description
hmscalc
A lightweight Python library for performing arithmetic on time values formatted as HH:MM or HH:MM:SS.
🚀 Features
- Supports time addition and subtraction
- Accepts
HH:MMandHH:MM:SSformatted strings - Handles negative durations gracefully
- Converts time to seconds, minutes, hours, and dictionary/tuple formats
- Fully testable across multiple Python versions via Docker
🐳 Quick Start (Docker-based)
# Build the image
docker build -t hmscalc .
# Run tests across multiple Python versions
docker run --rm hmscalc ./runtests.sh
# Run lint
docker run --rm hmscalc ./lint.sh
📦 Project Structure
hmscalc/
├── Dockerfile # Docker setup with pyenv and poetry
├── runtests.sh # Runs tests on multiple Python versions
├── hmscalc/ # Source code
│ └── hms_time.py
├── tests/ # Pytest-based unit tests
├── pyproject.toml # Poetry config
├── README.md # This file
└── LICENSE # MIT license
📚 Usage (inside container)
from hmscalc import HMSTime
a = HMSTime("1:30:15")
b = HMSTime("2:15:45")
print(a + b) # "3:46:00"
print(a - b) # "-0:45:30"
print(a.to_seconds()) # 5415
print(a.to_tuple()) # (1, 30, 15)
print(a.to_dict()) # {'hh': 1, 'mm': 30, 'ss': 15}
🔍 Examples
HMSTime("2:30") + HMSTime("1:45") # "4:15:00"
HMSTime("1:00:30") - HMSTime("0:30") # "0:30:30"
HMSTime("0:00") - HMSTime("0:01") # "-0:01:00"
🧪 Running tests locally via Docker
# Build image
docker build -t hmscalc .
# Run matrix tests via pyenv + poetry
docker run --rm hmscalc ./runtests.sh
📄 License
This project is licensed under the MIT License.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
hmscalc-0.1.0.tar.gz
(3.8 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file hmscalc-0.1.0.tar.gz.
File metadata
- Download URL: hmscalc-0.1.0.tar.gz
- Upload date:
- Size: 3.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.3 CPython/3.11.12 Linux/6.11.0-1014-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c4fbf717e7a204daa89aab40101640fd195c361c586a79fd7d91f7bc6aff63b8
|
|
| MD5 |
e8fed3850508fe8bc0db9445e9b906a8
|
|
| BLAKE2b-256 |
9a90193011d5a8719df2ae667041274d0d1bd0ae66b1de3102765a366aa5be6b
|
File details
Details for the file hmscalc-0.1.0-py3-none-any.whl.
File metadata
- Download URL: hmscalc-0.1.0-py3-none-any.whl
- Upload date:
- Size: 4.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.3 CPython/3.11.12 Linux/6.11.0-1014-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ee066d549a5eab7644d03b9f787576d49a84daba14d9f9bea6eba90bce992863
|
|
| MD5 |
8db2752dd543d3543ccb1fb95ea00d30
|
|
| BLAKE2b-256 |
4e5f8d4159d1a701561e6ceb8f44e79ffd226d1a27aef84be883dcbf22901802
|