Time Expression Parser

1.1.8 · active · verified Sun Mar 29

Pytimeparse is a small Python library designed to parse various kinds of natural language time expressions into a total number of seconds. It supports a wide range of formats including combinations of days, hours, minutes, and seconds, as well as clock-style notations. The current version is 1.1.8, and the library is considered stable with infrequent updates, with its last release in 2018.

Warnings

Install

Imports

Quickstart

The `parse` function takes a string time expression and returns the total number of seconds as an integer or float.

from pytimeparse import parse

# Parse various time expressions
print(parse('32m'))
print(parse('2h33m'))
print(parse('4:17'))
print(parse('5hr34m56s'))
print(parse('1.2 minutes'))
print(parse('2 days, 4:13:02.266'))
print(parse('1w 3d 2h 32m'))

view raw JSON →