Security News
Input Validation Vulnerabilities Dominate MITRE's 2024 CWE Top 25 List
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
For more details take a look at the docs
date-assistant is published on PyPI and can be installed from there:
pip install date-assistant
💡 Please consider that the default date format is '%Y-%m-%d'. Anyways, you can indicate the format of your date if you need to.
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.
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.
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
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
FAQs
🗓 Classes and functions with intuitive names for common dates operations
We found that date-assistant demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.