Socket
Book a DemoInstallSign in
Socket

regdurations

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

regdurations

Parse user-provided duration strings using regular expressions

1.0.7
pipPyPI
Maintainers
1

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.

FAQs

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.