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.
Project description
Temporal Adjuster
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. In essence, a Temporal Adjuster is a function that encapsulates a specific date/time manipulation rule. It operates on a temporal object (representing a date, time, or datetime) to produce a new temporal object adjusted according to the rule. Examples might be an adjuster that sets the date avoiding weekends, or one that sets the date to the last day of the month.
Installation
You can install Temporal Adjuster using pip:
pip install temporal-adjuster
Usage
This package provides a set of predefined temporal adjusters that can be used to adjust a temporal object in various ways. For example:
>>> from datetime import date, datetime
>>> from temporal_adjuster import TemporalAdjuster
>>> from temporal_adjuster.common.enums import Weekday
>>> TemporalAdjuster.first_day_of_next_week(date(2021, 1, 1))
datetime.date(2021, 1, 4)
>>> TemporalAdjuster.last_day_of_last_month(datetime(2021, 1, 1))
datetime.datetime(2020, 12, 31)
>>> TemporalAdjuster.first_of_year(Weekday.SATURDAY, date(2021, 1, 1))
datetime.date(2021, 1, 2)
>>> TemporalAdjuster.nth_of_month(Weekday.SUNDAY, datetime(2021, 5, 1), 2)
datetime.datetime(2021, 5, 9)
>>> TemporalAdjuster.next(Weekday.MONDAY, datetime(2021, 2, 11), 2)
datetime.datetime(2021, 2, 15)
Contributing
If you have any suggestions or improvements for this package, feel free to submit a pull request or open an issue on the GitHub repository as per the CONTRIBUTING document. We appreciate any feedback or contributions!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file temporal_adjuster-1.1.0.tar.gz
.
File metadata
- Download URL: temporal_adjuster-1.1.0.tar.gz
- Upload date:
- Size: 11.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 70eb6d6f0ca371e4f62cf3a4b2e72a27d65319462f0e04381d75ec0830bbc309 |
|
MD5 | f7631c9d396f37b52bf178b1e5ea08b2 |
|
BLAKE2b-256 | 4569f08b3d9e934e17a2e7cc9680693ee659803767412a6a29178fc6d2e93768 |
File details
Details for the file temporal_adjuster-1.1.0-py3-none-any.whl
.
File metadata
- Download URL: temporal_adjuster-1.1.0-py3-none-any.whl
- Upload date:
- Size: 14.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a5b80acd031fc79005bdaed0be3d19074d637e55b5466ed429eb014c187cd63d |
|
MD5 | faadb7fb1428c7d3df7801d97277a7e6 |
|
BLAKE2b-256 | 3965598c07a8fc85b83501eb05cea56a661f825cdec4a10ed0e9671e43ce720c |