private bool HasTripToday(DayOfWeek dayOfWeek, Calendar cal)
        {
            if (cal == null) return false;

            return ((dayOfWeek == DayOfWeek.Monday && cal.monday) ||
                   (dayOfWeek == DayOfWeek.Tuesday && cal.tuesday) ||
                   (dayOfWeek == DayOfWeek.Wednesday && cal.wednesday) ||
                   (dayOfWeek == DayOfWeek.Thursday && cal.thursday) ||
                   (dayOfWeek == DayOfWeek.Friday && cal.friday) ||
                   (dayOfWeek == DayOfWeek.Saturday && cal.saturday) ||
                   (dayOfWeek == DayOfWeek.Sunday && cal.sunday));
        }
        private static void CacheCalendarTable(ref SQLiteDataReader reader, ref int processedRowCount, Stopwatch timeSoFar, ref string current_table_name,
            Action displayTableName, Action<int, Stopwatch> updateTimeUI,
            ref Dictionary<string, Calendar> calendars)
        {
            // Update the table name shown on the progress form
            if (displayTableName != null)
                displayTableName();
            
            // Loop through the calendar table and add the information to a dictionary keyed by service_id
            try
            {
                while (reader.Read())
                {
                    ++processedRowCount;
                    if (updateTimeUI != null)
                        updateTimeUI(processedRowCount, timeSoFar);

                    Calendar cal = new Calendar();
                    cal.monday = Convert.ToBoolean(reader["monday"]);
                    cal.tuesday = Convert.ToBoolean(reader["tuesday"]);
                    cal.wednesday = Convert.ToBoolean(reader["wednesday"]);
                    cal.thursday = Convert.ToBoolean(reader["thursday"]);
                    cal.friday = Convert.ToBoolean(reader["friday"]);
                    cal.saturday = Convert.ToBoolean(reader["saturday"]);
                    cal.sunday = Convert.ToBoolean(reader["sunday"]);

                    String start_date = reader["start_date"].ToString();
                    cal.start_date = DateTime.ParseExact(start_date,
                                                  "yyyyMMdd",
                                                  System.Globalization.CultureInfo.InvariantCulture,
                                                  System.Globalization.DateTimeStyles.None);
                    String end_date = reader["end_date"].ToString();
                    cal.end_date = DateTime.ParseExact(end_date,
                                                  "yyyyMMdd",
                                                  System.Globalization.CultureInfo.InvariantCulture,
                                                  System.Globalization.DateTimeStyles.None);

                    string service_id = reader["service_id"].ToString();

                    // Add the calendar item to the dictionary.
                    calendars[service_id] = cal;
                }
            }
            catch (Exception e)
            {
                throw new Exception("Error caching calendar table. Error: " + e.Message, e);
            }
        }