Skip to content

Commit d42018f

Browse files
committed
Merge branch 'release/0.6'
2 parents 5ef75b4 + 1f0f7c0 commit d42018f

22 files changed

Lines changed: 284 additions & 38 deletions

.all-contributorsrc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,15 @@
7878
"review",
7979
"ideas"
8080
]
81+
},
82+
{
83+
"login": "rettinghaus",
84+
"name": "Klaus Rettinghaus",
85+
"avatar_url": "https://avatars.githubusercontent.com/u/7693447?v=4",
86+
"profile": "https://github.com/rettinghaus",
87+
"contributions": [
88+
"maintenance"
89+
]
8190
}
8291
],
8392
"contributorsPerLine": 7,

.github/workflows/check.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ jobs:
1515
working-directory: .
1616

1717
steps:
18-
- uses: actions/checkout@v4
18+
- uses: actions/checkout@v5
1919
- name: Set up Python 3.12
20-
uses: actions/setup-python@v5
20+
uses: actions/setup-python@v6
2121
with:
2222
python-version: "3.12"
2323

2424
- name: Install uv
25-
uses: astral-sh/setup-uv@v5
25+
uses: astral-sh/setup-uv@v6
2626
with:
2727
enable-cache: true
2828
cache-dependency-glob: "pyproject.toml"

.github/workflows/python-publish.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ jobs:
2121
runs-on: ubuntu-latest
2222

2323
steps:
24-
- uses: actions/checkout@v3
24+
- uses: actions/checkout@v5
2525
- name: Set up Python
26-
uses: actions/setup-python@v3
26+
uses: actions/setup-python@v6
2727
with:
2828
python-version: '3.x'
2929
- name: Install dependencies

.github/workflows/unit_tests.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ jobs:
3030
working-directory: .
3131

3232
steps:
33-
- uses: actions/checkout@v4
33+
- uses: actions/checkout@v5
3434

3535
# use github python action instead of uv to take advantage of caching
3636
- name: Set up Python ${{ matrix.python }}
37-
uses: actions/setup-python@v5
37+
uses: actions/setup-python@v6
3838
with:
3939
python-version: ${{ matrix.python }}
4040
cache: 'pip'
@@ -54,7 +54,7 @@ jobs:
5454
if: ${{ matrix.python == env.COV_PYTHON_VERSION }}
5555

5656
- name: Upload coverage to Codecov
57-
uses: codecov/codecov-action@v4
57+
uses: codecov/codecov-action@v5
5858
env:
5959
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
6060
if: ${{ matrix.python == env.COV_PYTHON_VERSION }}

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Change Log
22

3+
## 0.6
4+
5+
- Experimental omnibus date converter + parser (EDTF, Hebrew, Hijri)
6+
- Reorganized Lark grammar files to a common location
7+
- Improved documentation for converter class parsing and serialization
8+
- Update action versions in GitHub Workflows (contributed by @rettinghaus)
9+
310
## 0.5.2
411
- repr for Undate, UndateInterval, and UnDelta now produce fully-qualified, constructor-style strings with deterministic field ordering.
512
- Added Undate.unknown_year property and is_unknown() method to check for fully-unknown year/month/day.

CONTRIBUTORS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ We use [All Contributors](https://allcontributors.org/) because we recognize tha
2020
<td align="center" valign="top" width="14.28%"><a href="https://github.com/jdamerow"><img src="https://avatars.githubusercontent.com/u/8881141?v=4?s=100" width="100px;" alt="Julia Damerow"/><br /><sub><b>Julia Damerow</b></sub></a><br /><a href="https://github.com/dh-tech/undate-python/commits?author=jdamerow" title="Code">💻</a> <a href="https://github.com/dh-tech/undate-python/pulls?q=is%3Apr+reviewed-by%3Ajdamerow" title="Reviewed Pull Requests">👀</a> <a href="https://github.com/dh-tech/undate-python/commits?author=jdamerow" title="Tests">⚠️</a> <a href="#eventOrganizing-jdamerow" title="Event Organizing">📋</a> <a href="#ideas-jdamerow" title="Ideas, Planning, & Feedback">🤔</a></td>
2121
<td align="center" valign="top" width="14.28%"><a href="https://github.com/maltevogl"><img src="https://avatars.githubusercontent.com/u/20907912?v=4?s=100" width="100px;" alt="Malte Vogl"/><br /><sub><b>Malte Vogl</b></sub></a><br /><a href="https://github.com/dh-tech/undate-python/commits?author=maltevogl" title="Code">💻</a> <a href="https://github.com/dh-tech/undate-python/pulls?q=is%3Apr+reviewed-by%3Amaltevogl" title="Reviewed Pull Requests">👀</a> <a href="https://github.com/dh-tech/undate-python/commits?author=maltevogl" title="Tests">⚠️</a> <a href="https://github.com/dh-tech/undate-python/commits?author=maltevogl" title="Documentation">📖</a></td>
2222
<td align="center" valign="top" width="14.28%"><a href="http://taylorarnold.org"><img src="https://avatars.githubusercontent.com/u/5752184?v=4?s=100" width="100px;" alt="Taylor Arnold"/><br /><sub><b>Taylor Arnold</b></sub></a><br /><a href="https://github.com/dh-tech/undate-python/pulls?q=is%3Apr+reviewed-by%3Ataylor-arnold" title="Reviewed Pull Requests">👀</a> <a href="#ideas-taylor-arnold" title="Ideas, Planning, & Feedback">🤔</a></td>
23+
<td align="center" valign="top" width="14.28%"><a href="https://github.com/rettinghaus"><img src="https://avatars.githubusercontent.com/u/7693447?v=4?s=100" width="100px;" alt="Klaus Rettinghaus"/><br /><sub><b>Klaus Rettinghaus</b></sub></a><br /><a href="#maintenance-rettinghaus" title="Maintenance">🚧</a></td>
2324
</tr>
2425
</tbody>
2526
<tfoot>

docs/undate/converters.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,20 @@ Converters
44
Overview
55
--------
66

7+
8+
.. automodule:: undate.converters
9+
10+
-----
11+
712
.. automodule:: undate.converters.base
813
:members:
914
:undoc-members:
1015

16+
17+
.. autoclass:: undate.converters.combined.OmnibusDateConverter
18+
:members:
19+
20+
1121
Formats
1222
--------
1323

@@ -33,6 +43,8 @@ Extended Date-Time Format (EDTF)
3343
Calendars
3444
---------
3545

46+
.. automodule:: undate.converters.calendars
47+
3648
Gregorian
3749
^^^^^^^^^
3850

src/undate/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = "0.5.2"
1+
__version__ = "0.6.0"
22

33
from undate.date import DatePrecision, UnDelta
44
from undate.undate import Undate, Calendar

src/undate/converters/__init__.py

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,29 @@
1-
from undate.converters.base import BaseDateConverter as BaseDateConverter
1+
"""
2+
Converter classes add support for parsing and serializing dates
3+
in a variety of formats. A subset of these are calendar converters
4+
(:mod:`undate.converters.calendar`), which means they support both parsing
5+
and conversion from an alternate calendar to a common Gregorian
6+
for comparison across dates.
7+
8+
To parse a date with a supported converter, use the ``Undate`` class method
9+
:meth:`~undate.undate.Undate.parse` and specify the date as a string
10+
with the desired format or calendar, e.g.
11+
12+
.. code-block::
13+
14+
Undate.parse("2001-05", "EDTF")
15+
Undate.parse("7 Heshvan 5425", "Hebrew")
16+
17+
For converters that support it, you can also serialize a date in a specified
18+
format with ``Undate`` class method :meth:`~undate.undate.Undate.format`:
19+
20+
.. code-block::
21+
22+
Undate.parse("Rabīʿ ath-Thānī 343", "Islamic").format("EDTF")
23+
24+
25+
"""
26+
27+
from undate.converters.base import BaseDateConverter, GRAMMAR_FILE_PATH
28+
29+
__all__ = ["BaseDateConverter", "GRAMMAR_FILE_PATH"]

src/undate/converters/base.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444

4545
import importlib
4646
import logging
47+
import pathlib
4748
import pkgutil
4849
from functools import cache
4950
from typing import Dict, Type
@@ -53,6 +54,10 @@
5354
logger = logging.getLogger(__name__)
5455

5556

57+
#: Path to parser grammar files
58+
GRAMMAR_FILE_PATH = pathlib.Path(__file__).parent / "grammars"
59+
60+
5661
class BaseDateConverter:
5762
"""Base class for parsing, formatting, and converting dates to handle
5863
specific formats and different calendars."""

0 commit comments

Comments
 (0)