Skip to main content

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.

codecov Downloads per Month Package version

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 pynimbar, 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

temporal_adjuster-1.0.2.tar.gz (9.7 kB view details)

Uploaded Source

Built Distribution

temporal_adjuster-1.0.2-py3-none-any.whl (12.2 kB view details)

Uploaded Python 3

File details

Details for the file temporal_adjuster-1.0.2.tar.gz.

File metadata

  • Download URL: temporal_adjuster-1.0.2.tar.gz
  • Upload date:
  • Size: 9.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.0

File hashes

Hashes for temporal_adjuster-1.0.2.tar.gz
Algorithm Hash digest
SHA256 a53200298c051f5c76206765dbb07e9362ca2dde2cabda7a22b1f3570e7a0bc9
MD5 2a51cd47fed09847e697455a54d8052d
BLAKE2b-256 b0216887c6a27c64a771985fe2b613c77c768f442911a6b86e3f5e2523878e4d

See more details on using hashes here.

File details

Details for the file temporal_adjuster-1.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for temporal_adjuster-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 2d03a23f5c257d9d0552d197eb19b721be61c0045c2d209c397d2c95a571973b
MD5 ed333aa61aa0ecc88d295b8c5b961609
BLAKE2b-256 bce6aa6e4ca4cc48a3c429c20aa1523e11695d10a2925d52c50c7d51e95da689

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page