Skip to main content

Minuteman

Represent and transform expressions of time. For example:

  • 5 minutes per day in a year in days = 1.27 days.
  • 1 hour per day in a decade in weeks = 21,72 weeks
  • 10 months a year in 4 decades in years = 33.33 years

Install

pip install minuteman

Usage

Basic usage: from humanreadable expression to a number

from minuteman.parser import parse

# Case 1: calculation of daily habbit adding up.
expression = "5 minutes a day in 1 year in days" 
result = parse(expression)
print(result) # 1.2673611111111112 days

# Same result with rounding to given decimals.
result = parse(expression, 2)
print(result) # 1.27 days

# Case 2: how many actual years one spends working in 40 year career.
expression = "10 months a year in 4 decades in years"
result = parse(expression, 0) # indicating no decimals.
print(result) # 33 years

More fine tune usage: ignoring humanreadable strings and using straight number input

from minuteman.core import transform, TimeExpressionRequest
from minuteman.units import TimeExpression, UnitOfTime

# Build a time expression request from parts

# Case: 8 hours a day in a year in months
request = TimeExpressionRequst(
    original=TimeExpression(
        amount=8,
        unit=UnitOfTime.HOURS,
    ),
    in_time=TimeExpression(amount=1, unit=UnitOfTime.DAYS),
    comparison=TimeExpression(amount=1, unit=UnitOfTime.YEARS),
)
resolution = UnitOfTime.MONTHS

result = transform(request, resolution)

# Result is a TimeExpression instance with amount & unit.
print(result) # TimeExpression(amount=4.055555555555555, unit=UnitOfTime.Months)

Supported units of time:

  • Seconds
  • Minutes
  • Hours
  • Days
  • Weeks
  • Months
  • Years
  • Decades

Metadata

Release files for minuteman 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for minuteman 0.1.0
File Size Uploaded
minuteman-0.1.0.tar.gz 4.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for minuteman 0.1.0
File Interpreter ABI Platform
minuteman-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 9.4 kB

Release files / minuteman-0.1.0.tar.gz

Download URL minuteman-0.1.0.tar.gz
Size 4.4 kB
Tags Source
SHA-256 checksum
How to use checksums
dab79c7eb32e79a9ab2996657027d0cea642c3e4b0d55686f85c5877b5b8581f
BLAKE2b-256 checksum
How to use checksums
fc78c86c6c4965bde177cb7ef2610582d302c5fd7308bd8c34c33c0070b9ce3b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.16

Release files / minuteman-0.1.0-py3-none-any.whl

Download URL minuteman-0.1.0-py3-none-any.whl
Size 5.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3505878a8dff9f62bdc3247e4112f362f0251b964ea411d3646ce182000d078d
BLAKE2b-256 checksum
How to use checksums
8367fca425b3c4280d87342bd85bc550dd6dd828106b56d0864ec10156fd12d7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.16

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page