Skip to main content

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, ES languages!
  • 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


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)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

regdurations-1.0.7-py3-none-any.whl (5.6 kB view details)

Uploaded Python 3

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

Hashes for regdurations-1.0.7.tar.gz
Algorithm Hash digest
SHA256 daa27b2d89a1a7c7cc478bf28a91aeef53898d6df39507fe6e1d2271fae51503
MD5 2c603a03e87ed13c5e1830c81c3014aa
BLAKE2b-256 9635350c9309e6591873346f81f5efb86723dc8b19b1f2cfd7fc8cf3d62b8f50

See more details on using hashes here.

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

Hashes for regdurations-1.0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 196a68a2342934b12c24a3e6aaf0864ddefaad2434af5f039397bc54b8f87804
MD5 03e32cb60459124857d030ed378833a6
BLAKE2b-256 edc5561b09c2468f32529e886d779ab1ffe40315ff4fa93a81f2116619ea5363

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page