# Eones ![Python](https://img.shields.io/badge/Python-3.9+-yellow?style=for-the-badge&logo=python) ![PyPI](https://img.shields.io/pypi/v/eones?style=for-the-badge) ![Pylint](https://img.shields.io/badge/pylint-10.00-green?style=for-the-badge) ![Coverage](https://img.shields.io/badge/Coverage-100%25-red?style=for-the-badge) ![Build](https://img.shields.io/badge/Build-manual-green?style=for-the-badge) ![Tox](https://img.shields.io/badge/Tested%20tox-yellowgreen?style=for-the-badge) --- > Compatible with Python 3.9+ Β· No external dependencies Β· Portable and lightweight --- ## ✨ What is Eones? Eones is a minimalist, dependency-free library for expressive, clear, and powerful date/time manipulation. Inspired by natural language semantics, it allows you to manipulate, compare, and transform dates as if they were living entities. > *"That is not dead which can eternal lie, and with strange aeons even death may die."* > β€” *Abdul Alhazred*, Necronomicon ### Philosophy > **Eones is not a datetime replacement. It's a temporal reasoning layer.** Eones exists to fill the gap between Python's low-level `datetime` and the need for semantic, calendar-aware date manipulation: - Using **only the standard library** (Python 3.9+) - Providing a **semantically rich and consistent API** - Supporting modern timezone-aware design with `zoneinfo` - Maintaining **modular and composable** architecture through clear separation of responsibilities (`Date`, `Delta`, `Range`) **Eones is for:** - Developers who want to reason about time semantically, not just manipulate timestamps - Teams that want **zero external dependencies** for maximum portability - Projects where **timezones, truncation, deltas and ranges** are central domain logic --- ## πŸ“¦ Installation ```bash pip install "eones" ``` > If you're working with timezones on Windows or containers: > ⚠️ Also install `tzdata`: > ```bash > pip install tzdata > ``` --- ## πŸ§ͺ Basic Example ```python from eones import Eones e = Eones("2025-06-15") print(e.add(months=1, days=3)) # β†’ Eones(date=2025-07-18T00:00:00+00:00, tz='UTC') print(e.format("%Y-%m-%d")) # β†’ 2025-07-18 print(e.diff_for_humans("2025-06-10")) # β†’ in 1 month print(e.diff_for_humans("2025-06-20", locale="es")) # β†’ en 4 semanas ``` --- ## πŸ” Key Features - βœ… **Zero external dependencies**: Pure Python (Python 3.9+) - βœ… **Intuitive interface**: Simple, semantically rich and easy-to-use API - βœ… **Modern timezone support**: Robust handling with `zoneinfo` (not `pytz`) - βœ… **Flexible parsing**: Accepts multiple date formats automatically, including ISO 8601 with timezone offsets - βœ… **Advanced temporal operations**: Deltas, ranges and semantic comparisons - βœ… **Modular architecture**: Clear separation between `Date`, `Delta`, `Range` and utilities - βœ… **Localization**: Support for multiple languages - βœ… **Humanization**: Converts time differences to readable text - βœ… **Complete type hinting**: Fully typed following PEP 561 - βœ… **Interoperability**: Compatible with Python's standard `datetime` ### Localization & Error Handling You can add more languages by creating a new file in `eones/locales/` with the translations for your locale. For example, `fr.py` for French. Eones surfaces clear exceptions derived from `EonesError`. Invalid timezones raise `InvalidTimezoneError`, while unparsable strings raise `InvalidFormatError`. --- ## 🧾 Comparison with other libraries ### Why not Pendulum or Arrow? | Feature | Eones | Pendulum | Arrow | Delorean | dateutil | pytz | |-----------------------------------------|:-----:|:--------:|:-----:|:--------:|:--------:|:----:| | Modern timezone support | βœ… (`zoneinfo`) | ❌ (`pytz`) | ❌ (`pytz`) | βœ… | ⚠️ | βœ… | | External dependencies | βœ… None | ❌ Yes | ❌ Yes | ❌ Yes | ❌ Yes | ❌ Yes | | Semantically rich API | βœ… Rich | βœ… Medium | βœ… Medium | ⚠️ | ❌ | ❌ | | Modular/facade architecture | βœ… Yes | ❌ No | ❌ No | ❌ No | ❌ No | ❌ No | | Complete type hinting & PEP 561 | βœ… Yes | ❌ Limited | ❌ Limited | ❌ No | ❌ No | ❌ No | | **High Performance (~1M ops/sec)** | **βœ… Yes** | ❌ No | ❌ No | ❌ No | ❌ No | ❌ No | | **Memory Optimized (`__slots__`)** | **βœ… Yes** | ❌ No | ❌ No | ❌ No | ❌ No | ❌ No | | Zero-dep Localization (No Babel) | βœ… Yes | ❌ No | ❌ No | ❌ No | ❌ No | ❌ No | | Dedicated Range/Period API | βœ… Yes | βœ… Yes | ⚠️ Basic | ⚠️ Basic | ❌ No | ❌ No | | Date arithmetic (add/subtract) | βœ… | βœ… | βœ… | βœ… | ❌ | ❌ | | Flexible parsing (string, dict, dt) | βœ… | βœ… | βœ… | ⚠️ | βœ… | ❌ | | Coverage tested β‰₯ 97% | βœ… | ❓ | ❓ | ❌ | ❌ | ❌ | | Can replace native `datetime` directly | βœ… | βœ… | βœ… | ❌ | ❌ | ❌ | | Permissive license (MIT / BSD) | βœ… | βœ… | βœ… | βœ… | βœ… | βœ… | | Actively maintained | βœ… | βœ… | βœ… | ❌ | βœ… | ⚠️ | > **See the numbers yourself:** For detailed performance metrics (Speed, Memory, Profiling), check out our **[Benchmark Suite](https://github.com/roldriel/eones/blob/master/benchmarks/README.md)**. --- ## πŸ“š Documentation & Examples Comprehensive examples and documentation are available: ### πŸ“– Core Examples - **[Quick Start](https://github.com/roldriel/eones/blob/master/docs/source/examples/quick_start.md)** - Library import, date creation, formatting, basic operations - **[Advanced Patterns](https://github.com/roldriel/eones/blob/master/docs/source/examples/advanced_patterns.md)** - Truncation, rounding, period ranges, comparisons - **[Time Deltas](https://github.com/roldriel/eones/blob/master/docs/source/examples/time_deltas.md)** - Dual delta architecture, calendar vs duration intervals - **[Real World Scenarios](https://github.com/roldriel/eones/blob/master/docs/source/examples/real_world_scenarios.md)** - Real-world examples: age calculation, billing cycles, reports - **[Error Handling](https://github.com/roldriel/eones/blob/master/docs/source/examples/error_handling.md)** - Exception hierarchy, safe date creation, validation - **[Formatting & Serialization](https://github.com/roldriel/eones/blob/master/docs/source/examples/formatting_serialization.md)** - ISO 8601, JSON export/import, API integration - **[Regional Configuration](https://github.com/roldriel/eones/blob/master/docs/source/examples/regional_configuration.md)** - First day of week configuration, ISO vs US standards, weekend detection ### πŸ”— Integration Examples - **Django**: Custom model fields - **SQLAlchemy**: Specialized column types - **REST APIs**: Serialization utilities --- ## πŸ”§ Tests & Coverage ```bash tox ``` ```bash coverage html && open htmlcov/index.html ``` --- ## πŸ“– Requirements - Python 3.9 or higher - (Optional) `tzdata` if using timezones in systems without a local zoneinfo database --- ## πŸ“ License MIT Β© 2025 β€” Rodrigo Ezequiel RoldΓ‘n [View full license](https://github.com/roldriel/eones/blob/master/LICENSE.md)