Lightweight, readable, and powerful date utilities for Python.
Get common date calculations like start_of_week, end_of_week, yesterday, tomorrow, or even next_friday and prev_monday β with beautiful, clean code.
- β
start_of_week()andend_of_week()with customizable week start (Sunday or Monday) - β
yesterday()andtomorrow()with optional reference date - β
next_weekday()andprev_weekday()with helpers likenext_monday(),prev_sunday(), etc. - β
Works with
dateobjects directly (no timezone mess) - β
Enum-based safety for weekdays via
Day - β Fully tested, no external dependencies
pip install timecraftxfrom datetime import date
from timecraftx import (
start_of_week, end_of_week, yesterday, tomorrow,
next_friday, prev_monday, Day
)
today = date(2025, 6, 4)
print(start_of_week(today)) # 2025-06-02 (Monday)
print(end_of_week(today)) # 2025-06-08 (Sunday if Monday is week start)
print(yesterday(today)) # 2025-06-03
print(tomorrow(today)) # 2025-06-05
print(next_friday(today)) # 2025-06-06
print(prev_monday(today)) # 2025-06-02Returns the first day of the week. Defaults to today and Monday.
Returns the last day of the week (6 days after start_of_week).
Returns the day before the given date.
Returns the day after the given date.
Returns the next occurrence of a specific weekday.
next_monday()next_tuesday()next_wednesday()next_thursday()next_friday()next_saturday()next_sunday()
Returns the most recent past occurrence of a specific weekday.
prev_monday()prev_tuesday()prev_wednesday()prev_thursday()prev_friday()prev_saturday()prev_sunday()
Enum values for each day of the week, from Day.MONDAY to Day.SUNDAY.
MIT License. See LICENSE.
Jacobo Tapia
GitHub: @Jatapiaro
Project: https://github.com/Jatapiaro/timecraftx
Found a bug or have an idea? PRs welcome. Open an issue or submit a patch.