<commit_before>//
//  NewEventDataSource.swift
//  Carleton Reunion
//
//  Created by <NAME> on 5/23/15.
//  Copyright (c) 2015 BTIN. All rights reserved.
//
//  Data source for EventListViewController. Works in concert with ICSParser to parse schedule.ics for events
//

import Foundation

@objc class NewEventDataSource: NSObject {
    
    var fullEventList : NSMutableArray
    var myTableViewController : EventListViewController?
    
    override init() {
        self.fullEventList = NSMutableArray()
        super.init()
        let parser = ICSParser(eventDataSource: self)
    
    }
    
    func populateEventList(eventList: NSMutableArray?) {
        self.fullEventList = eventList!
        

    }
    
    
    // Used by EventListViewController
    func attachVCBackref(tableViewController: EventListViewController) {
            myTableViewController = tableViewController
            self.myTableViewController!.setVCArrayToDataSourceArray(self.fullEventList as [AnyObject])
        }
    
    func getEventsForDate(currentDate: NSDate) {
        var currentDateComps: NSDateComponents = NSWEvent.getDateComponentsFromDate(currentDate)
        var predicateFormat: NSString = "startDateComponents.day = \(currentDateComps.day) && startDateComponents.month == \(currentDateComps.month) && startDateComponents.year == \(currentDateComps.year)"
        var dateMatchesCurrent: NSComparisonPredicate = NSComparisonPredicate(format: predicateFormat as String)
        var todaysEvents: NSArray = self.fullEventList.filteredArrayUsingPredicate(dateMatchesCurrent)
        
        self.myTableViewController?.setVCArrayToDataSourceArray(todaysEvents as [AnyObject])
        
        
    }
    
    
    }
<commit_msg>Events now sorted by time<commit_after>//
//  NewEventDataSource.swift
//  Carleton Reunion
//
//  Created by <NAME> on 5/23/15.
//  Copyright (c) 2015 BTIN. All rights reserved.
//
//  Data source for EventListViewController. Works in concert with ICSParser to parse schedule.ics for events
//

import Foundation

@objc class NewEventDataSource: NSObject {
    
    var fullEventList : NSMutableArray
    var myTableViewController : EventListViewController?
    
    override init() {
        self.fullEventList = NSMutableArray()
        super.init()
        let parser = ICSParser(eventDataSource: self)
    
    }
    
    func populateEventList(eventList: NSMutableArray?) {
        self.fullEventList = eventList!
        

    }
    
    
    // Used by EventListViewController
    func attachVCBackref(tableViewController: EventListViewController) {
            myTableViewController = tableViewController
            self.myTableViewController!.setVCArrayToDataSourceArray(self.fullEventList as [AnyObject])
        }
    
    func getEventsForDate(currentDate: NSDate) {
        var currentDateComps: NSDateComponents = NSWEvent.getDateComponentsFromDate(currentDate)
        var predicateFormat: NSString = "startDateComponents.day = \(currentDateComps.day) && startDateComponents.month == \(currentDateComps.month) && startDateComponents.year == \(currentDateComps.year)"
        var dateMatchesCurrent: NSComparisonPredicate = NSComparisonPredicate(format: predicateFormat as String)
        var todaysEvents: NSArray = self.fullEventList.filteredArrayUsingPredicate(dateMatchesCurrent)
        
        self.myTableViewController?.setVCArrayToDataSourceArray(eventsSortedByTime(todaysEvents) as [AnyObject])
    }
    
    func eventsSortedByTime(unsortedEvents: NSArray)->NSArray {
        var sortDescriptor: NSSortDescriptor = NSSortDescriptor(key: "startDateTime", ascending: true)
        
        var sortDescriptors = [sortDescriptor]
        
        var sortedEvents: NSArray = unsortedEvents.sortedArrayUsingDescriptors(sortDescriptors as [AnyObject])
        
        return sortedEvents
    }
    
    }

{'fraction_non_alphanumeric': 0.07772020725388601, 'fraction_numerical': 0.00466321243523316, 'mean_word_length': 3.2242888402625822, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1333719', 'n_tokens_mistral': 1083, 'n_tokens_neox': 1018, 'n_words': 219}