Date Assistant
For more details take a look at the docs
Installation
date-assistant is published on PyPI and can be installed from there:
pip install date-assistant
Usage
💡 Please consider that the default date format is '%Y-%m-%d'. Anyways, you can indicate the format of your date if you need to.
Functions approach
Get the difference of days, months or years between 2 dates
from date_assistant import (
get_days_diff_between,
get_months_diff_between,
get_years_diff_between,
)
from date_assistant.formats import DD_MM_YYYY, YYYY_MM
get_days_diff_between('2021-01-01', '2021-01-11')
# 10
get_days_diff_between('2021-01-01', '21-01-2021', date2_format=DD_MM_YYYY)
# 20
get_months_diff_between('2021-01-01', '2022-01-11')
# 12
get_months_diff_between('2021-01-05', '2021-02-01')
# 0
get_months_diff_between('2021-01', '2021-02-21', date1_format=YYYY_MM)
# 1
get_years_diff_between('2021-01-01', '2022-01-11')
# 1
get_years_diff_between('2021-01-05', '2022-01-01')
# 0
get_years_diff_between('2021-01', '2023-01-01', date1_format=YYYY_MM)
# 2
💡 See how months and years are only counted if a full year or month has passed.
Get the amount of years or months started between 2 dates
from date_assistant import (
get_months_started_between,
get_years_started_between,
)
from date_assistant.formats import YYYY_MM
get_months_started_between('2021-01-05', '2021-02-01')
# 1
get_months_started_between('2021-01-01', '2022-01-11')
# 12
get_months_started_between('2021-01', '2021-02-21', date1_format=YYYY_MM)
# 1
get_years_started_between('2021-01-01', '2020-12-31')
# 1
get_years_started_between('2021-01-05', '2022-01-01')
# 1
get_years_started_between('2021-01', '2023-01-01', date1_format=YYYY_MM)
# 2
💡 In contrast with the previous block example, here you don't need a full year or month between dates to count. If a new year or month started, it count.
Classes approach
Get the difference of days, months or years between 2 dates
from date_assistant import DateAssistant
my_birthday_2021 = DateAssistant('2021-07-13')
date_assistant_birthday = '2021-08-18'
my_birthday_2021.days_diff_with(date_assistant_birthday)
# 36
my_birthday_2021.months_diff_with(date_assistant_birthday)
# 1
my_birthday_2021.years_diff_with(date_assistant_birthday)
# 0
Get the amount of years or months started since or until some date
from date_assistant import DateAssistant
last_day_of_2021 = DateAssistant('2021-12-31')
first_day_of_2022 = '2022-01-01'
first_day_of_2023 = '2023-01-01'
date_assistant_birthday = '2021-08-18'
last_day_of_2021.years_started_until(first_day_of_2022)
# 1
last_day_of_2021.years_started_until(first_day_of_2023)
# 2
last_day_of_2021.months_started_until(first_day_of_2022)
# 1
last_day_of_2021.months_started_since(date_assistant_birthday)
# 4
Metadata
Release files for date-assistant 0.11.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| date_assistant-0.11.2.tar.gz | 4.7 kB | Without provenance | Details for date_assistant-0.11.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| date_assistant-0.11.2-py3-none-any.whl | Python 3 | none | any | Details for date_assistant-0.11.2-py3-none-any.whl |
Total release size: 9.6 kB
Release files / date_assistant-0.11.2.tar.gz
| Download URL | date_assistant-0.11.2.tar.gz |
|---|---|
| Size | 4.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6133ce037ce50ff22bc61a91c042569836c9d1a55da57f3be0419fe228aec032
|
|
BLAKE2b-256 checksum How to use checksums |
07cdf50a70a9075d3d9d9cb1e51387126190c81f551d0b20a1e300b09e461595
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.8 CPython/3.8.0 Darwin/20.5.0
|
Release files / date_assistant-0.11.2-py3-none-any.whl
| Download URL | date_assistant-0.11.2-py3-none-any.whl |
|---|---|
| Size | 4.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5c9104406198124928b270180fedd60412d1b60a0078e4275d90cebb2abd9c24
|
|
BLAKE2b-256 checksum How to use checksums |
7e4e374e5317607e09a2ad2a1af013bc04a86af0b7be3e9a33b7fa00816fce84
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.8 CPython/3.8.0 Darwin/20.5.0
|
Security for date-assistant 0.11.2
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.