Skip to content

Commit

Permalink
Merge pull request #7 from shendric/main
Browse files Browse the repository at this point in the history
Update to v1.3
  • Loading branch information
shendric authored Jul 22, 2024
2 parents 082638e + 52a7b28 commit dc8fe95
Show file tree
Hide file tree
Showing 7 changed files with 268 additions and 67 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pythonpackage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v2
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# History of changes

## [1.3.0] 2024-07-22

### Added
- (Monthly) exclusion rules from `PeriodIterator`
- python 3.12 tests

## [1.2.1] 2024-04-09

### Fixed
Expand Down
29 changes: 27 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@

![Python package](https://github.com/shendric/dateperiods/workflows/Python%20package/badge.svg?branch=master)
[![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://choosealicense.com/licenses/mit/)
[![Python Version](https://img.shields.io/badge/python-3.7,_3.8,_3.9,_3.10,_3.11-blue)](https://www.python.org/downloads/)
[![Python Version](https://img.shields.io/badge/python-3.7,_3.8,_3.9,_3.10,_3.11,_3.12-blue)](https://www.python.org/downloads/)

## About dateperiods

The package `dateperiods` is meant to make iterating over certain periods between two dates easy. The main `DatePeriod` class takes two dates into account, the start of the time coverage with a daily granularity, but microsecond resolution:


### Basic Usage

```python
>>> from dateperiods import DatePeriod
>>> DatePeriod([2020, 10, 1], [2021, 4, 30])
Expand Down Expand Up @@ -68,7 +71,7 @@ DateDuration:
The period can be segmented into defined a duration type (day, isoweek, month, year):

```python
>>> dp.get_segments("month)
>>> dp.get_segments("month")
PeriodIterator:
tcs: 2020-10-01 00:00:00
tce: 2021-04-30 23:59:59.999999
Expand All @@ -89,6 +92,27 @@ The return value of `get_segments()` is a python iterator with each item is a `D
'2021-04-01 00:00:00 till 2021-04-30 23:59:59.999999']
```

### Exclusion Rules

A `DatePeriod` can be defined with rules that define if segments should be
excluded from the `PeriodIterator`. E.g.

```python
>>> from dateperiods import ExcludeMonth
>>> period_exc = DatePeriod([2020, 9, 1], [2021, 5, 31], exclude_rules=ExcludeMonth([5, 9]))
```
will ensure that the month of September 2020 and May 2021, will not be part
of the monthly sub-periods:

```python
>>> period_exc.get_segments("month")
PeriodIterator:
tcs: 2020-10-01 00:00:00
tce: 2021-04-30 23:59:59.999999
segment_duration: month
n_periods: 7
```

## Installation

See the [release page](https://github.com/shendric/dateperiods/releases) of this project for the latest version of `dateperiods` and install either from the main branch
Expand All @@ -115,3 +139,4 @@ Copyright (c) 2009, Gerhard Weis

- [ ] Add merge (`+`) operator for `DatePeriods`
- [ ] Add option to `DatePeriods.get_segments` to ensure sub-periods are fully within base period
- [ ] Add custom segments lengths using `dateutil-rrulestr()` (e.g. `RRULE:FREQ=DAILY;INTERVAL=14` for two week periods)
4 changes: 2 additions & 2 deletions citation.CFF
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ authors:
given-names: Stefan
orcid: https://orcid.org/0000-0002-1412-3146
title: "dateperiods: Periods between dates in python"
version: v1.1.0
date-released: 2022-02-07
version: v1.3.0
date-released: 2024-07-22
Loading

0 comments on commit dc8fe95

Please sign in to comment.