Metadata-Version: 2.5
Name: 1102
Version: 0.0.2
Summary: Format seconds as a compact duration and parse it back.
Project-URL: Homepage, https://github.com/lqxnjk/1102
Author: lqxnjk
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

Turn a number of seconds into something readable, and read it back.

The import name is `p1102` because a Python module cannot start with a digit:

```python
from p1102 import format_duration
```

## Install

```console
pip install 1102
```

## Usage

```python
from p1102 import format_duration, parse_duration

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

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

## Rules

`d`, `h`, `m`, `s`, case insensitive, any order, repeatable. Unparseable text
raises `ValueError` rather than returning `0` — a silent zero in a timeout
calculation is worse than a crash.

## License

MIT
