A tiny DSL for calendar interval algebra - compose, filter, and query time ranges using set operations.
Project description
calgebra 🗓️
A tiny DSL for merging and searching over calendar-like intervals.
Installation
pip install calgebra
# Or with Google Calendar support
pip install calgebra[google-calendar]
Quick Start
from calgebra import day_of_week, time_of_day, hours, at_tz, HOUR
# Compose time windows
weekdays = day_of_week(["monday", "tuesday", "wednesday", "thursday", "friday"])
work_hours = time_of_day(start=9*HOUR, duration=8*HOUR, tz="US/Pacific")
business_hours = weekdays & work_hours
# Find free time
busy = monday_meetings | friday_focus
free = business_hours - busy
long_slots = free & (hours >= 2)
# Query results
at = at_tz("US/Pacific")
meeting_options = list(long_slots[at("2025-01-01"):at("2025-02-01")])
Intervals use exclusive end bounds ([start, end)), matching Python slicing. Interval(start=10, end=13) represents 3 seconds. Intervals are automatically clipped to query bounds.
Core Features:
- Set operations:
|(union),&(intersection),-(difference),~(complement) - Recurring patterns:
recurring(),day_of_week(),time_of_day()(RFC 5545 viapython-dateutil) - Aggregations:
total_duration,max_duration,min_duration,count_intervals,coverage_ratio - Transformations:
buffer()(add time around intervals),merge_within()(coalesce nearby intervals) - Google Calendar:
calgebra.gcsa.calendars()for read/write operations
→ Tutorial | API Reference | Google Calendar Guide
License
MIT License - see LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file calgebra-0.6.0.tar.gz.
File metadata
- Download URL: calgebra-0.6.0.tar.gz
- Upload date:
- Size: 64.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
eecd98d5e236ce868f17283608424ae73e82bcc8145673c69a69e5cbec92abb8
|
|
| MD5 |
0ec66aaee860e22217509de7673d6aa5
|
|
| BLAKE2b-256 |
477db7aae8b0f743997cee4cf81771888528d2d0a418283a33ece87ea0cd1849
|
File details
Details for the file calgebra-0.6.0-py3-none-any.whl.
File metadata
- Download URL: calgebra-0.6.0-py3-none-any.whl
- Upload date:
- Size: 56.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e6a3c3b05d982fbfbeaae028b3cf070aaed7a9398bef0417fcf86900e02d489f
|
|
| MD5 |
4ee6b1c5e736976f2ff412d3cead5821
|
|
| BLAKE2b-256 |
257e0a1b380b50dd3a80f144e663ff03dd43749e813fd5b19bdce5168c212db8
|