
Security News
Browserslist-rs Gets Major Refactor, Cutting Binary Size by Over 1MB
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
python time duration conversion module
::
pip install duration
Examples below show how to convert timestamps in hh:mm:ss
and mm:ss
format
to iso8601 strings, integer seconds, datetime.timedelta objects and
(hours, minutes, seconds,) deltas
.. code:: python
from duration import (
to_iso8601,
to_seconds,
to_timedelta,
to_tuple,
)
time = '1:23:45'
iso8601 = to_iso8601(time) # 'PT01H23M45S'
seconds = to_seconds(time) # 5025
td = to_timedelta(time) # timedelta(hours=1, minutes=23, seconds=45)
tuple_ = to_tuple(time) # (1, 23, 45,)
Examples above use strict mode by default. In strict mode, conversion
functions raise StrictnessError
if your duration string meets one of the
following conditions:
To disable strict mode, pass strict=False
to the conversion function
.. code:: python
from duration import (
to_iso8601,
to_seconds,
to_timedelta,
to_tuple,
)
time = '24:83:25'
iso8601 = to_iso8601(time, strict=False) # 'P1DT01H23M25S'
seconds = to_seconds(time, strict=False) # 91405
td = to_timedelta(time, strict=False) # timedelta(seconds=91405)
tuple_ = to_tuple(time, strict=False) # (25, 23, 25,)
FAQs
python time duration conversion module
We found that duration 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
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
Research
Security News
Eight new malicious Firefox extensions impersonate games, steal OAuth tokens, hijack sessions, and exploit browser permissions to spy on users.
Security News
The official Go SDK for the Model Context Protocol is in development, with a stable, production-ready release expected by August 2025.