Parse user-provided duration strings using regular expressions
Project description
RegDurations
This library allows to simply parse durations written in a string, in multiple supported languages.
Install
Run:
pip install regdurations
Usage
from regdurations import DurationParser
duration_parser = DurationParser()
# optionally specify a list of supported languages:
duration_parser = DurationParser(allowed_languages=['it', 'en'])
duration_parser.find_relativedelta('3 weeks 10y 4 anni 5 minuti')
>>> (relativedelta(years=+14, days=+21, minutes=+5), 0, 27) # result, starting index, ending index
# or, if dateutil is not installed:
duration_parser.find_dict('4s 23gg 78 settimane')
>>> ({'seconds': 4, 'minutes': 0, 'hours': 0, 'days': 23, 'weeks': 78, 'months': 0, 'years': 0}, 0, 20)
Supported Languages
EN,IT,FR,DE,ES- Contributions for new languages are accepted
Credits and contact
- Thanks to CalledLuca for the idea and the
FR,DE,ESlanguages! - For any question you can try to contact me on Telegram.
License
This project is licensed under the Boost Software License. Please take a look.
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
regdurations-1.0.7.tar.gz
(4.8 kB
view details)
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 regdurations-1.0.7.tar.gz.
File metadata
- Download URL: regdurations-1.0.7.tar.gz
- Upload date:
- Size: 4.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
daa27b2d89a1a7c7cc478bf28a91aeef53898d6df39507fe6e1d2271fae51503
|
|
| MD5 |
2c603a03e87ed13c5e1830c81c3014aa
|
|
| BLAKE2b-256 |
9635350c9309e6591873346f81f5efb86723dc8b19b1f2cfd7fc8cf3d62b8f50
|
File details
Details for the file regdurations-1.0.7-py3-none-any.whl.
File metadata
- Download URL: regdurations-1.0.7-py3-none-any.whl
- Upload date:
- Size: 5.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
196a68a2342934b12c24a3e6aaf0864ddefaad2434af5f039397bc54b8f87804
|
|
| MD5 |
03e32cb60459124857d030ed378833a6
|
|
| BLAKE2b-256 |
edc5561b09c2468f32529e886d779ab1ffe40315ff4fa93a81f2116619ea5363
|