dateutils - Wrapper for Advanced Datetime Arithmetic

0.6.12 · maintenance · verified Sat Apr 11

The `dateutils` library provides various utilities for working with date and datetime objects. It acts as a lightweight wrapper over the more comprehensive `python-dateutil` library, offering specialized features like advanced arithmetic operations, date range generation, and business day calculations. The last release was version 0.6.12 in October 2020.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to use the `DateUtils` API to calculate the difference between two dates and generate a range of dates, showcasing common functionalities provided by this wrapper library.

from datetime import datetime, date
from dateutils.api import DateUtils

# Calculate the difference between two dates
date1 = date(2023, 1, 1)
date2 = date(2023, 1, 15)
diff_days = DateUtils.diff(date1, date2).days
print(f"Difference in days: {diff_days}")

# Generate a date range
start_date = date(2023, 3, 1)
end_date = date(2023, 3, 5)
dates_in_range = list(DateUtils.range(start_date, end_date))
print(f"Dates in range: {dates_in_range}")

view raw JSON →