April 16, 2016

Little League Schedules made easy with CLJS

This is the 3rd year that my two sons are playing Little League Baseball. This year, I wrote a small cljs widget to help consolidate all the practice and game schedules into a single list.

The Problem

Every year, each coach has a different way of sending out the baseball schedule. Some send a list of dates and locations in an email. Some create excel spreadsheets. Sometimes coaches will use online calendars services like Shutterfly.

The coaches don't get the entire schedule all at once. They'll usually send out the practice schedule early in the season, and then the game schedule a month or so afterwards.

So, I end up receiving about 4 or 5 different lists of practice and game schedules throughout the season.

As I receive the schedules, I'll enter them all into my Google Calendar. But after that, I need to send the schedules on to my wife and also to the kids' grandparents so they can come and watch the games.

Of course, I could just forward the schedules I receive from the coaches (like probably every normal person does). But not me! The "lazy-software-developer" gene in me got me thinking: How might I save my wife and family some time so that they don't have to manually consolidate all this stuff?

What I really wanted was a way to take the information I entered into Google Calendar and produce a list of dates and locations to send to my Wife and Family.

The Solution

This felt like a great excuse for a playing around with clojurescript! So here's what I came up with:

Like I mentioned, I first enter the dates and locations for each practice and game into my Google Calendar. I could probably automate this step well. But since the data comes in all different formats, this would take some time. I settled for manual data entry for this (for now at least).

Now that I have the data inside my calendar, I took advantage of the standard iCalendar format. Almost every calendar (including Google Calendars) support exporting data into ".ics" files.

All I needed now was a program to parse data out of an iCalendar file into a csv.

I did a quick google search and it turns out that Mozilla has a great library called ical.js that can parse iCalendar (rfc5545) format.

So, I created an externs file (and also contributed the externs to the cljsjs project in case anyone might want to use it from clojurescript).

And thanks to the amazing clojurescript environment and reagent library, I easily and quickly created a widget to convert ".ics" to csv.

This tool accepts ics files, parses the contents and displays the results and also provides a link to download a csv. All from your browser! If you have a ".ics" handy, feel free to try it out below. Hope someone else finds it useful someday.

Tags: clojure clojurescript