Natural Language (NLP) Extraction of Date and Time
Project description
fast-parse-time
Extract dates and times from text. Fast, deterministic, zero cost.
Why?
LLMs can parse dates, but they're slow, expensive, and non-deterministic. This library gives you:
- Sub-millisecond performance - Process thousands of documents per second
- Zero API costs - No per-request charges
- Deterministic results - Same input always produces same output
- Simple API - One function call, everything extracted
Install
pip install fast-parse-time
Usage
from fast_parse_time import parse_dates
text = "Meeting on 04/08/2024 to discuss issues from 5 days ago"
result = parse_dates(text)
# Explicit dates found in text
print(result.explicit_dates)
# [ExplicitDate(text='04/08/2024', date_type='FULL_EXPLICIT_DATE')]
# Relative time expressions
print(result.relative_times)
# [RelativeTime(cardinality=5, frame='day', tense='past')]
# Convert to Python datetime
for time_ref in result.relative_times:
print(time_ref.to_datetime())
# datetime.datetime(2025, 11, 14, ...)
What It Extracts
Explicit dates:
"Event on 04/08/2024" → 04/08/2024 (full date)
"Meeting scheduled for 3/24" → 3/24 (month/day)
"Copyright 2024" → 2024 (year only)
"Ambiguous: 4/8" → 4/8 (flagged as ambiguous)
"Published March 15, 2024" → March 15, 2024 (written month)
"Filed in 2024" → 2024 (year in prose)
Year ranges:
"Active 2014-2015" → 2014-2015 (year range)
"From 2010 to 2020" → From 2010 to 2020 (year range)
"Revenue grew 2019–2023" → 2019-2023 (en/em dash normalized)
"Contract 2023-24" → 2023-24 (abbreviated)
Relative times:
"5 days ago" → 5 days (past)
"last couple of weeks" → 2 weeks (past)
"30 minutes ago" → 30 minutes (past)
"half an hour ago" → 1 hour (past)
"a few days ago" → 3 days (past)
Examples
Parse everything at once
result = parse_dates("Report from 04/08/2024 covering issues from last week")
result.explicit_dates # ['04/08/2024']
result.relative_times # [RelativeTime(cardinality=1, frame='week', tense='past')]
Just get dates
from fast_parse_time import extract_explicit_dates
dates = extract_explicit_dates("Event on 04/08/2024 or maybe 3/24")
# {'04/08/2024': 'FULL_EXPLICIT_DATE', '3/24': 'MONTH_DAY'}
Convert to datetime objects
from fast_parse_time import resolve_to_datetime
datetimes = resolve_to_datetime("Show me data from 5 days ago")
# [datetime.datetime(2025, 11, 14, ...)]
Features
- Multiple date formats:
04/08/2024,3/24,2024-06-05,March 15, 2024 - Multiple delimiters:
/,-,. - Year ranges:
2014-2015,2010 to 2020,from 2018 through 2022,2023-24 - Unicode normalization: en dash, em dash, and other hyphen variants accepted automatically
- Written months:
March 15, 2024,Mar 15, 2024,15 March 2024 - Year-only in prose:
Copyright 2024,filed in 2019 - Relative time expressions: "5 days ago", "last week", "couple of months ago"
- Informal expressions: "half an hour ago", "a few days ago", "several weeks ago"
- Named day and time-of-day references: "last Monday", "this morning", "yesterday"
- Ambiguity detection: Flags dates like
4/8that could be April 8 or August 4 - Time frame support: seconds, minutes, hours, days, weeks, months, years
Documentation
- API Reference
- Functions - All functions with examples
- Types - Data classes and DateType enum
- System Boundaries - Design decisions and limitations
Performance
Typical extraction takes < 1ms per document. No network calls, no model inference, pure Python.
License
MIT - See LICENSE for details.
Author
Craig Trim - craigtrim@gmail.com
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fast_parse_time-1.3.2.tar.gz.
File metadata
- Download URL: fast_parse_time-1.3.2.tar.gz
- Upload date:
- Size: 1.4 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.3.2 CPython/3.11.9 Darwin/24.6.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b51090e8e4404c4e9a2ecc09fddc3acb43254ef14d75651db130e9f1124675a0
|
|
| MD5 |
3ba00e82586faf6763a40aba82446a24
|
|
| BLAKE2b-256 |
34c168f01e5247bcad31983db58e38e8db86d1f6dc43775520b9c988ed084ed0
|
File details
Details for the file fast_parse_time-1.3.2-py3-none-any.whl.
File metadata
- Download URL: fast_parse_time-1.3.2-py3-none-any.whl
- Upload date:
- Size: 1.4 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.3.2 CPython/3.11.9 Darwin/24.6.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
765053940e713b0baa038109eeab2c9fa9edd840e4f9602c3ed999ce7d727be6
|
|
| MD5 |
440cb4688226446140a0b54819fc7dab
|
|
| BLAKE2b-256 |
84d4f14c5903ffa7ddad374e93b34bb3d07eb4ba08c87345e01693a4457c36aa
|