datefind
A python module for locating dates within text. Use this package to search for dates and convert them to datetime objects.
Finds dates in many different formats.
- All numeric -
2024-01-01,01/01/2024,01012024, etc. - Natural language -
January 1st, 2024,March nineteenth, 2024,twenty fifth of January,Mar 15, 24, etc. - Fuzzy dates -
today,yesterday,tomorrow,last week,this week,next week, etc. - Relative offsets -
3 days ago,in 2 weeks,1 year from now, etc. - Weekdays -
Monday,next Friday,last Tuesday, etc. - Quarters -
Q1 2024,2024 Q3, etc.
Installation
Requires Python 3.11 or higher.
pip install datefind
Usage
from datefind import find_dates
string = "2024-01-01 and 2024-01-02"
for date in find_dates(string, tz="America/New_York"):
print(date)
>>> FoundDate(
datetime=datetime.datetime(2024, 1, 1, 0, 0, tzinfo=zoneinfo.ZoneInfo(key='America/New_York')),
match='2024-01-01',
span=(0, 10)
)
>>> FoundDate(
datetime=datetime.datetime(2024, 1, 2, 0, 0, tzinfo=zoneinfo.ZoneInfo(key='America/New_York')),
match='2024-01-02',
span=(15, 25)
)
find_dates
The find_dates() function is the main entry point for the datefind package. It takes a string of text and returns a generator of Date objects.
Arguments
text- The text to search for dates.first- The first number to find in ambiguous dates. (one ofmonth,day,year) Default ismonthtz- The timezone to use. Defaults to the local timezone.
For each date found, a FoundDate object is returned. The FoundDate object has the following properties:
datetime- The datetime object.match- The matched portion of the text.span- The span of the matched text in the original text.
Contributing
See CONTRIBUTING.md for more information.
Metadata
Release files for datefind 0.6.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| datefind-0.6.0.tar.gz | 12.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| datefind-0.6.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 24.9 kB
Release files / datefind-0.6.0.tar.gz
| Download URL | datefind-0.6.0.tar.gz |
|---|---|
| Size | 12.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4357c52491405d1fed3b6df07edb47f6471d1349d39e66e40fe9dd1d8aded754
|
|
BLAKE2b-256 checksum How to use checksums |
28defe1494984aca700b05cea50b8dcb62cc9b3c1dc24e39c2bd05b962f263f0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.0 {"installer":{"name":"uv","version":"0.13.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / datefind-0.6.0-py3-none-any.whl
| Download URL | datefind-0.6.0-py3-none-any.whl |
|---|---|
| Size | 12.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
42f8c017cd99964034333c4535875a42ad65cbc2bbaa1cceb8d0b05a2344b0bf
|
|
BLAKE2b-256 checksum How to use checksums |
5ce205061452d9ce5ef7250a127cf62cb971876ee5afed4158776d3e75a402df
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.0 {"installer":{"name":"uv","version":"0.13.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|