
Security News
Open Source CAI Framework Handles Pen Testing Tasks up to 3,600× Faster Than Humans
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.
A DateRange
type and related utility functions.
Install from pip:
pip install date-ranges
Import and create an instance:
from datetime import date
from date_ranges import DateRange
my_date_range = DateRange(start=date(2023, 5, 10), end=date(2023, 11, 3))
from datetime import date
from date_ranges import DateRange, MAX_DATE
# end date defaults to MAX_DATE
dr = DateRange(date(2023, 11, 1))
date(2023, 11, 22) in dr
# True
# An empty date (0 days in range):
empty = DateRange.empty()
bool(empty)
# False
# Iteration
for d in DateRange(date(2023, 1, 1), date(2023, 1, 3)):
print(d)
# 2023-01-01
# 2023-01-02
# 2023-01-03
# Create from strings
dr = DateRange.from_string('20230101-20230103')
repr(dr)
# 'DateRange(start=datetime.date(2023, 1, 1), end=datetime.date(2023, 1, 3))'
# Create range for a single date
dr = DateRange.from_string('20231031')
repr(dr)
# 'DateRange(start=datetime.date(2023, 10, 31), end=datetime.date(2023, 10, 31))'
# Create range for given year-month
dr = DateRange.from_string('202305')
repr(dr)
# 'DateRange(start=datetime.date(2023, 5, 1), end=datetime.date(2023, 5, 31))'
# Create range for multiple full months
dr = DateRange.from_string('202305-202311')
repr(dr)
# 'DateRange(start=datetime.date(2023, 5, 1), end=datetime.date(2023, 11, 30))'
# Formatted print
dr = DateRange(date(2023, 1, 1), date(2023, 1, 3))
dr
# 20230101-20230103
print(f'{dr:H}') # H for human
# 2023-01-01 to 2023-01-03
# Full months rendered appropriately
dr = DateRange.from_string('202305')
f'{dr:H}' # H for "human-readable"
# 'May 2023'
f'{dr:C}' # C for compact
# '202305'
dr
# '202305'
For those developing or maintaining the date-ranges
package itself,
be sure to install it with the [dev]
option to pull in packages
used when developing.
pip install --editable .[dev]
When developing, this package uses pre-commit
. After the initial
clone of the repository, you will need to set up pre-commit with:
# in the top level of the checked-out repository:
pre-commit install
FAQs
A DateRange type and related utility functions
We found that date-ranges 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
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.
Security News
Deno 2.4 brings back bundling, improves dependency updates and telemetry, and makes the runtime more practical for real-world JavaScript projects.
Security News
CVEForecast.org uses machine learning to project a record-breaking surge in vulnerability disclosures in 2025.