Skip to main content

Lightweight utilities for working with dates and time in Python.

Project description

⏳ Timecraftx

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.


🔧 Features

  • start_of_week() and end_of_week() with customizable week start (Sunday or Monday)
  • yesterday() and tomorrow() with optional reference date
  • next_weekday() and prev_weekday() with helpers like next_monday(), prev_sunday(), etc.
  • ✅ Works with date objects directly (no timezone mess)
  • ✅ Enum-based safety for weekdays via Day
  • ✅ Fully tested, no external dependencies

📦 Installation

pip install timecraftx

🚀 Quickstart

from 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-02

📘 API Reference

Week Utilities

start_of_week(from_date: Optional[date] = None, week_start: Day = Day.MONDAY) -> date

Returns the first day of the week. Defaults to today and Monday.

end_of_week(from_date: Optional[date] = None, week_start: Day = Day.MONDAY) -> date

Returns the last day of the week (6 days after start_of_week).


Relative Days

yesterday(from_date: Optional[date] = None) -> date

Returns the day before the given date.

tomorrow(from_date: Optional[date] = None) -> date

Returns the day after the given date.


Next Weekday Utilities

next_weekday(from_date: Optional[date] = None, target: Day = Day.MONDAY) -> date

Returns the next occurrence of a specific weekday.

Day-specific helpers:

  • next_monday()
  • next_tuesday()
  • next_wednesday()
  • next_thursday()
  • next_friday()
  • next_saturday()
  • next_sunday()

Previous Weekday Utilities

prev_weekday(from_date: Optional[date] = None, target: Day = Day.MONDAY) -> date

Returns the most recent past occurrence of a specific weekday.

Day-specific helpers:

  • prev_monday()
  • prev_tuesday()
  • prev_wednesday()
  • prev_thursday()
  • prev_friday()
  • prev_saturday()
  • prev_sunday()

Enum

Day

Enum values for each day of the week, from Day.MONDAY to Day.SUNDAY.


🛡️ License

MIT License. See LICENSE.


👤 Author

Jacobo Tapia
GitHub: @Jatapiaro
Project: https://github.com/Jatapiaro/timecraftx


🌟 Contribute

Found a bug or have an idea? PRs welcome. Open an issue or submit a patch.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

timecraftx-1.0.1.tar.gz (10.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

timecraftx-1.0.1-py3-none-any.whl (6.5 kB view details)

Uploaded Python 3

File details

Details for the file timecraftx-1.0.1.tar.gz.

File metadata

  • Download URL: timecraftx-1.0.1.tar.gz
  • Upload date:
  • Size: 10.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.32.3

File hashes

Hashes for timecraftx-1.0.1.tar.gz
Algorithm Hash digest
SHA256 e6494b5c6b14184bf0a0e19165faf24b54d55368ea738d83cd6af7f7870842b1
MD5 3dc9dc78ddcd99e181604d7950faef07
BLAKE2b-256 48072bdf829d5df089e9d247e661f7dc3258ab8f4672298a31d42e8bd25ec647

See more details on using hashes here.

File details

Details for the file timecraftx-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: timecraftx-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 6.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.32.3

File hashes

Hashes for timecraftx-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d17f8d7ef47afa028e9435da2796491abe48f303f42c784e774713c98e69605d
MD5 790c18b3e7cd32d6c78c18ec1e18e165
BLAKE2b-256 dc891625d2125eb5362be264b9f61c1a7ad5ad8247afeb526fd05ea0267bcb02

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page