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.4

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.4
File Size Uploaded Provenance Actions
1102-0.0.4.tar.gz 3.4 kB Without provenance Details for 1102-0.0.4.tar.gz

Built distribution (wheel)

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

Total release size: 7.3 kB

Release files / 1102-0.0.4.tar.gz

Download URL 1102-0.0.4.tar.gz
Size 3.4 kB
Tags Source
SHA-256 checksum
How to use checksums
e08537f73179f90eb4b965b4ba0945bd80d97b1c6466f56dee3a5c62f6485079
BLAKE2b-256 checksum
How to use checksums
f07a408f9e8b08aad3e5164ea6c3dee44cd7e073e3434fc2c097001c4f1ddf7e
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.4-py3-none-any.whl

Download URL 1102-0.0.4-py3-none-any.whl
Size 3.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
651ed89a8f81875cacfa8370c7da87d65988dc9d3490a486041a2e0c40be56ba
BLAKE2b-256 checksum
How to use checksums
137d5e5508fb8fc2263fed79e0508576f8fe86462a2a89659e2cde99b6a58688
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.4

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