commit 22aa77c8c4c90c927ce9cacbab7a83fb8337a6eb Author: klein panic Date: Sun Sep 29 01:17:59 2024 -0400 initial commit diff --git a/create_class_calendar.sh b/create_class_calendar.sh new file mode 100755 index 0000000..527e17e --- /dev/null +++ b/create_class_calendar.sh @@ -0,0 +1,40 @@ +#!/usr/bin/env bash + +# Function to generate an ICS file for a class +generate_ics() { + local class_name="$1" + local start_time="$2" + local end_time="$3" + local days_per_week="$4" + local days_of_week="$5" + local end_date="$6" + + # ICS file header + echo "BEGIN:VCALENDAR" > "${class_name}.ics" + echo "VERSION:2.0" >> "${class_name}.ics" + echo "CALSCALE:GREGORIAN" >> "${class_name}.ics" + + # ICS event details + echo "BEGIN:VEVENT" >> "${class_name}.ics" + echo "SUMMARY:${class_name}" >> "${class_name}.ics" + echo "DTSTART;TZID=America/New_York:${start_time}" >> "${class_name}.ics" + echo "DTEND;TZID=America/New_York:${end_time}" >> "${class_name}.ics" + echo "RRULE:FREQ=WEEKLY;COUNT=${days_per_week};BYDAY=${days_of_week};UNTIL=${end_date}" >> "${class_name}.ics" + echo "END:VEVENT" >> "${class_name}.ics" + + # ICS file footer + echo "END:VCALENDAR" >> "${class_name}.ics" + + echo "ICS file for ${class_name} created successfully." +} + +# User input +read -p "Enter class name: " class_name +read -p "Enter start time (YYYYMMDDTHHMMSS format): " start_time +read -p "Enter end time (YYYYMMDDTHHMMSS format): " end_time +read -p "Enter how many days a week it occurs: " days_per_week +read -p "Enter the days of the week it occurs (e.g., MO,WE,FR): " days_of_week +read -p "Enter the end date (YYYYMMDD format): " end_date + +# Generate the ICS file +generate_ics "$class_name" "$start_time" "$end_time" "$days_per_week" "$days_of_week" "$end_date"