Large diffs are not rendered by default.

@@ -131,6 +131,12 @@ class Task: NSManagedObject {
self.isComplete = false
}


// Whether or not the task is due on or before the given date
func isDueOnOrBefore(date: NSDate) -> Bool {
return (self.dueDate.compare(date) != .OrderedDescending)
}

// Adds the given TaskWorkSession to this task
func addWorkSession(workSession: TaskWorkSession) {
self.workSessions = self.workSessions.setByAddingObject(workSession)
@@ -0,0 +1,32 @@
//
// TaskTableViewCell.swift
// TaskScheduler
//
// Created by Ben Oztalay on 12/21/15.
// Copyright © 2015 Ben Oztalay. All rights reserved.
//
import UIKit

class TaskTableViewCell: UITableViewCell {
@IBOutlet weak var titleLabel: UILabel!
@IBOutlet weak var dueByLabel: UILabel!
@IBOutlet weak var priorityLabel: UILabel!
@IBOutlet weak var typeLabel: UILabel!

private static var dateFormatter: NSDateFormatter = {
let formatter = NSDateFormatter()
formatter.formattingContext = .MiddleOfSentence
formatter.dateStyle = .MediumStyle
formatter.timeStyle = .NoStyle
formatter.doesRelativeDateFormatting = true
return formatter
}()

func setTask(task: Task) {
self.titleLabel.text = "\(task.title) (\(task.workEstimate) hours)"
self.dueByLabel.text = "Due " + TaskTableViewCell.dateFormatter.stringFromDate(task.dueDate)
self.priorityLabel.text = String(task.priority)
self.typeLabel.text = task.type
}
}
@@ -119,7 +119,7 @@ class TasksViewController: UITableViewController, UITabBarControllerDelegate, Sc
}

override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("Task Cell", forIndexPath: indexPath) as! WorkSessionTableViewCell
let cell = tableView.dequeueReusableCellWithIdentifier("WorkSessionCell", forIndexPath: indexPath) as! WorkSessionTableViewCell

let workSession = self.user!.todayWorkDay().workSessionsArray[indexPath.row]
cell.setWorkSession(workSession)
@@ -179,7 +179,7 @@ class User: NSManagedObject {

// Calculates the amount of work to do between now and the given date
func workToDoBetweenNowAnd(date date: NSDate) -> Float {
return self.notDroppedTasks.filter({ !$0.isDueInPast }).map({ $0.workLeftToDo }).reduce(0.0, combine: +)
return self.notDroppedTasks.filter({ $0.isDueOnOrBefore(date) && !$0.isDueInPast }).map({ $0.workLeftToDo }).reduce(0.0, combine: +)
}

// Removes all of the incomplete work sessions from all of
@@ -22,11 +22,6 @@ class WorkSessionTableViewCell: UITableViewCell {
formatter.doesRelativeDateFormatting = true
return formatter
}()

override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
}

func setWorkSession(workSession: TaskWorkSession) {
let task = workSession.parentTask