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.8.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.8-py3-none-any.whl (5.6 kB view details)

Uploaded Python 3

File details

Details for the file regdurations-1.0.8.tar.gz.

File metadata

  • Download URL: regdurations-1.0.8.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.8.tar.gz
Algorithm Hash digest
SHA256 ae4aa801a5ebad36204ac4875a464b47320abfd3d0552f974a1c0846940b5fdd
MD5 6684ef6b43c077dbc54e378ac171f536
BLAKE2b-256 ecf545e7a7fb71d918ab1f36d5d2048e922c1681213d46195f09ee6b259e0de3

See more details on using hashes here.

File details

Details for the file regdurations-1.0.8-py3-none-any.whl.

File metadata

  • Download URL: regdurations-1.0.8-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.8-py3-none-any.whl
Algorithm Hash digest
SHA256 0dd20d606f5ba39fc366835ad23bec9f8d9d5c40544a021b0edef989b6735c22
MD5 fea717de4e9a22c3d4a1d303e3be1ccb
BLAKE2b-256 de69b69a5a3971c2ea415174c7815a0a064826c3d74437f09632d0f5b7979bf4

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