1102
توضیحات
把秒数格式化成紧凑时长,也能反向解析。
| ویژگی | مقدار |
|---|---|
| سیستم عامل | OS Independent |
| نام فایل | 1102-0.0.4 |
| نام | 1102 |
| نسخه کتابخانه | 0.0.4 |
| نگهدارنده | [] |
| ایمیل نگهدارنده | [] |
| نویسنده | - |
| ایمیل نویسنده | lqxnjk <lqxnjk@qq.com> |
| آدرس صفحه اصلی | - |
| آدرس اینترنتی | https://pypi.org/project/1102/ |
| مجوز | MIT |
# 1102
[English](#english) | 中文
把秒数格式化成紧凑时长,也能反向解析。
## 安装
```console
pip install 1102
```
## 用法
```python
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
---
<a id="english"></a>
## English
Format seconds as a compact duration and parse it back.
## Install
```console
pip install 1102
```
## Usage
```python
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
زبان مورد نیاز
| مقدار | نام |
|---|---|
| >=3.10 | Python |
نحوه نصب
نصب پکیج whl 1102-0.0.4:
pip install 1102.whl
نصب پکیج tar.gz 1102-0.0.4:
pip install 1102.tar.gz