pytimeparse2
Time expression parser.
What it is and what it does
pytimeparse2 is a lightweight parser that converts time expressions written in natural language into numeric seconds or Python timedelta objects. It handles a wide variety of formats: shorthand notation (32m, 2h32m, 3d2h32m), colon-separated time (4:13:02), English prose (5 hours, 34 minutes, 56 seconds), and uptime-style output (2 days, 4:13:02). The library also supports months and years using fixed assumptions (30 days per month, 365 days per year).
The package has no runtime dependencies and installs as a pure Python wheel, making it simple to add to any project. It is marked Production/Stable and supports Python 3.6 through 3.11. Maintenance is dormant (last update in 2023), but the codebase carries no known vulnerabilities and the API is straightforward: call parse() with a time string and optionally request a timedelta object instead of raw seconds.
Use it for:
- Parse user-supplied timeout or delay values in configuration files or CLI arguments.
- Convert uptime or system log timestamps into standardized seconds for calculations.
- Accept human-friendly duration input in web forms or APIs and normalize to timedelta.
- Build retry logic or rate-limiting that reads duration strings from environment variables.
- Parse scheduling expressions that use natural time notation.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Parses human-readable time expressions (like '2h32m', '1.2 minutes', '2 days, 4:13:02') into seconds or timedelta objects.
Yes. pytimeparse2 solves a specific, well-defined problem with zero dependencies, permissive licensing, and no security issues. It is stable and dormant rather than actively maintained, but that is appropriate for a mature parsing utility. Install it if you need to accept time expressions from users or configuration; skip it if you only work with numeric seconds or strict time formats.
Install
pytimeparse2 on PyPI
pip
pip install pytimeparse2uv
uv add pytimeparse2poetry
poetry add pytimeparse2Installing pytimeparse2
Before you install
Low friction: pure Python wheel with no runtime dependencies. Maintenance is dormant (last commit 2023-09-29, 1191 days ago), but the package is marked Production/Stable and carries no known vulnerabilities.
License in practice
MIT license (permissive) — you may use, modify, and distribute freely with minimal restrictions; include the license text.
Quickstart
pip install pytimeparse2
from pytimeparse2 import parse
result = parse('2h32m')
print(result) # seconds as integer or float
Verify before relying
- Whether dateutil is automatically installed or optional; the description mentions conditional relativedelta support but does not clarify the dependency status.
- Performance characteristics and parsing speed for large batches of expressions.
- Exact behavior and edge cases for month/year calculations (the description notes assumptions but does not detail all corner cases).
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.6) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | dormant — 1,191 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 3,452,027/month — #2,618 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: pytimeparse2-1.7.1-py3-none-any.whl
Keywords: parsing, time, timeparsing, text
Tags
More Libraries packages
urllib3 is an HTTP client library that provides…
permissive · top 100 on PyPI
requestsRequests is a Python HTTP library that…
permissive · top 100 on PyPI
pluggyPluggy provides a plugin system that lets you…
permissive · top 100 on PyPI
python-dateutilProvides parsing, arithmetic, and recurrence…
permissive · top 100 on PyPI
sixSix provides utility functions to write Python…
permissive · top 100 on PyPI
pytestpytest is a testing framework that lets you…
permissive · top 100 on PyPI
pytimeparseParses human-readable time expressions (like…
permissive · top 1,000 on PyPI
deltaParses human-readable duration strings like '1…
permissive · top 15,000 on PyPI
humanreadableParses human-readable time and bitrate strings…
permissive · top 15,000 on PyPI
agoConverts datetime, timedelta, and timestamp…
permissive · top 15,000 on PyPI
durationpyConverts between Python's `datetime.timedelta`…
permissive · top 1,000 on PyPI
timeagoFormats datetime objects and timedeltas into…
permissive · top 5,000 on PyPI
metomi-isodatetimeParses and manipulates ISO 8601 date-time…
copyleft · top 15,000 on PyPI
isodateParses and formats ISO 8601 date, time,…
permissive · top 1,000 on PyPI
isodurationParses and manipulates ISO 8601 duration…
permissive · top 1,000 on PyPI
human-readableConverts numbers, dates, times, file sizes, and…
permissive · top 15,000 on PyPI