Skip to content

Commit

Permalink
Done with version 1.2.0, still need to setup readthedocs stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
gtkacz committed Jun 20, 2024
1 parent a10d5b4 commit d6604e8
Show file tree
Hide file tree
Showing 10 changed files with 655 additions and 111 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

---

## [1.2.0] - 2024-06-20

### Added

- Altered sequence processing to make use of numpy vectorization.

## [1.1.1] - 2024-06-17

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta"
[project]
name = "temporal_adjuster"
dynamic = ["dependencies"]
version = "1.1.0"
version = "1.2.0"
description = "Adjusters are a key tool for modifying temporal objects. They exist to externalize the process of adjustment, permitting different approaches, as per the strategy design pattern. Temporal Adjuster provides tools that help pinpoint very specific moments in time, without having to manually count days, weeks, or months."
requires-python = ">= 3.3"
authors = [
Expand Down
1 change: 1 addition & 0 deletions requirements_dev.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
coverage
mypy
pandas
pre-commit
psutil
Expand Down
8 changes: 8 additions & 0 deletions temporal_adjuster/common/decorators/sequence_processor.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from typing import TypeVar

T = TypeVar("T")

def sequenceable(target: str):
"""
This decorator is used to process if a sequence of values passed as an argument to a function. The function is called for each value in the sequence, and the result is stored in the same position in the sequence.
"""
33 changes: 33 additions & 0 deletions temporal_adjuster/common/enums/day_of_week.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
from enum import IntEnum

class Weekday(IntEnum):
"""
A day-of-week, such as 'Tuesday'.
Weekday is an enum representing the 7 days of the week - Monday, Tuesday, Wednesday, Thursday, Friday, Saturday and Sunday.
In addition to the textual enum name, each day-of-week has an int value. The int value follows the Python datetime standard, from 0 (Monday) to 6 (Sunday).
"""

MONDAY: int
TUESDAY: int
WEDNESDAY: int
THURSDAY: int
FRIDAY: int
SATURDAY: int
SUNDAY: int

class ISOWeekday(IntEnum):
"""
A day-of-week, such as 'Tuesday'.
Weekday is an enum representing the 7 days of the week - Monday, Tuesday, Wednesday, Thursday, Friday, Saturday and Sunday.
In addition to the textual enum name, each day-of-week has an int value. The int value follows the ISO-8601 standard, from 1 (Monday) to 7 (Sunday).
"""

MONDAY: int
TUESDAY: int
WEDNESDAY: int
THURSDAY: int
FRIDAY: int
SATURDAY: int
SUNDAY: int
1 change: 1 addition & 0 deletions temporal_adjuster/common/exceptions/common.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
class DateError(Exception): ...
5 changes: 5 additions & 0 deletions temporal_adjuster/common/types/dates.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from datetime import date, datetime
from typing import TypeVar

AnyDate = datetime | date
DateT = TypeVar("DateT", bound=AnyDate)
72 changes: 18 additions & 54 deletions temporal_adjuster/modules/first_and_last_day_operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@
class _TemporalAdjusterForFirstAndLastDays:
@staticmethod
@sequenceable(target="date")
def first_day_of_week(
date: Union[DateT, Sequence[DateT]]
) -> Union[DateT, Sequence[DateT]]:
def first_day_of_week(date: DateT) -> DateT:
"""
Returns the first day of the week of the given date. The week starts on Monday.
Expand All @@ -25,9 +23,7 @@ def first_day_of_week(

@staticmethod
@sequenceable(target="date")
def first_day_of_next_week(
date: Union[DateT, Sequence[DateT]]
) -> Union[DateT, Sequence[DateT]]:
def first_day_of_next_week(date: DateT) -> DateT:
"""
Returns the first day of the next week of the given date. The week starts on Monday.
Expand All @@ -43,9 +39,7 @@ def first_day_of_next_week(

@staticmethod
@sequenceable(target="date")
def first_day_of_last_week(
date: Union[DateT, Sequence[DateT]]
) -> Union[DateT, Sequence[DateT]]:
def first_day_of_last_week(date: DateT) -> DateT:
"""
Returns the first day of the last week of the given date. The week starts on Monday.
Expand All @@ -61,9 +55,7 @@ def first_day_of_last_week(

@staticmethod
@sequenceable(target="date")
def first_day_of_month(
date: Union[DateT, Sequence[DateT]]
) -> Union[DateT, Sequence[DateT]]:
def first_day_of_month(date: DateT) -> DateT:
"""
Returns the first day of the month of the given date.
Expand All @@ -77,9 +69,7 @@ def first_day_of_month(

@staticmethod
@sequenceable(target="date")
def first_day_of_next_month(
date: Union[DateT, Sequence[DateT]]
) -> Union[DateT, Sequence[DateT]]:
def first_day_of_next_month(date: DateT) -> DateT:
"""
Returns the first day of the next month of the given date.
Expand All @@ -95,9 +85,7 @@ def first_day_of_next_month(

@staticmethod
@sequenceable(target="date")
def first_day_of_last_month(
date: Union[DateT, Sequence[DateT]]
) -> Union[DateT, Sequence[DateT]]:
def first_day_of_last_month(date: DateT) -> DateT:
"""
Returns the first day of the last month of the given date.
Expand All @@ -113,9 +101,7 @@ def first_day_of_last_month(

@staticmethod
@sequenceable(target="date")
def first_day_of_year(
date: Union[DateT, Sequence[DateT]]
) -> Union[DateT, Sequence[DateT]]:
def first_day_of_year(date: DateT) -> DateT:
"""
Returns the first day of the year of the given date.
Expand All @@ -129,9 +115,7 @@ def first_day_of_year(

@staticmethod
@sequenceable(target="date")
def first_day_of_next_year(
date: Union[DateT, Sequence[DateT]]
) -> Union[DateT, Sequence[DateT]]:
def first_day_of_next_year(date: DateT) -> DateT:
"""
Returns the first day of the next year of the given date.
Expand All @@ -147,9 +131,7 @@ def first_day_of_next_year(

@staticmethod
@sequenceable(target="date")
def first_day_of_last_year(
date: Union[DateT, Sequence[DateT]]
) -> Union[DateT, Sequence[DateT]]:
def first_day_of_last_year(date: DateT) -> DateT:
"""
Returns the first day of the last year of the given date.
Expand All @@ -165,9 +147,7 @@ def first_day_of_last_year(

@staticmethod
@sequenceable(target="date")
def last_day_of_week(
date: Union[DateT, Sequence[DateT]]
) -> Union[DateT, Sequence[DateT]]:
def last_day_of_week(date: DateT) -> DateT:
"""
Returns the last day of the week of the given date. The week ends on Sunday.
Expand All @@ -181,9 +161,7 @@ def last_day_of_week(

@staticmethod
@sequenceable(target="date")
def last_day_of_next_week(
date: Union[DateT, Sequence[DateT]]
) -> Union[DateT, Sequence[DateT]]:
def last_day_of_next_week(date: DateT) -> DateT:
"""
Returns the last day of the next week of the given date. The week ends on Sunday.
Expand All @@ -199,9 +177,7 @@ def last_day_of_next_week(

@staticmethod
@sequenceable(target="date")
def last_day_of_last_week(
date: Union[DateT, Sequence[DateT]]
) -> Union[DateT, Sequence[DateT]]:
def last_day_of_last_week(date: DateT) -> DateT:
"""
Returns the last day of the last week of the given date. The week ends on Sunday.
Expand All @@ -217,9 +193,7 @@ def last_day_of_last_week(

@staticmethod
@sequenceable(target="date")
def last_day_of_month(
date: Union[DateT, Sequence[DateT]]
) -> Union[DateT, Sequence[DateT]]:
def last_day_of_month(date: DateT) -> DateT:
"""
Returns the last day of the month of the given date.
Expand All @@ -233,9 +207,7 @@ def last_day_of_month(

@staticmethod
@sequenceable(target="date")
def last_day_of_next_month(
date: Union[DateT, Sequence[DateT]]
) -> Union[DateT, Sequence[DateT]]:
def last_day_of_next_month(date: DateT) -> DateT:
"""
Returns the last day of the next month of the given date.
Expand All @@ -251,9 +223,7 @@ def last_day_of_next_month(

@staticmethod
@sequenceable(target="date")
def last_day_of_last_month(
date: Union[DateT, Sequence[DateT]]
) -> Union[DateT, Sequence[DateT]]:
def last_day_of_last_month(date: DateT) -> DateT:
"""
Returns the last day of the last month of the given date.
Expand All @@ -269,9 +239,7 @@ def last_day_of_last_month(

@staticmethod
@sequenceable(target="date")
def last_day_of_year(
date: Union[DateT, Sequence[DateT]]
) -> Union[DateT, Sequence[DateT]]:
def last_day_of_year(date: DateT) -> DateT:
"""
Returns the last day of the year of the given date.
Expand All @@ -285,9 +253,7 @@ def last_day_of_year(

@staticmethod
@sequenceable(target="date")
def last_day_of_next_year(
date: Union[DateT, Sequence[DateT]]
) -> Union[DateT, Sequence[DateT]]:
def last_day_of_next_year(date: DateT) -> DateT:
"""
Returns the last day of the next year of the given date.
Expand All @@ -303,9 +269,7 @@ def last_day_of_next_year(

@staticmethod
@sequenceable(target="date")
def last_day_of_last_year(
date: Union[DateT, Sequence[DateT]]
) -> Union[DateT, Sequence[DateT]]:
def last_day_of_last_year(date: DateT) -> DateT:
"""
Returns the last day of the last year of the given date.
Expand Down
Loading

0 comments on commit d6604e8

Please sign in to comment.