python-utils-rondomondo
Reusable Python utilities for dates and money.
Install
pip install python-utils-rondomondo
Or with uv:
uv add python-utils-rondomondo
Usage
from python_utils.dates import now_utc, parse_duration, date_windows
from python_utils.money import to_money, fmt_accounting, format_currency, allocate
Dates
| Function | Description |
|---|---|
now_utc(microsecond=False) |
Current UTC datetime, always timezone-aware |
to_iso(dt, timespec="seconds") |
Format datetime as ISO 8601 string (space separator) |
from_iso(s) |
Parse ISO 8601 string to datetime |
parse_duration(s) |
Parse human duration like "7days", "3hrs", "90secs" to timedelta |
midnight_before(dt) |
Midnight at the start of the day before dt |
date_windows(start, end, window) |
Split a range into non-overlapping timedelta windows |
is_leap(year) |
True if the given year is a leap year |
same_day_next_year(dt) |
Advance by one calendar year, clamping Feb 29 to Feb 28 |
from python_utils.dates import now_utc, parse_duration, date_windows, to_iso
from datetime import timedelta
now = now_utc()
end = now + parse_duration("7days")
windows = date_windows(now, end, timedelta(days=2))
print(to_iso(now)) # '2026-05-19 14:30:00+00:00'
Money
| Function | Description |
|---|---|
to_money(value) |
Convert str, int, or Decimal to a cent-quantised Decimal (half-up) |
to_decimal(value) |
Convert int, float, str, or Decimal to Decimal without rounding |
round_half_up(amount, places=2) |
Round using half-up convention |
round_bankers(amount, places=2) |
Round using banker's rounding (half to even) |
truncate(amount, places=2) |
Truncate toward zero |
format_currency(amount, symbol="$", thousands=True) |
Format Decimal as a currency string |
parse_currency(s) |
Parse a currency string like "$1,234.56" or "-£99.00" to Decimal |
fmt_accounting(value) |
Accounting convention: negatives as (120.00), positives as 500.00 |
allocate(amount, ratios) |
Distribute amount across ratios with no penny lost or gained |
from decimal import Decimal
from python_utils.money import to_money, format_currency, fmt_accounting, allocate
price = to_money("19.99")
tax = to_money(price * Decimal("0.1")) # 2.00
total = price + tax # 21.99
print(format_currency(total)) # '$21.99'
print(fmt_accounting(Decimal("-120.00"))) # '(120.00)'
print(fmt_accounting(Decimal("500.00"))) # '500.00 '
shares = allocate(Decimal("100.00"), [1, 2, 3]) # [33.33, 33.33, 33.34] (sums exactly)
Examples
F-string formatting reference
src/python_utils/examples/fstrings.py is a runnable reference script covering the full range of Python f-string format specs, using an invoice as the running example:
- Number formatting: decimal places, thousands separators, alignment, currency symbols
- Sign formatting: explicit
+, space padding, accounting parentheses - Integer bases: hex, octal, binary, scientific notation, percent
- String alignment, padding, fill characters, truncation
- Expressions, conditionals, and method calls inside f-strings
- Conversion flags:
!s,!r,!a - A complete invoice table tying all patterns together
python src/python_utils/examples/fstrings.py
Requirements
Python 3.12+
License
MIT
Metadata
Release files for python-utils-rondomondo 0.1.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| python_utils_rondomondo-0.1.5.tar.gz | 12.2 kB | Without provenance | Details for python_utils_rondomondo-0.1.5.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| python_utils_rondomondo-0.1.5-py3-none-any.whl | Python 3 | none | any | Details for python_utils_rondomondo-0.1.5-py3-none-any.whl |
Total release size: 20.7 kB
Release files / python_utils_rondomondo-0.1.5.tar.gz
| Download URL | python_utils_rondomondo-0.1.5.tar.gz |
|---|---|
| Size | 12.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2191eff3bc23f97036a33a0f8fd654c3171c21efb50c8e3161a5eb85a0eb03c3
|
|
BLAKE2b-256 checksum How to use checksums |
7dd5043cb12b2d84e7512cd9dc0321096911d5730c3e2065b5c5c0ddb83d08be
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.15 {"installer":{"name":"uv","version":"0.11.15","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / python_utils_rondomondo-0.1.5-py3-none-any.whl
| Download URL | python_utils_rondomondo-0.1.5-py3-none-any.whl |
|---|---|
| Size | 8.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c8cf830058562f4e4e71c385e312f4d4141b7b2c40bc519dc27d19e3a0b2cff8
|
|
BLAKE2b-256 checksum How to use checksums |
cfa5bb17a91e2c5d2e573db75ad51fbc3ff7a294b6363aa6ef626520a58c1744
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.15 {"installer":{"name":"uv","version":"0.11.15","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Security for python-utils-rondomondo 0.1.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.