Skip to main content

No project description provided

Project description


date-operations


Usage

Get days, months or years between 2 dates

With these functions you get the amount of days, months or years between 2 days. In the case of months and years, there needs to be a full month or year between the dates in order to make it count:

from date_operations import (
    days_between,
    months_between,
    years_between,
)

days_between("2023-01-01", "2023-01-02")  # 1

months_between("2023-01-01", "2023-02-01")  # 1
months_between("2023-01-31", "2023-02-01")  # 0

years_between("2023-01-01", "2024-01-01")  # 1
years_between("2023-12-31", "2024-01-01")  # 0

Get months or years started between 2 dates

If you need to know how many months or years have started between 2 dates (not caring about full months or years), these are the functions to use:

from date_operations import (
    months_started_between,
    years_started_between,
)

months_started_between("2023-01-01", "2023-02-01")  # 1
months_started_between("2023-01-31", "2023-02-01")  # 1

years_started_between("2023-01-01", "2024-01-01")  # 1
years_started_between("2023-12-31", "2024-01-01")  # 1

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

date_operations-0.1.0-py3-none-any.whl (2.1 kB view hashes)

Uploaded Python 3

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