Metadata-Version: 2.5
Name: 1102
Version: 0.0.3
Summary: Format seconds as a compact duration and parse it back.
Project-URL: Homepage, https://pypi.org/project/1102/
Author-email: lqxnjk <lqxnjk@qq.com>
License: MIT
License-File: LICENSE
Keywords: duration,format,interval,parse,time
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Typing :: Typed
Requires-Python: >=3.10
Description-Content-Type: text/markdown

# 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
