skillfed

pytimeparse2

Time expression parser.

pytimeparse2 v1.7.1 3.5M downloads/30d#2,618 on PyPI19
Permissive license MIT DORMANT released

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 pytimeparse2

uv

uv add pytimeparse2

poetry

poetry add pytimeparse2

Installing 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

Development Status :: 5 - Production/StableIntended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseProgramming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.6Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Programming Language :: Python :: Implementation :: CPythonTopic :: Software Development :: LibrariesTopic :: Software Development :: Libraries :: Python ModulesTopic :: Text ProcessingTopic :: Utilities

Tags

parse time expressionsconvert time string to secondshuman readable duration parsingtimedelta from stringuptime format parsertime duration parserparse duration strings
parsingtime-utilities

More Libraries packages