Skip to content

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
  • 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

  1. Install Python: Ensure Python 3.6+ is installed (uses built-in modules)

  2. Run the Calendar:

    python basiccalendarapp.py
    python basiccalendarapp.py
  3. 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

  1. Add Event - Create new calendar events
  2. View Today’s Events - See current day’s schedule
  3. View Upcoming Events - Preview future events
  4. View Monthly Calendar - ASCII calendar with event indicators
  5. View Events by Date - Specific date event listing
  6. Search Events - Find events by keywords
  7. View Events by Category - Filter by event categories
  8. Edit Event - Modify existing event details
  9. Delete Event - Remove events with confirmation
  10. View Statistics - Analytics dashboard
  11. Export Events - Save events to text files
  12. 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

  1. GUI Interface: Tkinter or PyQt graphical interface
  2. Recurring Events: Support for repeating events
  3. Reminders: Email or desktop notification system
  4. Shared Calendars: Multi-user calendar sharing
  5. Import/Export: ICS file format support
  6. Web Interface: Flask web application
  7. Database Storage: SQLite or PostgreSQL integration
  8. Mobile App: Cross-platform mobile application

πŸ“ˆ Usage Patterns

Typical Workflow

  1. Setup: Create categories for your lifestyle
  2. Planning: Add upcoming events and appointments
  3. Daily Use: Check today’s events and add new ones
  4. Review: Use monthly view to see patterns
  5. 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