Metadata-Version: 2.4
Name: timecore
Version: 0.2.0
Summary: A modern, unified, fully typed, cross-platform Python library for date, time, duration, intervals, calendars, recurrence, and scheduling.
Author: Oceanus
Author-email: Oceanus <295322314+oceanus403@users.noreply.github.com>
License-Expression: MIT
Requires-Dist: whenever>=0.11.0
Requires-Dist: tzdata>=2025.1
Requires-Dist: tzlocal>=5.0
Requires-Dist: python-dateutil>=2.9.0
Requires-Dist: holidays>=0.109
Requires-Dist: portion>=2.6.3
Requires-Dist: babel>=2.19.0
Requires-Dist: croniter>=7.0.0
Requires-Dist: dateparser>=1.5.1 ; extra == 'natural'
Requires-Python: >=3.12
Project-URL: Repository, https://github.com/oceanus403/timecore
Project-URL: Documentation, https://oceanus403.github.io/timecore/
Provides-Extra: natural
Description-Content-Type: text/markdown

<div align="center">

<h1>TimeCore</h1>

<p><strong>A modern, unified, fully typed Python library for date and time</strong></p>

<p>
Date, time, duration, intervals, calendars, recurrence, and scheduling<br>
under one consistent, strongly typed API.
</p>

<p>
<a href="https://pypi.org/project/timecore/"><img alt="PyPI version" src="https://img.shields.io/pypi/v/timecore"></a>
<a href="pyproject.toml"><img alt="Python 3.12+" src="https://img.shields.io/badge/python-3.12%2B-blue"></a>
<a href="LICENSE"><img alt="License: MIT" src="https://img.shields.io/badge/license-MIT-blue"></a>
</p>

<p>
<a href="https://oceanus403.github.io/timecore/"><b>Documentation</b></a>
&nbsp;&middot;&nbsp;
<a href="#capabilities"><b>Capabilities</b></a>
&nbsp;&middot;&nbsp;
<a href="#installation"><b>Installation</b></a>
&nbsp;&middot;&nbsp;
<a href="#usage"><b>Usage</b></a>
&nbsp;&middot;&nbsp;
<a href="https://oceanus403.github.io/timecore/docs/contributing"><b>Contributing</b></a>
</p>

</div>

<br>

## Capabilities

| Family | Covers |
|:--|:--|
| [Core types](docs/content/docs/core-types/index.mdx) | `Date`, `Time`, `LocalDateTime`, `DateTime`, `Instant`, `TimeZone`, `Weekday`; immutable value objects, DST-aware arithmetic, native interop |
| [Durations & periods](docs/content/docs/durations-periods/index.mdx) | `Duration` for exact lengths of time, `Period` for calendar-based amounts |
| [Intervals](docs/content/docs/intervals/index.mdx) | `Interval` and `IntervalSet`; half-open by default, set operations |
| [Calendars & business time](docs/content/docs/calendars-business-time/index.mdx) | `Calendar`, `HolidayCalendar`, `BusinessCalendar`; holidays, business days and hours |
| [Recurrence & cron](docs/content/docs/recurrence-cron/index.mdx) | `Recurrence` rules with iCalendar interchange, `Cron` expressions |
| [Schedules & availability](docs/content/docs/schedules-availability/index.mdx) | `Schedule` combining rules with times, timezones and calendars; `Availability` free/busy time |
| [Parsing](docs/content/docs/parsing/index.mdx) | Strict ISO 8601 parsing, custom formats, optional natural-language parsing |
| [Formatting & localization](docs/content/docs/formatting-localization/index.mdx) | Locale-aware formatting of temporal values and durations |
| [Clocks & timers](docs/content/docs/clocks-timers/index.mdx) | Injectable `Clock` for deterministic tests, `Timer` for elapsed time |

## Installation

TimeCore supports Python 3.12 and newer.

Add it to a uv project:

```sh
uv add timecore
```

To install it in an active Python environment:

```sh
pip install timecore
```

To build from source:

```sh
git clone https://github.com/oceanus403/timecore
cd timecore
uv sync --locked
```

## Usage

```python
from timecore import (
    BusinessCalendar,
    Date,
    DateTime,
    Duration,
    Interval,
    Period,
    Recurrence,
    Schedule,
    Time,
    Weekday,
    parse_date,
)

# Dates and calendar arithmetic.
today = Date(2026, 11, 25)
next_month = today + Period(months=1)  # 2026-12-25
ten_days = today + Duration(days=10)  # 2026-12-05

# A zoned datetime; DST is handled, never guessed.
meeting = DateTime(2026, 11, 25, 9, 0, timezone="America/New_York")
instant = meeting.to_instant()  # 2026-11-25T14:00:00Z

# A half-open interval and a weekly schedule.
week = Interval(today, today + Duration(days=7))
schedule = Schedule(
    Recurrence.weekly([Weekday.MONDAY, Weekday.FRIDAY]),
    time=Time(9, 0),
    timezone="America/New_York",
    calendar=BusinessCalendar(country="US"),
)
occurrences = schedule.occurrences(today, count=3)

# Strict parsing and locale-aware formatting.
deadline = parse_date("2026-12-25")
print(deadline.format())  # Dec 25, 2026
print(deadline.format(locale="fr_FR"))  # 25 déc. 2026
```

## Project status

TimeCore 0.1.0 is released. The API may change before 1.0.

## License

MIT. See [LICENSE](LICENSE).
