Skip to content

Commit 1ee06ff

Browse files
committed
Merge branch 'release/0.5'
2 parents 327e2d4 + 5859aad commit 1ee06ff

30 files changed

+5568
-104
lines changed

.all-contributorsrc

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,16 @@
6868
"test",
6969
"doc"
7070
]
71+
},
72+
{
73+
"login": "taylor-arnold",
74+
"name": "Taylor Arnold",
75+
"avatar_url": "https://avatars.githubusercontent.com/u/5752184?v=4",
76+
"profile": "http://taylorarnold.org",
77+
"contributions": [
78+
"review",
79+
"ideas"
80+
]
7181
}
7282
],
7383
"contributorsPerLine": 7,
@@ -77,5 +87,6 @@
7787
"repoHost": "https://github.com",
7888
"projectName": "undate-python",
7989
"projectOwner": "dh-tech",
80-
"badgeTemplate": "![All Contributors](https://img.shields.io/github/all-contributors/dh-tech/undate-python?color=ee8449&style=flat-square)"
90+
"badgeTemplate": "![All Contributors](https://img.shields.io/github/all-contributors/dh-tech/undate-python?color=ee8449&style=flat-square)",
91+
"commitType": "docs"
8192
}

.github/workflows/check.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ name: Check style + docs + types
33
on:
44
pull_request:
55

6+
permissions:
7+
contents: read
8+
69
jobs:
710
check:
811
runs-on: ubuntu-latest

.github/workflows/unit_tests.yml

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
name: unit tests
22

3+
permissions:
4+
contents: read
5+
id-token: write
6+
37
on:
48
push:
59
branches:
@@ -33,26 +37,25 @@ jobs:
3337
uses: actions/setup-python@v5
3438
with:
3539
python-version: ${{ matrix.python }}
40+
cache: 'pip'
41+
cache-dependency-path: '**/pyproject.toml'
3642

37-
- name: Install uv
38-
uses: astral-sh/setup-uv@v5
39-
with:
40-
enable-cache: true
41-
cache-dependency-glob: "pyproject.toml"
42-
43-
- name: Install package with dev and test dependencies
44-
run: uv sync --extra test
43+
- name: Install package with dependencies
44+
run: pip install -e ".[test]"
4545

4646
# for all versions but the one we use for code coverage, run normally
47-
- name: Run unit tests normally
48-
run: uv run pytest
47+
- name: Run unit tests without code coverage
48+
run: pytest
4949
if: ${{ matrix.python != env.COV_PYTHON_VERSION }}
5050

5151
# run code coverage in one version only
5252
- name: Run unit tests with code coverage reporting
53-
run: uv run pytest --cov=undate
53+
run: pytest --cov=.
5454
if: ${{ matrix.python == env.COV_PYTHON_VERSION }}
55-
- name: Upload test coverage to Codecov
56-
uses: codecov/codecov-action@v3
55+
56+
- name: Upload coverage to Codecov
57+
uses: codecov/codecov-action@v4
58+
env:
59+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
5760
if: ${{ matrix.python == env.COV_PYTHON_VERSION }}
5861

CHANGELOG.md

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,21 @@
11
# Change Log
22

3+
## 0.5
4+
5+
- New `UnDelta` and `UnInt` classes for uncertain durations
6+
- `Undate.duration` now returns either a `Timedelta` or an `UnDelta` if the duration is ambiguous
7+
- New properties `possible_years` and `representative_years` on `Undate` class, used for calculating durations for uncertain years and months
8+
- New `weekday` method on class `undate.date.Date`
9+
- Calendar converter improvements:
10+
- Calendar converter classes can optional provide minimum and maximum years for uncertain dates
11+
- New calendar methods `days_in_year` and `representative_years`
12+
- Hebrew date parser now allows for week days, along with additional month variants
13+
- Preliminary Seleucide calendar converter class, based on Hebrew calendar with a year offset
14+
- New method `as_calendar` on `Undate` class, to set calendar without doing any conversion
15+
- Readme examples have been improved and extended
16+
- New example notebook testing Hebrew, Islamic, and Seleucid date parsing and conversion with Princeton Geniza Project data
17+
- bugfix: duration for uncertain years previously returned the duration from earliest to latest possible dates in range; now returns an `UnDelta` with the possible durations for the possible years in the given calendar
18+
319
## 0.4
420

521
- Undate is now Calendar aware / Calendar explicit; default is Gregorian
@@ -20,7 +36,6 @@
2036
- Reorganized examples folder to avoid unnecessary nesting
2137
- ISMI data has been updated from older JSON data to examples in RDF (turtle)
2238

23-
2439
## 0.3.1
2540

2641
Update readthedocs config for current installation
@@ -49,7 +64,7 @@ Update readthedocs config for current installation
4964

5065
### numpy impact
5166

52-
Performance differences seem to be negligible, but it does increase payload size. The virtualenv for installing version 0.2 was 14MB; when installing the newer version with numpy, the virtualenv is 46MB (the numpy folder in site packages is 31MB on its own).
67+
Performance differences seem to be negligible, but it does increase payload size. The virtualenv for installing version 0.2 was 14MB; when installing the newer version with numpy, the virtualenv is 46MB (the numpy folder in site packages is 31MB on its own).
5368

5469
## 0.2
5570

CONTRIBUTORS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ We use [All Contributors](https://allcontributors.org/) because we recognize tha
1919
<td align="center" valign="top" width="14.28%"><a href="https://github.com/robcast"><img src="https://avatars.githubusercontent.com/u/1488847?v=4?s=100" width="100px;" alt="Robert Casties"/><br /><sub><b>Robert Casties</b></sub></a><br /><a href="#data-robcast" title="Data">🔣</a> <a href="#ideas-robcast" title="Ideas, Planning, & Feedback">🤔</a> <a href="https://github.com/dh-tech/undate-python/pulls?q=is%3Apr+reviewed-by%3Arobcast" title="Reviewed Pull Requests">👀</a></td>
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>
22+
<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>
2223
</tr>
2324
</tbody>
2425
<tfoot>

README.md

Lines changed: 76 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -5,34 +5,60 @@
55
**undate** is a python library for working with uncertain or partially known dates.
66

77
> [!WARNING]
8-
> This is alpha software and is not yet feature complete! Use with caution and give us feedback.
9-
> Currently `undate` supports parsing and formatting dates in ISO8601, some
10-
portions of EDTF (Extended Date Time Format), and parsing and conversion for dates in Hebrew Anno Mundi and Islamic Hijri calendars
8+
> This is beta software and is not yet feature complete! Use with caution and give us feedback.
9+
> Currently `undate` supports parsing and formatting dates in ISO8601, some
10+
> portions of EDTF (Extended Date Time Format), and parsing and conversion for dates in Hebrew Anno Mundi and Islamic Hijri calendars.
1111
12-
*Undate was initially created as part of a [DH-Tech](https://dh-tech.github.io/) hackathon in November 2022.*
12+
_Undate was initially created as part of a [DH-Tech](https://dh-tech.github.io/) hackathon in November 2022._
1313

14-
* * *
14+
---
1515

1616
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.11068867.svg)](https://doi.org/10.5281/zenodo.11068867)
1717
[![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
1818
[![Documentation Status](https://readthedocs.org/projects/undate-python/badge/?version=latest)](https://undate-python.readthedocs.io/en/latest/?badge=latest)
1919
[![unit tests](https://github.com/dh-tech/undate-python/actions/workflows/unit_tests.yml/badge.svg)](https://github.com/dh-tech/undate-python/actions/workflows/unit_tests.yml)
2020
[![codecov](https://codecov.io/gh/dh-tech/undate-python/branch/main/graph/badge.svg?token=GE7HZE8C9D)](https://codecov.io/gh/dh-tech/undate-python)
2121
[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
22+
2223
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
24+
2325
[![All Contributors](https://img.shields.io/badge/all_contributors-5-orange.svg?style=flat-square)](CONTRIBUTORS.md)
26+
2427
<!-- ALL-CONTRIBUTORS-BADGE:END -->
2528

2629
Read [Contributors](CONTRIBUTORS.md) for detailed contribution information.
2730

31+
## Installation
32+
33+
_Recommended_: use pip to install the latest published version from PyPI:
34+
35+
```console
36+
pip install undate
37+
```
38+
39+
To install a development version or specific tag or branch, you can install from GitHub.
40+
Use the `@name` notation to specify the branch or tag; e.g., to install development version:
41+
42+
```console
43+
pip install git+https://github.com/dh-tech/undate-python@develop#egg=undate
44+
```
45+
2846
## Example Usage
2947

30-
Often humanities and cultural data include imprecise or uncertain temporal information. We want to store that information but also work with it in a structured way, not just treat it as text for display. Different projects may need to work with or convert between different date formats or even different calendars.
48+
Often humanities and cultural data include imprecise or uncertain
49+
temporal information. We want to store that information but also work
50+
with it in a structured way, not just treat it as text for display.
51+
Different projects may need to work with or convert between different
52+
date formats or even different calendars.
3153

32-
An `undate.Undate` is analogous to python’s builtin `datetime.date` object, but with support for varying degrees of precision and unknown information. You can initialize an undate with either strings or numbers for whichever parts of the date are known or partially known. An `Undate` can take an optional label.
54+
An `undate.Undate` is analogous to python’s builtin `datetime.date`
55+
object, but with support for varying degrees of precision and unknown
56+
information. You can initialize an `Undate` with either strings or
57+
numbers for whichever parts of the date are known or partially known.
58+
An `Undate` can take an optional label.
3359

3460
```python
35-
from undate.undate import Undate
61+
from undate import Undate
3662

3763
november7 = Undate(2000, 11, 7)
3864
november = Undate(2000, 11)
@@ -46,12 +72,14 @@ easter1916 = Undate(1916, 4, 23, label="Easter 1916")
4672
```
4773

4874
You can convert an `Undate` to string using a date formatter (current default is ISO8601):
75+
4976
```python
5077
>>> [str(d) for d in [november7, november, year2k, november7_some_year]]
5178
['2000-11-07', '2000-11', '2000', '--11-07']
5279
```
5380

5481
If enough information is known, an `Undate` object can report on its duration:
82+
5583
```python
5684
>>> december = Undate(2000, 12)
5785
>>> feb_leapyear = Undate(2024, 2)
@@ -68,7 +96,9 @@ If enough information is known, an `Undate` object can report on its duration:
6896
2024-02 - duration in days: 29
6997
```
7098

71-
If enough of the date is known and the precision supports it, you can check if one date falls within another date:
99+
If enough of the date is known and the precision supports it, you can
100+
check if one date falls within another date:
101+
72102
```python
73103
>>> november7 = Undate(2000, 11, 7)
74104
>>> november2000 = Undate(2000, 11)
@@ -86,7 +116,10 @@ False
86116
False
87117
```
88118

89-
For dates that are imprecise or partially known, `undate` calculates earliest and latest possible dates for comparison purposes so you can sort dates and compare with equals, greater than, and less than. You can also compare with python `datetime.date` objects.
119+
For dates that are imprecise or partially known, `undate` calculates
120+
earliest and latest possible dates for comparison purposes so you can
121+
sort dates and compare with equals, greater than, and less than. You
122+
can also compare with python `datetime.date` objects.
90123

91124
```python
92125
>>> november7_2020 = Undate(2020, 11, 7)
@@ -104,7 +137,8 @@ False
104137
False
105138
```
106139

107-
When dates cannot be compared due to ambiguity or precision, comparison methods raise a `NotImplementedError`.
140+
When dates cannot be compared due to ambiguity or precision, comparison
141+
methods raise a `NotImplementedError`.
108142

109143
```python
110144
>>> november_2020 = Undate(2020, 11)
@@ -118,17 +152,22 @@ Traceback (most recent call last):
118152
NotImplementedError: Can't compare when one date falls within the other
119153
```
120154

121-
An `UndateInterval` is a date range between two `Undate` objects. Intervals can be open-ended, allow for optional labels, and can calculate duration if enough information is known
155+
An `UndateInterval` is a date range between two `Undate` objects.
156+
Intervals can be open-ended, allow for optional labels, and can
157+
calculate duration if enough information is known. `UndateIntervals`
158+
are inclusive (i.e., a closed interval), and include both the earliest
159+
and latest date as part of the range.
160+
122161
```python
123-
>>> from undate.undate import UndateInterval
162+
>>> from undate import UndateInterval
124163
>>> UndateInterval(Undate(1900), Undate(2000))
125164
<UndateInterval 1900/2000>
126-
>>> UndateInterval(Undate(1900), Undate(2000), label="19th century")
127-
>>> UndateInterval(Undate(1900), Undate(2000), label="19th century").duration().days
128-
36890
129-
<UndateInterval '19th century' (1900/2000)>
130-
>>> UndateInterval(Undate(1900), Undate(2000), label="20th century")
131-
<UndateInterval '20th century' (1900/2000)>
165+
>>> UndateInterval(Undate(1801), Undate(1900), label="19th century")
166+
>>> UndateInterval(Undate(1801), Undate(1900), label="19th century").duration().days
167+
36524
168+
<UndateInterval '19th century' (1801/1900)>
169+
>>> UndateInterval(Undate(1901), Undate(2000), label="20th century")
170+
<UndateInterval '20th century' (1901/2000)>
132171
>>> UndateInterval(latest=Undate(2000)) # before 2000
133172
<UndateInterval ../2000>
134173
>>> UndateInterval(Undate(1900)) # after 1900
@@ -139,8 +178,10 @@ An `UndateInterval` is a date range between two `Undate` objects. Intervals can
139178
31
140179
```
141180

142-
You can initialize `Undate` or `UndateInterval` objects by parsing a date string with a specific converter, and you can also output an `Undate` object in those formats.
143-
Currently available converters are "ISO8601" and "EDTF" and supported calendars.
181+
You can initialize `Undate` or `UndateInterval` objects by parsing a
182+
date string with a specific converter, and you can also output an
183+
`Undate` object in those formats. Currently available converters
184+
are "ISO8601" and "EDTF" and supported calendars.
144185

145186
```python
146187
>>> from undate import Undate
@@ -158,9 +199,17 @@ Currently available converters are "ISO8601" and "EDTF" and supported calendars.
158199

159200
### Calendars
160201

161-
All `Undate` objects are calendar aware, and date converters include support for parsing and working with dates from other calendars. The Gregorian calendar is used by default; currently `undate` supports the Islamic Hijri calendar and the Hebrew Anno Mundi calendar based on calendar conversion logic implemented in the [convertdate](https://convertdate.readthedocs.io/en/latest/) package.
202+
All `Undate` objects are calendar aware, and date converters include
203+
support for parsing and working with dates from other calendars. The
204+
Gregorian calendar is used by default; currently `undate` supports the
205+
Islamic Hijri calendar and the Hebrew Anno Mundi calendar based on
206+
calendar conversion logic implemented in the
207+
[convertdate](https://convertdate.readthedocs.io/en/latest/) package.
162208

163-
Dates are stored with the year, month, day and appropriate precision for the original calendar; internally, earliest and latest dates are calculated in Gregorian / Proleptic Gregorian calendar for standardized comparison across dates from different calendars.
209+
Dates are stored with the year, month, day and appropriate precision for
210+
the original calendar; internally, earliest and latest dates are
211+
calculated in Gregorian / Proleptic Gregorian calendar for standardized
212+
comparison across dates from different calendars.
164213

165214
```python
166215
>>> from undate import Undate
@@ -181,9 +230,11 @@ Dates are stored with the year, month, day and appropriate precision for the ori
181230
[<Undate '26 Tammuz 4816 Anno Mundi' 4816-04-26 (Hebrew)>, <Undate 'Rajab 495 Hijrī' 0495-07 (Islamic)>, <Undate 2001 (Gregorian)>]
182231
```
183232

184-
* * *
233+
---
185234

186-
For more examples, refer to the code notebooks included in the [examples](https://github.com/dh-tech/undate-python/tree/main/examples/) in this repository.
235+
For more examples, refer to the code notebooks included in the[examples]
236+
(https://github.com/dh-tech/undate-python/tree/main/examples/) in this
237+
repository.
187238

188239
## Documentation
189240

codecov.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
coverage:
2+
status:
3+
project:
4+
default: false # disable default status check
5+
app: # custom target for app code
6+
target: auto # default target (95%)
7+
paths:
8+
- "src/" # limit to files within src code directory
9+
tests: # declare a new status context for "tests"
10+
target: 100% # we always want 100% coverage here
11+
paths:
12+
- "tests/" # only include coverage in "tests/" folder
13+
14+

0 commit comments

Comments
 (0)