Skip to main content

1102

English | 中文

把秒数格式化成紧凑时长,也能反向解析。

安装

pip install 1102

用法

from p1102 import format_duration, parse_duration

format_duration(0)             # '0s'
format_duration(93784)         # '1d 2h 3m'
format_duration(93784, 2)      # '1d 2h'
format_duration(-90)           # '-1m 30s'

parse_duration("1d 2h 3m 4s")  # 93784.0
parse_duration("90")           # 90.0

说明

包名以数字开头,导入名是 p1102。单位 d/h/m/s 大小写不敏感、可任意顺序、可重复。无法解析时抛 ValueError 而不返回 0——超时计算里一个静默的 0 比崩溃更难查。

许可证

MIT


English

Format seconds as a compact duration and parse it back.

Install

pip install 1102

Usage

from p1102 import format_duration, parse_duration

format_duration(0)             # '0s'
format_duration(93784)         # '1d 2h 3m'
format_duration(93784, 2)      # '1d 2h'
format_duration(-90)           # '-1m 30s'

parse_duration("1d 2h 3m 4s")  # 93784.0
parse_duration("90")           # 90.0

Notes

The import name is p1102 because the distribution starts with a digit. Units d/h/m/s are case insensitive, may appear in any order and may repeat. Unparseable text raises ValueError instead of returning 0.

License

MIT

Metadata

Release files for 1102 0.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for 1102 0.0.3
File Size Uploaded Provenance Actions
1102-0.0.3.tar.gz 3.4 kB Without provenance Details for 1102-0.0.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for 1102 0.0.3
File Interpreter ABI Platform Actions
1102-0.0.3-py3-none-any.whl Python 3 none any Details for 1102-0.0.3-py3-none-any.whl

Total release size: 7.3 kB

Release files / 1102-0.0.3.tar.gz

Download URL 1102-0.0.3.tar.gz
Size 3.4 kB
Tags Source
SHA-256 checksum
How to use checksums
ef4502b6254fe84f0bfa3d62bd1f7a58907909eb5566c61ea4c935bcdeb0f19f
BLAKE2b-256 checksum
How to use checksums
df9d57bc01182a5d3c5ebf2422d3146a8ca5ae7c5662d58d74cc10f29b7978cf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.11

Release files / 1102-0.0.3-py3-none-any.whl

Download URL 1102-0.0.3-py3-none-any.whl
Size 3.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
62950d1e4bbc10ba745656da0f574afaab0a0194bd7b56ca9d201f02c663910e
BLAKE2b-256 checksum
How to use checksums
ea1a4ff73ea34181661c44b772af6fee095404c632a4be1ca905a94ed651714e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.11

Security for 1102 0.0.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page