Metadata-Version: 2.4
Name: dttools
Version: 0.2.0
Summary: A simple library for common date and time manipulations
Author-email: Emmanuel Ademola <ademola.emmanuel383@gmail.com>
License: MIT
Project-URL: Homepage, https://github.com/ademola-emmanuel/dttools
Project-URL: Bug Tracker, https://github.com/ademola-emmanuel/dttools/issues
Keywords: datetime,date,time,business-days,timezone
Classifier: Development Status :: 4 - Beta
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.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: tzdata; sys_platform == "win32"
Dynamic: license-file

# dttools

A simple Python library for common date and time manipulations.

## Installation

```bash
pip install dttools
```

Requires Python 3.10+. Uses the standard library's `zoneinfo` for timezones
(no `pytz`). On Windows, `tzdata` is pulled in automatically.

## Usage

### Adding (or subtracting) business days

```python
from dttools import add_business_days
from datetime import datetime, date

start_date = datetime(2023, 11, 10)
add_business_days(start_date, 5)   # 5 business days forward, skipping weekends
add_business_days(start_date, -3)  # 3 business days backward

# Optionally skip holidays too
add_business_days(start_date, 5, holidays={date(2023, 11, 23)})
```

### Counting business days between two dates

```python
from dttools import days_between_in_business_days
from datetime import datetime

days_between_in_business_days(datetime(2023, 11, 1), datetime(2023, 11, 10))
# Counts weekdays from start (inclusive) up to end (exclusive).
```

### Checking business days and weekends

```python
from dttools import is_business_day, is_weekend
from datetime import date

is_business_day(date(2023, 11, 10))  # True  (Friday)
is_business_day(date(2023, 11, 11))  # False (Saturday)
is_weekend(date(2023, 11, 11))       # True
```

### Human-readable relative dates

```python
from dttools import format_relative_date
from datetime import datetime, timedelta

now = datetime.now()
format_relative_date(now - timedelta(minutes=30))  # "30 minutes ago"
format_relative_date(now - timedelta(hours=2))     # "2 hours ago"
format_relative_date(now - timedelta(days=3))      # "3 days ago"
format_relative_date(now + timedelta(days=1))      # "Tomorrow"
```

### Converting to a specific timezone

```python
from dttools import to_timezone
from datetime import datetime, timezone

utc_now = datetime.now(timezone.utc)
to_timezone(utc_now, "America/New_York")
```

Naive datetimes are treated as UTC.

## License

MIT - see [LICENSE](LICENSE).
