Eones 1.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- eones-1.0.0/CHANGELOG.md +23 -0
- eones-1.0.0/CONTRIBUTING.md +80 -0
- eones-1.0.0/LICENSE.md +21 -0
- eones-1.0.0/MANIFEST.in +14 -0
- eones-1.0.0/PKG-INFO +136 -0
- eones-1.0.0/README.md +113 -0
- eones-1.0.0/examples/advanced_usage.py +30 -0
- eones-1.0.0/examples/basic_usage.py +33 -0
- eones-1.0.0/examples/labor_calendar.py +34 -0
- eones-1.0.0/pyproject.toml +32 -0
- eones-1.0.0/setup.cfg +4 -0
- eones-1.0.0/src/Eones.egg-info/PKG-INFO +136 -0
- eones-1.0.0/src/Eones.egg-info/SOURCES.txt +38 -0
- eones-1.0.0/src/Eones.egg-info/dependency_links.txt +1 -0
- eones-1.0.0/src/Eones.egg-info/requires.txt +1 -0
- eones-1.0.0/src/Eones.egg-info/top_level.txt +1 -0
- eones-1.0.0/src/eones/__init__.py +12 -0
- eones-1.0.0/src/eones/constants.py +34 -0
- eones-1.0.0/src/eones/core/__init__.py +1 -0
- eones-1.0.0/src/eones/core/date.py +427 -0
- eones-1.0.0/src/eones/core/delta.py +149 -0
- eones-1.0.0/src/eones/core/parser.py +107 -0
- eones-1.0.0/src/eones/core/range.py +77 -0
- eones-1.0.0/src/eones/errors.py +36 -0
- eones-1.0.0/src/eones/formats.py +40 -0
- eones-1.0.0/src/eones/integrations/__init__.py +1 -0
- eones-1.0.0/src/eones/integrations/django.py +17 -0
- eones-1.0.0/src/eones/integrations/serializers.py +7 -0
- eones-1.0.0/src/eones/integrations/sqlalchemy.py +17 -0
- eones-1.0.0/src/eones/interface.py +222 -0
- eones-1.0.0/tests/__init__.py +0 -0
- eones-1.0.0/tests/test_date.py +226 -0
- eones-1.0.0/tests/test_delta.py +70 -0
- eones-1.0.0/tests/test_errors.py +31 -0
- eones-1.0.0/tests/test_formats.py +39 -0
- eones-1.0.0/tests/test_integrations.py +10 -0
- eones-1.0.0/tests/test_interface.py +152 -0
- eones-1.0.0/tests/test_parser.py +90 -0
- eones-1.0.0/tests/test_range.py +34 -0
- eones-1.0.0/tests/test_version.py +6 -0
eones-1.0.0/CHANGELOG.md
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# π¦ CHANGELOG
|
|
2
|
+
|
|
3
|
+
All versions are documented in this file.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## [1.0.0] - 2025-05-19
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
- First stable release of the `eones` library.
|
|
11
|
+
- Unified parser for `str`, `dict`, and `datetime`.
|
|
12
|
+
- Timezone support using `ZoneInfo`.
|
|
13
|
+
- Truncation, aggregation, comparison, and range methods.
|
|
14
|
+
- Optional integrations for `Django`, `SQLAlchemy`, and `Serializers`.
|
|
15
|
+
|
|
16
|
+
### Changed
|
|
17
|
+
- Centralized interface using the `Eones` class.
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## History
|
|
22
|
+
|
|
23
|
+
This project is designed to be minimalist, cross-platform, and 100% based on Pythonβs standard library.
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
# Contributing to Eones
|
|
2
|
+
|
|
3
|
+
First of all, thank you for your interest in contributing to **Eones** β a minimalist, expressive and dependency-free date/time library for Python.
|
|
4
|
+
|
|
5
|
+
This project values **clarity, correctness, and composability** over feature-bloat or excessive abstraction. Contributions are welcome, as long as they align with these principles.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## π§ Guiding Principles
|
|
10
|
+
|
|
11
|
+
- **Standard Library only**: Avoid adding external dependencies.
|
|
12
|
+
- **Strong typing**: All public interfaces must be type hinted using `mypy`-compatible syntax.
|
|
13
|
+
- **Black + Pylint compliance**: Run formatting and linting before submitting a pull request.
|
|
14
|
+
- **Explicit over implicit**: Prefer readable code over clever hacks.
|
|
15
|
+
- **UTC by default**: Timezone handling must be safe, predictable, and always explicit.
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## π Setup
|
|
20
|
+
|
|
21
|
+
To contribute, clone the repository and install the dev dependencies:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
git clone https://github.com/your-username/eones.git
|
|
25
|
+
cd eones
|
|
26
|
+
python -m venv .venv
|
|
27
|
+
source .venv/bin/activate # or .venv\Scripts\activate on Windows
|
|
28
|
+
pip install -r requirements-dev.txt
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
## π§ͺ Running Tests
|
|
34
|
+
|
|
35
|
+
Eones uses `pytest`. To run all tests:
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
pytest
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
To check coverage:
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
pytest --cov=src/eones --cov-report=term-missing
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
To run linters:
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
black src tests
|
|
51
|
+
pylint src/eones
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
---
|
|
55
|
+
|
|
56
|
+
## βοΈ Pull Request Guidelines
|
|
57
|
+
|
|
58
|
+
- Each PR should focus on a **single concern**.
|
|
59
|
+
- Include or update **unit tests** for any change in logic.
|
|
60
|
+
- Add or improve **docstrings** in public APIs.
|
|
61
|
+
- If fixing a bug, include a minimal test case to reproduce the issue.
|
|
62
|
+
- If adding a feature, explain the motivation and provide an example of usage.
|
|
63
|
+
|
|
64
|
+
---
|
|
65
|
+
|
|
66
|
+
## π File Structure
|
|
67
|
+
|
|
68
|
+
```
|
|
69
|
+
src/eones/ # Core logic: date, delta, parser, range
|
|
70
|
+
tests/ # Pytest-based unit tests
|
|
71
|
+
docs/ # Sphinx documentation (optional)
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
---
|
|
75
|
+
|
|
76
|
+
## π¬ Need Help?
|
|
77
|
+
|
|
78
|
+
Feel free to open a [Discussion](https://github.com/roldriel/eones/discussions) or reach out via issues.
|
|
79
|
+
|
|
80
|
+
Thanks again for contributing to Eones π
|
eones-1.0.0/LICENSE.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Rodrigo Ezequiel RoldΓ‘n
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
eones-1.0.0/MANIFEST.in
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# Core
|
|
2
|
+
include README.md
|
|
3
|
+
include LICENSE.md
|
|
4
|
+
include pyproject.toml
|
|
5
|
+
include CHANGELOG.md
|
|
6
|
+
include CONTRIBUTING.md
|
|
7
|
+
|
|
8
|
+
# Include
|
|
9
|
+
recursive-include tests *.py
|
|
10
|
+
recursive-include examples *
|
|
11
|
+
|
|
12
|
+
# Exclude
|
|
13
|
+
global-exclude *.py[cod] __pycache__/*
|
|
14
|
+
recursive-exclude htmlcov *
|
eones-1.0.0/PKG-INFO
ADDED
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: Eones
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Elegant time manipulation and reasoning library
|
|
5
|
+
Author-email: Rodrigo Ezequiel RoldΓ‘n <roldriel@gmail.com>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Keywords: datetime,time,calendar,library,dates,timezones
|
|
8
|
+
Classifier: Development Status :: 4 - Beta
|
|
9
|
+
Classifier: Intended Audience :: Developers
|
|
10
|
+
Classifier: Operating System :: OS Independent
|
|
11
|
+
Classifier: Programming Language :: Python
|
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
18
|
+
Requires-Python: >=3.8
|
|
19
|
+
Description-Content-Type: text/markdown
|
|
20
|
+
License-File: LICENSE.md
|
|
21
|
+
Requires-Dist: tzdata
|
|
22
|
+
Dynamic: license-file
|
|
23
|
+
|
|
24
|
+
# Eones
|
|
25
|
+

|
|
26
|
+

|
|
27
|
+

|
|
28
|
+

|
|
29
|
+

|
|
30
|
+

|
|
31
|
+

|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
> Compatible with Python 3.8+ Β· No external dependencies Β· Portable and lightweight
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
## β¨ What is Eones?
|
|
40
|
+
|
|
41
|
+
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.
|
|
42
|
+
|
|
43
|
+
> *βThat is not dead which can eternal lie, and with strange aeons even death may die.β*
|
|
44
|
+
> β *Abdul Alhazred*, Necronomicon
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
## π¦ Installation
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
pip install "eones"
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
> If you're working with timezones on Windows or containers:
|
|
55
|
+
> β οΈ Also install `tzdata`:
|
|
56
|
+
> ```bash
|
|
57
|
+
> pip install tzdata
|
|
58
|
+
> ```
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
## π§ͺ Basic Example
|
|
63
|
+
|
|
64
|
+
```python
|
|
65
|
+
from eones import Eones
|
|
66
|
+
|
|
67
|
+
z = Eones("2025-06-15")
|
|
68
|
+
z.add(months=1, days=3)
|
|
69
|
+
|
|
70
|
+
print(z.format("%Y-%m-%d")) # β 2025-07-18
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
---
|
|
74
|
+
|
|
75
|
+
## π Key Features
|
|
76
|
+
|
|
77
|
+
- β
Automatic parsing for `str`, `dict`, `datetime`, `Eones`
|
|
78
|
+
- β
Add/subtract days, months, years, minutes, seconds
|
|
79
|
+
- β
Date comparison (same week, within year, between ranges)
|
|
80
|
+
- β
Full day/month/year ranges
|
|
81
|
+
- β
Truncation and rounding by unit
|
|
82
|
+
- β
Full support for `ZoneInfo` (PEP 615)
|
|
83
|
+
- β
Zero external dependencies
|
|
84
|
+
- β
Conversion to `datetime`, `date`, and native types
|
|
85
|
+
|
|
86
|
+
---
|
|
87
|
+
|
|
88
|
+
## π§Ύ Comparison with other libraries
|
|
89
|
+
|
|
90
|
+
| Feature | Eones | Pendulum | Arrow | Delorean | dateutil | pytz |
|
|
91
|
+
|-----------------------------------------|:-----:|:--------:|:-----:|:--------:|:--------:|:----:|
|
|
92
|
+
| Modern, consistent API | β
| β
| β
| β οΈ | β | β |
|
|
93
|
+
| Date arithmetic (add/subtract) | β
| β
| β
| β
| β | β |
|
|
94
|
+
| Flexible parsing (string, dict, dt) | β
| β
| β
| β οΈ | β
| β |
|
|
95
|
+
| Native timezone support | β
| β
| β
| β
| β οΈ | β
|
|
|
96
|
+
| No external dependencies | β
| β | β | β | β | β |
|
|
97
|
+
| Coverage tested β₯ 97% | β
| β | β | β | β | β |
|
|
98
|
+
| Can replace native `datetime` directly | β
| β
| β
| β | β | β |
|
|
99
|
+
| Permissive license (MIT / BSD) | β
| β
| β
| β
| β
| β
|
|
|
100
|
+
| Actively maintained | β
| β
| β
| β | β
| β οΈ |
|
|
101
|
+
|
|
102
|
+
---
|
|
103
|
+
|
|
104
|
+
## π Advanced Examples
|
|
105
|
+
|
|
106
|
+
You can find more usage examples in:
|
|
107
|
+
|
|
108
|
+
- [examples/basic_usage.py](examples/basic_usage.py)
|
|
109
|
+
- [examples/advanced_usage.py](examples/advanced_usage.py)
|
|
110
|
+
- [examples/labor_calendar.py](examples/labor_calendar.py)
|
|
111
|
+
|
|
112
|
+
---
|
|
113
|
+
|
|
114
|
+
## π§ Tests & Coverage
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
tox
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
```bash
|
|
121
|
+
coverage html && open htmlcov/index.html
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
---
|
|
125
|
+
|
|
126
|
+
## π Requirements
|
|
127
|
+
|
|
128
|
+
- Python 3.8 or higher
|
|
129
|
+
- (Optional) `tzdata` if using timezones in systems without a local zoneinfo database
|
|
130
|
+
|
|
131
|
+
---
|
|
132
|
+
|
|
133
|
+
## π License
|
|
134
|
+
|
|
135
|
+
MIT Β© 2025 β Rodrigo Ezequiel RoldΓ‘n
|
|
136
|
+
[View full license](LICENSE.md)
|
eones-1.0.0/README.md
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
# Eones
|
|
2
|
+

|
|
3
|
+

|
|
4
|
+

|
|
5
|
+

|
|
6
|
+

|
|
7
|
+

|
|
8
|
+

|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
> Compatible with Python 3.8+ Β· No external dependencies Β· Portable and lightweight
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## β¨ What is Eones?
|
|
17
|
+
|
|
18
|
+
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.
|
|
19
|
+
|
|
20
|
+
> *βThat is not dead which can eternal lie, and with strange aeons even death may die.β*
|
|
21
|
+
> β *Abdul Alhazred*, Necronomicon
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
## π¦ Installation
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
pip install "eones"
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
> If you're working with timezones on Windows or containers:
|
|
32
|
+
> β οΈ Also install `tzdata`:
|
|
33
|
+
> ```bash
|
|
34
|
+
> pip install tzdata
|
|
35
|
+
> ```
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
## π§ͺ Basic Example
|
|
40
|
+
|
|
41
|
+
```python
|
|
42
|
+
from eones import Eones
|
|
43
|
+
|
|
44
|
+
z = Eones("2025-06-15")
|
|
45
|
+
z.add(months=1, days=3)
|
|
46
|
+
|
|
47
|
+
print(z.format("%Y-%m-%d")) # β 2025-07-18
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
---
|
|
51
|
+
|
|
52
|
+
## π Key Features
|
|
53
|
+
|
|
54
|
+
- β
Automatic parsing for `str`, `dict`, `datetime`, `Eones`
|
|
55
|
+
- β
Add/subtract days, months, years, minutes, seconds
|
|
56
|
+
- β
Date comparison (same week, within year, between ranges)
|
|
57
|
+
- β
Full day/month/year ranges
|
|
58
|
+
- β
Truncation and rounding by unit
|
|
59
|
+
- β
Full support for `ZoneInfo` (PEP 615)
|
|
60
|
+
- β
Zero external dependencies
|
|
61
|
+
- β
Conversion to `datetime`, `date`, and native types
|
|
62
|
+
|
|
63
|
+
---
|
|
64
|
+
|
|
65
|
+
## π§Ύ Comparison with other libraries
|
|
66
|
+
|
|
67
|
+
| Feature | Eones | Pendulum | Arrow | Delorean | dateutil | pytz |
|
|
68
|
+
|-----------------------------------------|:-----:|:--------:|:-----:|:--------:|:--------:|:----:|
|
|
69
|
+
| Modern, consistent API | β
| β
| β
| β οΈ | β | β |
|
|
70
|
+
| Date arithmetic (add/subtract) | β
| β
| β
| β
| β | β |
|
|
71
|
+
| Flexible parsing (string, dict, dt) | β
| β
| β
| β οΈ | β
| β |
|
|
72
|
+
| Native timezone support | β
| β
| β
| β
| β οΈ | β
|
|
|
73
|
+
| No external dependencies | β
| β | β | β | β | β |
|
|
74
|
+
| Coverage tested β₯ 97% | β
| β | β | β | β | β |
|
|
75
|
+
| Can replace native `datetime` directly | β
| β
| β
| β | β | β |
|
|
76
|
+
| Permissive license (MIT / BSD) | β
| β
| β
| β
| β
| β
|
|
|
77
|
+
| Actively maintained | β
| β
| β
| β | β
| β οΈ |
|
|
78
|
+
|
|
79
|
+
---
|
|
80
|
+
|
|
81
|
+
## π Advanced Examples
|
|
82
|
+
|
|
83
|
+
You can find more usage examples in:
|
|
84
|
+
|
|
85
|
+
- [examples/basic_usage.py](examples/basic_usage.py)
|
|
86
|
+
- [examples/advanced_usage.py](examples/advanced_usage.py)
|
|
87
|
+
- [examples/labor_calendar.py](examples/labor_calendar.py)
|
|
88
|
+
|
|
89
|
+
---
|
|
90
|
+
|
|
91
|
+
## π§ Tests & Coverage
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
tox
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
coverage html && open htmlcov/index.html
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
---
|
|
102
|
+
|
|
103
|
+
## π Requirements
|
|
104
|
+
|
|
105
|
+
- Python 3.8 or higher
|
|
106
|
+
- (Optional) `tzdata` if using timezones in systems without a local zoneinfo database
|
|
107
|
+
|
|
108
|
+
---
|
|
109
|
+
|
|
110
|
+
## π License
|
|
111
|
+
|
|
112
|
+
MIT Β© 2025 β Rodrigo Ezequiel RoldΓ‘n
|
|
113
|
+
[View full license](LICENSE.md)
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# examples/advanced_usage.py
|
|
2
|
+
from datetime import datetime
|
|
3
|
+
|
|
4
|
+
from zilean import Zilean
|
|
5
|
+
|
|
6
|
+
# Caso 1: Validar si una factura estΓ‘ dentro del mes actual
|
|
7
|
+
factura_fecha = Zilean("2025-06-08")
|
|
8
|
+
actual = Zilean("2025-06-15")
|
|
9
|
+
if actual.is_within(factura_fecha):
|
|
10
|
+
print("La factura corresponde al mes actual")
|
|
11
|
+
|
|
12
|
+
# Caso 2: Calcular cuΓ‘ntos dΓas faltan para el vencimiento
|
|
13
|
+
vencimiento = Zilean("2025-06-20")
|
|
14
|
+
hoy = Zilean("2025-06-15")
|
|
15
|
+
dias_restantes = hoy.difference(vencimiento, unit="days")
|
|
16
|
+
print("DΓas hasta el vencimiento:", dias_restantes)
|
|
17
|
+
|
|
18
|
+
# Caso 3: Detectar si una fecha es el inicio de trimestre fiscal
|
|
19
|
+
fecha = Zilean("2025-07-01")
|
|
20
|
+
if fecha.format("%m-%d") in ["01-01", "04-01", "07-01", "10-01"]:
|
|
21
|
+
print("Inicio de trimestre fiscal")
|
|
22
|
+
|
|
23
|
+
# Caso 4: Generar un reporte desde el inicio del mes hasta hoy
|
|
24
|
+
hoy = Zilean("2025-06-18")
|
|
25
|
+
inicio_mes, _ = hoy.range("month")
|
|
26
|
+
print("Reporte del:", inicio_mes.date(), "al", hoy.now().to_datetime().date())
|
|
27
|
+
|
|
28
|
+
# Caso 5: Estimar prΓ³xima fecha de corte semanal (lunes)
|
|
29
|
+
corte = hoy.next_weekday(0)
|
|
30
|
+
print("PrΓ³ximo lunes:", corte.to_datetime().strftime("%Y-%m-%d"))
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# examples/basic_usage.py
|
|
2
|
+
from datetime import datetime
|
|
3
|
+
|
|
4
|
+
from zilean import Zilean
|
|
5
|
+
|
|
6
|
+
# 1. Crear fechas desde distintos formatos
|
|
7
|
+
z1 = Zilean("2025-06-15")
|
|
8
|
+
z2 = Zilean({"year": 2025, "month": 6, "day": 15})
|
|
9
|
+
z3 = Zilean(datetime(2025, 6, 15))
|
|
10
|
+
print("Format date:", z1.format("%Y-%m-%d"))
|
|
11
|
+
|
|
12
|
+
# 2. Agregar tiempo
|
|
13
|
+
z1.add(years=1, months=2, days=10)
|
|
14
|
+
print("After add:", z1.format("%Y-%m-%d"))
|
|
15
|
+
|
|
16
|
+
# 3. Diferencias
|
|
17
|
+
base = Zilean("2025-01-01")
|
|
18
|
+
print("Diff days:", base.difference("2025-01-04", unit="days"))
|
|
19
|
+
print("Diff months:", base.difference("2025-03-01", unit="months"))
|
|
20
|
+
print("Diff years:", base.difference("2027-01-01", unit="years"))
|
|
21
|
+
|
|
22
|
+
# 4. Comparaciones
|
|
23
|
+
z = Zilean("2025-06-10")
|
|
24
|
+
print("Is within same month:", z.is_within("2025-06-01"))
|
|
25
|
+
print("Is same year:", z.is_within("2025-01-01", check_month=False))
|
|
26
|
+
|
|
27
|
+
# 5. Rango mensual
|
|
28
|
+
start, end = z.range("month")
|
|
29
|
+
print("Month range:", start, "to", end)
|
|
30
|
+
|
|
31
|
+
# 6. PrΓ³ximo lunes desde una fecha
|
|
32
|
+
monday = z.next_weekday(0)
|
|
33
|
+
print("Next Monday:", monday.to_datetime())
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# examples/labor_calendar.py
|
|
2
|
+
from datetime import datetime
|
|
3
|
+
|
|
4
|
+
from zilean import Zilean
|
|
5
|
+
|
|
6
|
+
# Lista de feriados (puede venir de una base de datos externa)
|
|
7
|
+
feriados = [
|
|
8
|
+
"2025-01-01", # AΓ±o Nuevo
|
|
9
|
+
"2025-05-01", # DΓa del Trabajador
|
|
10
|
+
"2025-12-25", # Navidad
|
|
11
|
+
]
|
|
12
|
+
|
|
13
|
+
# Verificar si una fecha es laborable
|
|
14
|
+
fecha = Zilean("2025-05-01")
|
|
15
|
+
|
|
16
|
+
is_weekend = fecha.now().to_datetime().weekday() >= 5 # 5 = SΓ‘bado, 6 = Domingo
|
|
17
|
+
is_feriado = fecha.format("%Y-%m-%d") in feriados
|
|
18
|
+
|
|
19
|
+
if is_weekend or is_feriado:
|
|
20
|
+
print("No laborable")
|
|
21
|
+
else:
|
|
22
|
+
print("Laborable")
|
|
23
|
+
|
|
24
|
+
# Calcular prΓ³ximos 5 dΓas laborables
|
|
25
|
+
actual = Zilean("2025-05-01")
|
|
26
|
+
proximos = []
|
|
27
|
+
|
|
28
|
+
while len(proximos) < 5:
|
|
29
|
+
actual.add(days=1)
|
|
30
|
+
dt = actual.now().to_datetime()
|
|
31
|
+
if dt.weekday() < 5 and actual.format("%Y-%m-%d") not in feriados:
|
|
32
|
+
proximos.append(actual.format("%Y-%m-%d"))
|
|
33
|
+
|
|
34
|
+
print("PrΓ³ximos 5 dΓas laborables:", proximos)
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "Eones"
|
|
7
|
+
version = "1.0.0"
|
|
8
|
+
description = "Elegant time manipulation and reasoning library"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.8"
|
|
11
|
+
license = "MIT"
|
|
12
|
+
authors = [{ name = "Rodrigo Ezequiel RoldΓ‘n", email = "roldriel@gmail.com" }]
|
|
13
|
+
keywords = ["datetime", "time", "calendar", "library", "dates", "timezones"]
|
|
14
|
+
classifiers = [
|
|
15
|
+
"Development Status :: 4 - Beta",
|
|
16
|
+
"Intended Audience :: Developers",
|
|
17
|
+
"Operating System :: OS Independent",
|
|
18
|
+
"Programming Language :: Python",
|
|
19
|
+
"Programming Language :: Python :: 3",
|
|
20
|
+
"Programming Language :: Python :: 3.9",
|
|
21
|
+
"Programming Language :: Python :: 3.10",
|
|
22
|
+
"Programming Language :: Python :: 3.11",
|
|
23
|
+
"Programming Language :: Python :: 3.12",
|
|
24
|
+
"Topic :: Software Development :: Libraries :: Python Modules"
|
|
25
|
+
]
|
|
26
|
+
dependencies = ["tzdata"]
|
|
27
|
+
|
|
28
|
+
[tool.setuptools]
|
|
29
|
+
package-dir = {"" = "src"}
|
|
30
|
+
|
|
31
|
+
[tool.setuptools.packages.find]
|
|
32
|
+
where = ["src"]
|
eones-1.0.0/setup.cfg
ADDED
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: Eones
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Elegant time manipulation and reasoning library
|
|
5
|
+
Author-email: Rodrigo Ezequiel RoldΓ‘n <roldriel@gmail.com>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Keywords: datetime,time,calendar,library,dates,timezones
|
|
8
|
+
Classifier: Development Status :: 4 - Beta
|
|
9
|
+
Classifier: Intended Audience :: Developers
|
|
10
|
+
Classifier: Operating System :: OS Independent
|
|
11
|
+
Classifier: Programming Language :: Python
|
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
18
|
+
Requires-Python: >=3.8
|
|
19
|
+
Description-Content-Type: text/markdown
|
|
20
|
+
License-File: LICENSE.md
|
|
21
|
+
Requires-Dist: tzdata
|
|
22
|
+
Dynamic: license-file
|
|
23
|
+
|
|
24
|
+
# Eones
|
|
25
|
+

|
|
26
|
+

|
|
27
|
+

|
|
28
|
+

|
|
29
|
+

|
|
30
|
+

|
|
31
|
+

|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
> Compatible with Python 3.8+ Β· No external dependencies Β· Portable and lightweight
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
## β¨ What is Eones?
|
|
40
|
+
|
|
41
|
+
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.
|
|
42
|
+
|
|
43
|
+
> *βThat is not dead which can eternal lie, and with strange aeons even death may die.β*
|
|
44
|
+
> β *Abdul Alhazred*, Necronomicon
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
## π¦ Installation
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
pip install "eones"
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
> If you're working with timezones on Windows or containers:
|
|
55
|
+
> β οΈ Also install `tzdata`:
|
|
56
|
+
> ```bash
|
|
57
|
+
> pip install tzdata
|
|
58
|
+
> ```
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
## π§ͺ Basic Example
|
|
63
|
+
|
|
64
|
+
```python
|
|
65
|
+
from eones import Eones
|
|
66
|
+
|
|
67
|
+
z = Eones("2025-06-15")
|
|
68
|
+
z.add(months=1, days=3)
|
|
69
|
+
|
|
70
|
+
print(z.format("%Y-%m-%d")) # β 2025-07-18
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
---
|
|
74
|
+
|
|
75
|
+
## π Key Features
|
|
76
|
+
|
|
77
|
+
- β
Automatic parsing for `str`, `dict`, `datetime`, `Eones`
|
|
78
|
+
- β
Add/subtract days, months, years, minutes, seconds
|
|
79
|
+
- β
Date comparison (same week, within year, between ranges)
|
|
80
|
+
- β
Full day/month/year ranges
|
|
81
|
+
- β
Truncation and rounding by unit
|
|
82
|
+
- β
Full support for `ZoneInfo` (PEP 615)
|
|
83
|
+
- β
Zero external dependencies
|
|
84
|
+
- β
Conversion to `datetime`, `date`, and native types
|
|
85
|
+
|
|
86
|
+
---
|
|
87
|
+
|
|
88
|
+
## π§Ύ Comparison with other libraries
|
|
89
|
+
|
|
90
|
+
| Feature | Eones | Pendulum | Arrow | Delorean | dateutil | pytz |
|
|
91
|
+
|-----------------------------------------|:-----:|:--------:|:-----:|:--------:|:--------:|:----:|
|
|
92
|
+
| Modern, consistent API | β
| β
| β
| β οΈ | β | β |
|
|
93
|
+
| Date arithmetic (add/subtract) | β
| β
| β
| β
| β | β |
|
|
94
|
+
| Flexible parsing (string, dict, dt) | β
| β
| β
| β οΈ | β
| β |
|
|
95
|
+
| Native timezone support | β
| β
| β
| β
| β οΈ | β
|
|
|
96
|
+
| No external dependencies | β
| β | β | β | β | β |
|
|
97
|
+
| Coverage tested β₯ 97% | β
| β | β | β | β | β |
|
|
98
|
+
| Can replace native `datetime` directly | β
| β
| β
| β | β | β |
|
|
99
|
+
| Permissive license (MIT / BSD) | β
| β
| β
| β
| β
| β
|
|
|
100
|
+
| Actively maintained | β
| β
| β
| β | β
| β οΈ |
|
|
101
|
+
|
|
102
|
+
---
|
|
103
|
+
|
|
104
|
+
## π Advanced Examples
|
|
105
|
+
|
|
106
|
+
You can find more usage examples in:
|
|
107
|
+
|
|
108
|
+
- [examples/basic_usage.py](examples/basic_usage.py)
|
|
109
|
+
- [examples/advanced_usage.py](examples/advanced_usage.py)
|
|
110
|
+
- [examples/labor_calendar.py](examples/labor_calendar.py)
|
|
111
|
+
|
|
112
|
+
---
|
|
113
|
+
|
|
114
|
+
## π§ Tests & Coverage
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
tox
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
```bash
|
|
121
|
+
coverage html && open htmlcov/index.html
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
---
|
|
125
|
+
|
|
126
|
+
## π Requirements
|
|
127
|
+
|
|
128
|
+
- Python 3.8 or higher
|
|
129
|
+
- (Optional) `tzdata` if using timezones in systems without a local zoneinfo database
|
|
130
|
+
|
|
131
|
+
---
|
|
132
|
+
|
|
133
|
+
## π License
|
|
134
|
+
|
|
135
|
+
MIT Β© 2025 β Rodrigo Ezequiel RoldΓ‘n
|
|
136
|
+
[View full license](LICENSE.md)
|