Skip to main content

date-operations

🗓 Easy to use functions for common date operations


Usage

Days between 2 dates

Get the amount of days between 2 dates:

from date_operations import days_between

days_between("2023-01-01", "2023-01-02")  # 1
days_between("01 01 2023", "01/01/2024")  # 365

# You can omit the day:
days_between("jan-2023", "01/02/2023")  # 31

Months between 2 dates

Get the amount of full months between 2 dates:

from date_operations import months_between

months_between("01 05 2023", "31 05 2023")  # 0
months_between("01-05-2023", "01-06-2023")  # 1
months_between("10/05/2022", "10/05/2023")  # 12
months_between("10-may-2022", "09-may-2023")  # 11

# You can omit the day:
months_between("05-2023", "06-2023")  # 1

Months started between 2 dates

Get the amount of months started between 2 dates:

from date_operations import months_started_between

months_started_between("31 05 2023", "01 06 2023")  # 1
months_started_between("01-05-2023", "01-06-2023")  # 1
months_started_between("31/12/2022", "01/01/2023")  # 1

Years between 2 dates

Get the amount of full years between 2 dates:

from date_operations import years_between

years_between("15 01 2022", "15 01 2023")  # 1
years_between("15-01-2022", "14-01-2023")  # 0
years_between("31/12/2022", "01/01/2023")  # 0

# You can omit the day:
years_between("05/2023", "06/2023")  # 0
years_between("05/2023", "01/2024")  # 0
years_between("05/2023", "05/2024")  # 1

Years started between 2 dates

Get the amount of years started between 2 dates:

from date_operations import years_started_between

years_started_between("31 12 2022", "01 01 2023")  # 1
years_started_between("01-01-2023", "31-12-2023")  # 0
years_started_between("31/12/2022", "01/01/2024")  # 2

Date formats

Date formats are inferred given this priority list. If the format of your date is not within the list you can add it or explicitly indicate the format of a given date. The formats added to the list are given priority.

from date_operations import months_between

months_between("01-01", "01-02", format_1="%d-%m", format_2="%d-%m")  # 1
months_between("01-01", "01-02", extra_formats=["%d-%m"])  # 1

The same parameters are used for all the functions.

Metadata

Release files for date-operations 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for date-operations 0.2.0
File Size Uploaded Provenance Actions
date_operations-0.2.0.tar.gz 3.7 kB Without provenance Details for date_operations-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for date-operations 0.2.0
File Interpreter ABI Platform Actions
date_operations-0.2.0-py3-none-any.whl Python 3 none any Details for date_operations-0.2.0-py3-none-any.whl

Total release size: 8.3 kB

Release files / date_operations-0.2.0.tar.gz

Download URL date_operations-0.2.0.tar.gz
Size 3.7 kB
Tags Source
SHA-256 checksum
How to use checksums
05fd7b2c299572360cbbb5d7173cf25a34e1a10f2676dab83c0a614232f1673a
BLAKE2b-256 checksum
How to use checksums
3f49ffe09ce1c22e13fdf20322af9474f77c04db2acdb21b1ef7df0ffee23a3f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.4.2 CPython/3.10.2 Darwin/20.6.0

Release files / date_operations-0.2.0-py3-none-any.whl

Download URL date_operations-0.2.0-py3-none-any.whl
Size 4.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
41c05a073ffc1b5abc9d49c9b6ac015c924e72c23ebdfe3ef35e4c86971ce29e
BLAKE2b-256 checksum
How to use checksums
1ed05d951f0ce97fb125301589fdaabeb0d18cb4a97e72cd89d2cff38dcf6756
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.4.2 CPython/3.10.2 Darwin/20.6.0

Security for date-operations 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page