
Security News
Open Source Maintainers Feeling the Weight of the EU’s Cyber Resilience Act
The EU Cyber Resilience Act is prompting compliance requests that open source maintainers may not be obligated or equipped to handle.
A python durations parsing library, providing a straight-forward API to parse duration string representations such as 1d
, 1 day 2 hours
or 2 days 3h 26m 52s
and convert them to numeric values.
It's easier and more straight forward to read a duration expressed in natural language (at least for a human), as an expression rather than an amount. When writing configuration files for example:
interval: 3 hours
is easier to understand for a human than
interval: 10800 # seconds
durations_nlp
can be installed via pip:
$ pip install durations_nlp
To parse a duration string representation, just instantiate a Duration object and let it work for you. A Duration representation is composed of as many <value><scale>
pairs as you need to express it:
,
or and
1d
2 days
2 days and 4 hours
4M, 22d and 6hours
c
, century
, centuries
D
, decade
, decades
y
, year
, Year
M
, month
, months
w
, week
, weeks
d
, day
, days
h
, hour
, hours
m
, minute
, minutes
s
, second
, seconds
ms
, millisecond
, milliseconds
from durations_nlp import Duration
one_hour = "1hour"
one_hour_duration = Duration(one_hour)
one_hour_duration.to_seconds()
# >>> 3600.0
one_hour_duration.to_minutes()
# >>> 60.0
# You can even compose durations in their short
# and long variations
two_days_three_hours = "2 days, 3h"
two_days_three_hours_duration = Duration(two_days_three_hours)
two_days_three_hours_duration.to_seconds()
# >>> 183600.0
two_days_three_hours_duration.to_hours()
# >>> 51.0
FAQs
A python durations parsing library.
We found that durations-nlp demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
The EU Cyber Resilience Act is prompting compliance requests that open source maintainers may not be obligated or equipped to handle.
Security News
Crates.io adds Trusted Publishing support, enabling secure GitHub Actions-based crate releases without long-lived API tokens.
Research
/Security News
Undocumented protestware found in 28 npm packages disrupts UI for Russian-language users visiting Russian and Belarusian domains.