# Calendar Link Generator
[](https://github.com/Nneji123/calendar-link/actions/workflows/tests.yml)
[](https://github.com/Nneji123/calendar-link/actions/workflows/docs.yml)
[](https://github.com/Nneji123/calendar-link/actions/workflows/codecov.yml)
[](https://github.com/Nneji123/calendar-link/actions/workflows/pypi.yml)
A Python package for generating calendar links and ICS files for various calendar services including Google Calendar, Apple Calendar, Yahoo Calendar, AOL Calendar, and Microsoft 365.
## Features
- Generate calendar links for multiple services:
- Google Calendar
- Apple Calendar
- Yahoo Calendar
- AOL Calendar
- Microsoft Outlook
- Microsoft 365
- Generate ICS (iCalendar) files
- Support for timezone handling
- Event validation and sanitization
- Comprehensive error handling
## Installation
```bash
pip install calendar-link
```
## Quick Start
```python
from datetime import datetime
from calendar_link import CalendarEvent, CalendarGenerator
# Create an event
event = CalendarEvent(
title="Team Meeting",
start_time=datetime(2024, 1, 15, 10, 0), # 10:00 AM
end_time=datetime(2024, 1, 15, 11, 0), # 11:00 AM
description="Weekly team sync meeting",
location="Conference Room A",
attendees=["john@example.com", "jane@example.com"]
)
# Generate calendar links
generator = CalendarGenerator()
# Generate Google Calendar link
google_link = generator.generate_link(event, "google")
print(f"Google Calendar: {google_link}")
# Generate ICS file content
ics_content = generator.generate_ics(event)
print(f"ICS Content:\n{ics_content}")
# Generate all links at once
all_links = generator.generate_all_links(event)
for service, link in all_links.items():
print(f"{service}: {link}")
```
## Usage Examples
### Creating Events from Dictionary
```python
from calendar_link import CalendarEvent
event_data = {
"title": "Birthday Party",
"start_time": "2024-02-15T18:00:00",
"end_time": "2024-02-15T22:00:00",
"description": "Come celebrate!",
"location": "My House",
"all_day": False
}
event = CalendarEvent.from_dict(event_data)
```
### Working with Timezones
```python
import pytz
from datetime import datetime
from calendar_link import CalendarEvent
# Create event with specific timezone
ny_tz = pytz.timezone("America/New_York")
start_time = ny_tz.localize(datetime(2024, 1, 15, 10, 0))
event = CalendarEvent(
title="Meeting",
start_time=start_time,
end_time=start_time.replace(hour=11),
timezone="America/New_York"
)
```
### All-Day Events
```python
from datetime import datetime
from calendar_link import CalendarEvent
event = CalendarEvent(
title="Vacation Day",
start_time=datetime(2024, 1, 15, 0, 0),
end_time=datetime(2024, 1, 15, 0, 0),
all_day=True
)
```
### Saving ICS File
```python
from calendar_link import CalendarEvent, CalendarGenerator
event = CalendarEvent(
title="Important Meeting",
start_time=datetime(2024, 1, 15, 14, 30),
end_time=datetime(2024, 1, 15, 15, 30),
description="Don't forget to prepare the presentation"
)
generator = CalendarGenerator()
ics_content = generator.generate_ics(event)
# Save to file
with open("meeting.ics", "w") as f:
f.write(ics_content)
```
## API Reference
### CalendarEvent
The main class for representing calendar events.
#### Constructor
```python
CalendarEvent(
title: str,
start_time: datetime,
end_time: Optional[datetime] = None,
description: Optional[str] = None,
location: Optional[str] = None,
attendees: Optional[List[str]] = None,
all_day: bool = False,
timezone: Optional[str] = None
)
```
#### Methods
- `from_dict(data: dict) -> CalendarEvent`: Create event from dictionary
- `to_dict() -> dict`: Convert event to dictionary
- `get_duration_minutes() -> int`: Get event duration in minutes
- `is_same_day() -> bool`: Check if start and end are on same day
### CalendarGenerator
The main class for generating calendar links and ICS files.
#### Methods
- `generate_link(event: CalendarEvent, service: str) -> str`: Generate link for specific service
- `generate_ics(event: CalendarEvent) -> str`: Generate ICS file content
- `generate_all_links(event: CalendarEvent) -> Dict[str, str]`: Generate all links
- `get_supported_services() -> Dict[str, str]`: Get list of supported services
#### Supported Services
- `google`: Google Calendar
- `apple`: Apple Calendar
- `yahoo`: Yahoo Calendar
- `aol`: AOL Calendar
- `outlook`: Microsoft Outlook
- `office365`: Microsoft 365
- `ics`: ICS File
## Error Handling
The package includes custom exceptions for better error handling:
```python
from calendar_link import CalendarLinkError, InvalidEventDataError, UnsupportedCalendarServiceError
try:
event = CalendarEvent(title="", start_time=datetime.now()) # Invalid title
except InvalidEventDataError as e:
print(f"Invalid event data: {e}")
try:
generator.generate_link(event, "unsupported_service")
except UnsupportedCalendarServiceError as e:
print(f"Unsupported service: {e}")
```
## Utility Functions
The package also includes utility functions for common operations:
```python
from calendar_link.utils import parse_datetime, validate_email, sanitize_text
# Parse datetime with timezone
dt = parse_datetime("2024-01-15 10:00:00", "America/New_York")
# Validate email
is_valid = validate_email("user@example.com")
# Sanitize text for calendar services
clean_text = sanitize_text("Event\nDescription\nwith\nnewlines")
```
## Contributing
1. Fork the repository
2. Create a feature branch
3. Make your changes
4. Add tests if applicable
5. Submit a pull request
## License
This project is licensed under the MIT License - see the LICENSE file for details.
## Acknowledgments
- [ical](https://github.com/allenporter/ical) - Python iCalendar implementation
- [python-dateutil](https://dateutil.readthedocs.io/) - Date utilities
- [pytz](https://pythonhosted.org/pytz/) - Timezone handling
Raw data
{
"_id": null,
"home_page": null,
"name": "calendar-link",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.12",
"maintainer_email": null,
"keywords": "apple-calendar, calendar, google-calendar, ics, outlook, yahoo",
"author": null,
"author_email": "Ifeanyi Nneji <ifeanyinneji777@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/29/d3/4718f1cbffefc4614026eea55d004ed259678d660ced3fef44c618fbeb02/calendar_link-0.1.3.tar.gz",
"platform": null,
"description": "# Calendar Link Generator\n\n[](https://github.com/Nneji123/calendar-link/actions/workflows/tests.yml)\n[](https://github.com/Nneji123/calendar-link/actions/workflows/docs.yml)\n[](https://github.com/Nneji123/calendar-link/actions/workflows/codecov.yml)\n[](https://github.com/Nneji123/calendar-link/actions/workflows/pypi.yml)\n\nA Python package for generating calendar links and ICS files for various calendar services including Google Calendar, Apple Calendar, Yahoo Calendar, AOL Calendar, and Microsoft 365.\n\n## Features\n\n- Generate calendar links for multiple services:\n - Google Calendar\n - Apple Calendar\n - Yahoo Calendar\n - AOL Calendar\n - Microsoft Outlook\n - Microsoft 365\n- Generate ICS (iCalendar) files\n- Support for timezone handling\n- Event validation and sanitization\n- Comprehensive error handling\n\n## Installation\n\n```bash\npip install calendar-link\n```\n\n## Quick Start\n\n```python\nfrom datetime import datetime\nfrom calendar_link import CalendarEvent, CalendarGenerator\n\n# Create an event\nevent = CalendarEvent(\n title=\"Team Meeting\",\n start_time=datetime(2024, 1, 15, 10, 0), # 10:00 AM\n end_time=datetime(2024, 1, 15, 11, 0), # 11:00 AM\n description=\"Weekly team sync meeting\",\n location=\"Conference Room A\",\n attendees=[\"john@example.com\", \"jane@example.com\"]\n)\n\n# Generate calendar links\ngenerator = CalendarGenerator()\n\n# Generate Google Calendar link\ngoogle_link = generator.generate_link(event, \"google\")\nprint(f\"Google Calendar: {google_link}\")\n\n# Generate ICS file content\nics_content = generator.generate_ics(event)\nprint(f\"ICS Content:\\n{ics_content}\")\n\n# Generate all links at once\nall_links = generator.generate_all_links(event)\nfor service, link in all_links.items():\n print(f\"{service}: {link}\")\n```\n\n## Usage Examples\n\n### Creating Events from Dictionary\n\n```python\nfrom calendar_link import CalendarEvent\n\nevent_data = {\n \"title\": \"Birthday Party\",\n \"start_time\": \"2024-02-15T18:00:00\",\n \"end_time\": \"2024-02-15T22:00:00\",\n \"description\": \"Come celebrate!\",\n \"location\": \"My House\",\n \"all_day\": False\n}\n\nevent = CalendarEvent.from_dict(event_data)\n```\n\n### Working with Timezones\n\n```python\nimport pytz\nfrom datetime import datetime\nfrom calendar_link import CalendarEvent\n\n# Create event with specific timezone\nny_tz = pytz.timezone(\"America/New_York\")\nstart_time = ny_tz.localize(datetime(2024, 1, 15, 10, 0))\n\nevent = CalendarEvent(\n title=\"Meeting\",\n start_time=start_time,\n end_time=start_time.replace(hour=11),\n timezone=\"America/New_York\"\n)\n```\n\n### All-Day Events\n\n```python\nfrom datetime import datetime\nfrom calendar_link import CalendarEvent\n\nevent = CalendarEvent(\n title=\"Vacation Day\",\n start_time=datetime(2024, 1, 15, 0, 0),\n end_time=datetime(2024, 1, 15, 0, 0),\n all_day=True\n)\n```\n\n### Saving ICS File\n\n```python\nfrom calendar_link import CalendarEvent, CalendarGenerator\n\nevent = CalendarEvent(\n title=\"Important Meeting\",\n start_time=datetime(2024, 1, 15, 14, 30),\n end_time=datetime(2024, 1, 15, 15, 30),\n description=\"Don't forget to prepare the presentation\"\n)\n\ngenerator = CalendarGenerator()\nics_content = generator.generate_ics(event)\n\n# Save to file\nwith open(\"meeting.ics\", \"w\") as f:\n f.write(ics_content)\n```\n\n## API Reference\n\n### CalendarEvent\n\nThe main class for representing calendar events.\n\n#### Constructor\n\n```python\nCalendarEvent(\n title: str,\n start_time: datetime,\n end_time: Optional[datetime] = None,\n description: Optional[str] = None,\n location: Optional[str] = None,\n attendees: Optional[List[str]] = None,\n all_day: bool = False,\n timezone: Optional[str] = None\n)\n```\n\n#### Methods\n\n- `from_dict(data: dict) -> CalendarEvent`: Create event from dictionary\n- `to_dict() -> dict`: Convert event to dictionary\n- `get_duration_minutes() -> int`: Get event duration in minutes\n- `is_same_day() -> bool`: Check if start and end are on same day\n\n### CalendarGenerator\n\nThe main class for generating calendar links and ICS files.\n\n#### Methods\n\n- `generate_link(event: CalendarEvent, service: str) -> str`: Generate link for specific service\n- `generate_ics(event: CalendarEvent) -> str`: Generate ICS file content\n- `generate_all_links(event: CalendarEvent) -> Dict[str, str]`: Generate all links\n- `get_supported_services() -> Dict[str, str]`: Get list of supported services\n\n#### Supported Services\n\n- `google`: Google Calendar\n- `apple`: Apple Calendar\n- `yahoo`: Yahoo Calendar\n- `aol`: AOL Calendar\n- `outlook`: Microsoft Outlook\n- `office365`: Microsoft 365\n- `ics`: ICS File\n\n## Error Handling\n\nThe package includes custom exceptions for better error handling:\n\n```python\nfrom calendar_link import CalendarLinkError, InvalidEventDataError, UnsupportedCalendarServiceError\n\ntry:\n event = CalendarEvent(title=\"\", start_time=datetime.now()) # Invalid title\nexcept InvalidEventDataError as e:\n print(f\"Invalid event data: {e}\")\n\ntry:\n generator.generate_link(event, \"unsupported_service\")\nexcept UnsupportedCalendarServiceError as e:\n print(f\"Unsupported service: {e}\")\n```\n\n## Utility Functions\n\nThe package also includes utility functions for common operations:\n\n```python\nfrom calendar_link.utils import parse_datetime, validate_email, sanitize_text\n\n# Parse datetime with timezone\ndt = parse_datetime(\"2024-01-15 10:00:00\", \"America/New_York\")\n\n# Validate email\nis_valid = validate_email(\"user@example.com\")\n\n# Sanitize text for calendar services\nclean_text = sanitize_text(\"Event\\nDescription\\nwith\\nnewlines\")\n```\n\n## Contributing\n\n1. Fork the repository\n2. Create a feature branch\n3. Make your changes\n4. Add tests if applicable\n5. Submit a pull request\n\n## License\n\nThis project is licensed under the MIT License - see the LICENSE file for details.\n\n## Acknowledgments\n\n- [ical](https://github.com/allenporter/ical) - Python iCalendar implementation\n- [python-dateutil](https://dateutil.readthedocs.io/) - Date utilities\n- [pytz](https://pythonhosted.org/pytz/) - Timezone handling",
"bugtrack_url": null,
"license": "MIT",
"summary": "Generate calendar links and ICS files for Google, Apple, Yahoo, AOL, Microsoft 365, and more",
"version": "0.1.3",
"project_urls": {
"Homepage": "https://github.com/nneji123/calendar-link",
"Issues": "https://github.com/nneji123/calendar-link/issues",
"Repository": "https://github.com/nneji123/calendar-link"
},
"split_keywords": [
"apple-calendar",
" calendar",
" google-calendar",
" ics",
" outlook",
" yahoo"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "95d45f0b2c898beb46e597f5119bbfb54e18e4e392c85a2043968d36e831d207",
"md5": "81f2314074cf512034deccf42c381ea2",
"sha256": "81f8ca11585940c7cf65c34c5ce49dfa4c9f6ffedd4783d1077d7dfb904a95df"
},
"downloads": -1,
"filename": "calendar_link-0.1.3-py3-none-any.whl",
"has_sig": false,
"md5_digest": "81f2314074cf512034deccf42c381ea2",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.12",
"size": 10883,
"upload_time": "2025-08-06T11:27:56",
"upload_time_iso_8601": "2025-08-06T11:27:56.251360Z",
"url": "https://files.pythonhosted.org/packages/95/d4/5f0b2c898beb46e597f5119bbfb54e18e4e392c85a2043968d36e831d207/calendar_link-0.1.3-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "29d34718f1cbffefc4614026eea55d004ed259678d660ced3fef44c618fbeb02",
"md5": "8948c09bb8afd2ab8171a23be4d9a898",
"sha256": "a42d79428b79e8db317e515a089941084fa33d71df54c97f38ed64a0650b582b"
},
"downloads": -1,
"filename": "calendar_link-0.1.3.tar.gz",
"has_sig": false,
"md5_digest": "8948c09bb8afd2ab8171a23be4d9a898",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.12",
"size": 77296,
"upload_time": "2025-08-06T11:27:57",
"upload_time_iso_8601": "2025-08-06T11:27:57.373955Z",
"url": "https://files.pythonhosted.org/packages/29/d3/4718f1cbffefc4614026eea55d004ed259678d660ced3fef44c618fbeb02/calendar_link-0.1.3.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-08-06 11:27:57",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "nneji123",
"github_project": "calendar-link",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "calendar-link"
}