Basic Calendar App
Abstract
A comprehensive command-line calendar application that provides complete event management functionality including scheduling, categorization, search, and export capabilities. This project demonstrates advanced data structures, date/time handling, and file persistence techniques.
π― Project Overview
This project creates a full-featured calendar application with:
- Event creation and management system
- Calendar view with visual event indicators
- Category-based organization
- Search and filtering capabilities
- Statistics and analytics
- Data export functionality
- Persistent storage using JSON
β¨ Features
Event Management
- Create Events: Add events with title, date, time, description, and category
- Edit Events: Update existing event details
- Delete Events: Remove events with confirmation
- Event Categories: Organize events by custom categories
Calendar Views
- Monthly Calendar: Visual calendar with event indicators
- Daily View: Detailed view of events for specific dates
- Todayβs Events: Quick view of current dayβs schedule
- Upcoming Events: Configurable future event preview
Organization & Search
- Category System: Built-in and custom categories for organization
- Event Search: Search by title, description, or category
- Date Filtering: View events by specific date ranges
- Sorting: Automatic chronological sorting of events
Analytics & Export
- Statistics Dashboard: Event counts, category distribution, and trends
- Data Export: Export events to text files with date filtering
- Monthly Distribution: Track event patterns over time
- Category Analytics: Monitor category usage
π οΈ Technical Implementation
Class Structure
basiccalendarapp.py
class Event:
def __init__(self, event_id, title, date, time="", description="", category="General"):
# Event data model with validation
# Automatic ID generation and timestamps
def get_datetime(self):
# Convert string date/time to datetime object
def is_upcoming(self, days=7):
# Check if event is within specified timeframe
class BasicCalendarApp:
def __init__(self, data_file="calendar_data.json"):
# Initialize calendar with data persistence
# Load existing events and categories
def add_event(self, title, date_str, time_str, description, category):
# Create and store new event with validation
def get_calendar_view(self, year, month):
# Generate ASCII calendar with event indicators
basiccalendarapp.py
class Event:
def __init__(self, event_id, title, date, time="", description="", category="General"):
# Event data model with validation
# Automatic ID generation and timestamps
def get_datetime(self):
# Convert string date/time to datetime object
def is_upcoming(self, days=7):
# Check if event is within specified timeframe
class BasicCalendarApp:
def __init__(self, data_file="calendar_data.json"):
# Initialize calendar with data persistence
# Load existing events and categories
def add_event(self, title, date_str, time_str, description, category):
# Create and store new event with validation
def get_calendar_view(self, year, month):
# Generate ASCII calendar with event indicators
Key Components
Data Models
- Event Class: Represents calendar events with metadata
- Unique IDs: Automatic generation of event identifiers (EVT001, EVT002, etc.)
- Datetime Handling: Robust date and time parsing and validation
- Category Management: Dynamic category creation and assignment
Calendar Display
- ASCII Calendar: Visual month view using Pythonβs calendar module
- Event Indicators: Asterisk markers for days with events
- Formatted Output: Clean, readable event listings
- Date Navigation: Easy month/year navigation
Data Persistence
- JSON Storage: Automatic saving and loading of all data
- Error Handling: Graceful handling of file operations
- Data Validation: Ensure data integrity on load/save
- Backup Safety: Protection against data corruption
π How to Run
-
Install Python: Ensure Python 3.6+ is installed (uses built-in modules)
-
Run the Calendar:
python basiccalendarapp.py
python basiccalendarapp.py
-
Getting Started:
- Add your first event
- Explore the monthly calendar view
- Try different categories and search features
- View statistics and export data
π‘ Usage Examples
Creating Events
basiccalendarapp.py
# Create calendar app instance
calendar_app = BasicCalendarApp()
# Add a simple event
event = calendar_app.add_event(
title="Team Meeting",
date_str="2024-01-15",
time_str="14:30",
description="Weekly team sync",
category="Work"
)
print(f"Event created with ID: {event.id}")
basiccalendarapp.py
# Create calendar app instance
calendar_app = BasicCalendarApp()
# Add a simple event
event = calendar_app.add_event(
title="Team Meeting",
date_str="2024-01-15",
time_str="14:30",
description="Weekly team sync",
category="Work"
)
print(f"Event created with ID: {event.id}")
Viewing Calendar
basiccalendarapp.py
# Get monthly calendar view
calendar_view = calendar_app.get_calendar_view(2024, 1)
print(calendar_view)
# Get events for specific date
date_events = calendar_app.get_events_for_date("2024-01-15")
for event in date_events:
print(f"β’ {event}")
basiccalendarapp.py
# Get monthly calendar view
calendar_view = calendar_app.get_calendar_view(2024, 1)
print(calendar_view)
# Get events for specific date
date_events = calendar_app.get_events_for_date("2024-01-15")
for event in date_events:
print(f"β’ {event}")
Search and Filter
basiccalendarapp.py
# Search events
results = calendar_app.search_events("meeting")
# Get events by category
work_events = calendar_app.get_events_by_category("Work")
# Get upcoming events
upcoming = calendar_app.get_upcoming_events(7) # Next 7 days
basiccalendarapp.py
# Search events
results = calendar_app.search_events("meeting")
# Get events by category
work_events = calendar_app.get_events_by_category("Work")
# Get upcoming events
upcoming = calendar_app.get_upcoming_events(7) # Next 7 days
Analytics
basiccalendarapp.py
# Get comprehensive statistics
stats = calendar_app.get_event_statistics()
print(f"Total events: {stats['total_events']}")
print(f"Categories: {stats['categories']}")
basiccalendarapp.py
# Get comprehensive statistics
stats = calendar_app.get_event_statistics()
print(f"Total events: {stats['total_events']}")
print(f"Categories: {stats['categories']}")
π¨ Interactive Menu System
Main Menu Options
- Add Event - Create new calendar events
- View Todayβs Events - See current dayβs schedule
- View Upcoming Events - Preview future events
- View Monthly Calendar - ASCII calendar with event indicators
- View Events by Date - Specific date event listing
- Search Events - Find events by keywords
- View Events by Category - Filter by event categories
- Edit Event - Modify existing event details
- Delete Event - Remove events with confirmation
- View Statistics - Analytics dashboard
- Export Events - Save events to text files
- Manage Categories - Add custom categories
User Experience Features
- Input Validation: Robust date and time format checking
- Smart Defaults: Sensible default values for optional fields
- Confirmation Prompts: Safety checks for destructive operations
- Error Handling: Graceful error recovery and user feedback
π Calendar Features
Monthly Calendar View
January 2024
Mo Tu We Th Fr Sa Su
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15*16 17 18*19 20 21
22 23 24 25 26 27 28
29 30 31
* = Has events
January 2024
Mo Tu We Th Fr Sa Su
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15*16 17 18*19 20 21
22 23 24 25 26 27 28
29 30 31
* = Has events
Event Display Format
=== Today's Events ===
2024-01-15 (Monday)
-------------------------
[EVT001] Team Meeting at 14:30 (Work)
Weekly team sync
[EVT002] Dentist Appointment at 16:00 (Health)
=== Today's Events ===
2024-01-15 (Monday)
-------------------------
[EVT001] Team Meeting at 14:30 (Work)
Weekly team sync
[EVT002] Dentist Appointment at 16:00 (Health)
Category Organization
- Built-in Categories: General, Work, Personal, Health, Education
- Custom Categories: User-defined categories for specific needs
- Category Statistics: Track usage and distribution
- Category Filtering: View events by specific categories
π§ Advanced Features
Date Validation
basiccalendarapp.py
def get_date_input(prompt):
# Validate YYYY-MM-DD format
# Provide user-friendly error messages
# Allow empty input for optional fields
basiccalendarapp.py
def get_date_input(prompt):
# Validate YYYY-MM-DD format
# Provide user-friendly error messages
# Allow empty input for optional fields
Event Updates
basiccalendarapp.py
# Update any event field selectively
calendar_app.update_event(
event_id="EVT001",
title="Updated Meeting Title",
date_str="2024-01-16",
# Other fields remain unchanged
)
basiccalendarapp.py
# Update any event field selectively
calendar_app.update_event(
event_id="EVT001",
title="Updated Meeting Title",
date_str="2024-01-16",
# Other fields remain unchanged
)
Export Functionality
basiccalendarapp.py
# Export all events
calendar_app.export_events("all_events.txt")
# Export with date range
calendar_app.export_events(
"january_events.txt",
start_date="2024-01-01",
end_date="2024-01-31"
)
basiccalendarapp.py
# Export all events
calendar_app.export_events("all_events.txt")
# Export with date range
calendar_app.export_events(
"january_events.txt",
start_date="2024-01-01",
end_date="2024-01-31"
)
π Data Structure
Event Format
{
"id": "EVT001",
"title": "Team Meeting",
"date": "2024-01-15",
"time": "14:30",
"description": "Weekly team sync",
"category": "Work",
"created_at": "2024-01-01T10:00:00.000000"
}
{
"id": "EVT001",
"title": "Team Meeting",
"date": "2024-01-15",
"time": "14:30",
"description": "Weekly team sync",
"category": "Work",
"created_at": "2024-01-01T10:00:00.000000"
}
Statistics Output
basiccalendarapp.py
{
'total_events': 25,
'today_events': 3,
'upcoming_events': 8,
'categories': {
'Work': 12,
'Personal': 8,
'Health': 3,
'Education': 2
},
'monthly_distribution': {
'2024-01': 15,
'2024-02': 10
},
'total_categories': 4
}
basiccalendarapp.py
{
'total_events': 25,
'today_events': 3,
'upcoming_events': 8,
'categories': {
'Work': 12,
'Personal': 8,
'Health': 3,
'Education': 2
},
'monthly_distribution': {
'2024-01': 15,
'2024-02': 10
},
'total_categories': 4
}
π‘οΈ Error Handling
- Date Validation: Comprehensive date and time format checking
- File Operations: Graceful handling of JSON file errors
- User Input: Input validation with helpful error messages
- Data Integrity: Protection against data corruption
π Learning Objectives
- Date/Time Handling: Working with Pythonβs datetime module
- Data Persistence: JSON file operations and data management
- User Interface Design: Command-line interface best practices
- Input Validation: Robust user input handling
- Data Organization: Categorization and search algorithms
π― Potential Enhancements
- GUI Interface: Tkinter or PyQt graphical interface
- Recurring Events: Support for repeating events
- Reminders: Email or desktop notification system
- Shared Calendars: Multi-user calendar sharing
- Import/Export: ICS file format support
- Web Interface: Flask web application
- Database Storage: SQLite or PostgreSQL integration
- Mobile App: Cross-platform mobile application
π Usage Patterns
Typical Workflow
- Setup: Create categories for your lifestyle
- Planning: Add upcoming events and appointments
- Daily Use: Check todayβs events and add new ones
- Review: Use monthly view to see patterns
- Analysis: Review statistics to understand scheduling trends
Best Practices
- Use descriptive event titles
- Leverage categories for better organization
- Include time for important appointments
- Add descriptions for complex events
- Regular exports for backup
π Project Completion
This Basic Calendar App demonstrates:
- β Complete event lifecycle management (CRUD operations)
- β Visual calendar presentation
- β Data persistence and integrity
- β Search and filtering capabilities
- β Analytics and statistics
- β Export and backup functionality
Perfect for beginners learning data management and intermediate developers exploring calendar application development!
Was this page helpful?
Let us know how we did