Datefinder

1.0.0 · active · verified Thu Apr 09

Datefinder is a Python library designed to extract datetime objects from natural language text. It supports various date and time formats, including relative and absolute expressions. The current version is 1.0.0, and it follows an active release cadence, with a recent major update shifting its default parsing engine.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to use `find_dates` to extract datetime objects from a string. It iterates through the returned `DateMatch` objects, printing both the original substring found and the parsed `datetime` object. It also shows how to explicitly specify the 'legacy' engine for pre-1.0.0 behavior.

from datefinder import find_dates

text = "I have a meeting on October 25th, 2024 at 3 PM and another one next Tuesday."

print("Dates found:")
for match in find_dates(text):
    print(f"  Match: '{match.substring}' -> Datetime: {match.datetime}")

# To use the legacy engine (pre-1.0.0 behavior)
print("\nDates found (legacy engine):")
for match in find_dates(text, engine='legacy'):
    print(f"  Match: '{match.substring}' -> Datetime: {match.datetime}")

view raw JSON →