Metadata-Version: 2.4
Name: philiprehberger-timeago
Version: 0.1.4
Summary: Convert timestamps to relative time phrases like '3 hours ago'
Project-URL: Homepage, https://github.com/philiprehberger/py-timeago#readme
Project-URL: Repository, https://github.com/philiprehberger/py-timeago
Project-URL: Issues, https://github.com/philiprehberger/py-timeago/issues
Project-URL: Changelog, https://github.com/philiprehberger/py-timeago/blob/main/CHANGELOG.md
Author: Philip Rehberger
License-Expression: MIT
License-File: LICENSE
Keywords: ago,datetime,human,relative,timeago,timestamp
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Typing :: Typed
Requires-Python: >=3.10
Description-Content-Type: text/markdown

# philiprehberger-timeago

[![Tests](https://github.com/philiprehberger/py-timeago/actions/workflows/publish.yml/badge.svg)](https://github.com/philiprehberger/py-timeago/actions/workflows/publish.yml)
[![PyPI version](https://img.shields.io/pypi/v/philiprehberger-timeago.svg)](https://pypi.org/project/philiprehberger-timeago/)
[![License](https://img.shields.io/github/license/philiprehberger/py-timeago)](LICENSE)

Convert timestamps to relative time phrases like "3 hours ago".

## Installation

```bash
pip install philiprehberger-timeago
```

## Usage

```python
from philiprehberger_timeago import timeago, timedelta_human
from datetime import datetime, timedelta, timezone

now = datetime.now(timezone.utc)

timeago(now - timedelta(seconds=30))  # "30 seconds ago"
timeago(now - timedelta(hours=3))     # "3 hours ago"
timeago(now - timedelta(days=1))      # "yesterday"
timeago(now + timedelta(days=7))      # "in 1 week"

# Unix timestamps
timeago(1709913600)

# Duration formatting
timedelta_human(timedelta(hours=3, minutes=25))  # "3 hours, 25 minutes"
```

## API

- `timeago(dt, now=None)` — Relative time phrase from datetime, date, or Unix timestamp
- `timedelta_human(td)` — Format a timedelta as readable duration


## Development

```bash
pip install -e .
python -m pytest tests/ -v
```

## License

MIT
