     }
     
 }
+
+// MARK: - NSDate Extension
+/// Adds TimeUnit functionality to date objects, allowing method chaining.
+extension NSDate {
+    
+// MARK: - Beginning of time unit
+    /**
+        Creates a new date at the first second of the same minute as the recevier.
+    
+        - returns: The newly created date representing the first second of the same
+            minute as the receiver.
+    */
+    public func beginningOfMinute() -> NSDate {
+        return TimeUnit().beginningOfMinute(self)
+    }
+    
+    /**
+        Creates a new date at the first second of the same hour as the receiver.
+    
+        - returns: The newly created date representing the first second of the 
+            same hour as the receiver.
+    */
+    public func beginningOfHour() -> NSDate {
+        return TimeUnit().beginningOfHour(self)
+    }
+    
+    /**
+        Creates a new date at the first second of the same day as the receiver.
+    
+        - returns: The newly created date representing the first second of the 
+            same day as the receiver.
+    */
+    public func beginningOfDay() -> NSDate {
+        return TimeUnit().beginningOfDay(self)
+    }
+    
+    /**
+        Creates a new date at the first second of the same week as the receiver.
+    
+        - returns: The newly created date representing the first second of the 
+            same week as the receiver.
+    */
+    public func beginningOfWeek() -> NSDate {
+        return TimeUnit().beginningOfWeek(self)
+    }
+    
+    /**
+        Creates a new date at the first second of the same month as the receiver.
+    
+        - returns: The newly created date representing the first second of the 
+            same month as the receiver.
+    */
+    public func beginningOfMonth() -> NSDate {
+        return TimeUnit().beginningOfMonth(self)
+    }
+    
+    /**
+        Creates a new date at the first second of the same year as the receiver.
+    
+        - returns: The newly created date representing the first second of the 
+            same year as the receiver.
+    */
+    public func beginningOfYear() -> NSDate {
+        return TimeUnit().beginningOfYear(self)
+    }
+    
+// MARK: - End of time unit
+    public func endOfMinute() -> NSDate {
+        return TimeUnit().endOfMinute(self)
+    }
+    
+    public func endOfHour() -> NSDate {
+        return TimeUnit().endOfHour(self)
+    }
+    
+    public func endOfDay() -> NSDate {
+        return TimeUnit().endOfDay(self)
+    }
+    
+    public func endOfWeek() -> NSDate {
+        return TimeUnit().endOfWeek(self)
+    }
+    
+    public func endOfMonth() -> NSDate {
+        return TimeUnit().endOfMonth(self)
+    }
+    
+    public func endOfYear() -> NSDate {
+        return TimeUnit().endOfYear(self)
+    }
+    
+    
+// MARK: - Next and previous time unit
+    
+    public func minuteBefore() -> NSDate {
+        return TimeUnit().minuteBefore(self)
+    }
+    
+    public func minuteAfter() -> NSDate {
+        return TimeUnit().minuteAfter(self)
+    }
+    
+    public func hourBefore() -> NSDate {
+        return TimeUnit().hourBefore(self)
+    }
+    
+    public func hourAfter() -> NSDate {
+        return TimeUnit().hourAfter(self)
+    }
+    
+    public func dayBefore() -> NSDate {
+        return TimeUnit().dayBefore(self)
+    }
+    
+    public func dayAfter() -> NSDate {
+        return TimeUnit().dayAfter(self)
+    }
+    
+    public func weekBefore() -> NSDate {
+        return TimeUnit().weekBefore(self)
+    }
+    
+    public func weekAfter() -> NSDate {
+        return TimeUnit().weekAfter(self)
+    }
+    
+    public func monthBefore() -> NSDate {
+        return TimeUnit().monthBefore(self)
+    }
+    
+    public func monthAfter() -> NSDate {
+        return TimeUnit().monthAfter(self)
+    }
+    
+    public func yearBefore() -> NSDate {
+        return TimeUnit().yearBefore(self)
+    }
+    
+    public func yearAfter() -> NSDate {
+        return TimeUnit().yearAfter(self)
+    }
+}

    /**
        Creates a new date at the first second of the hour prior to the given date.
    
        - parameter date: The date for which to find the previous hour
    
        - returns: The newly created date.

// MARK: - Calculate end of time unit
    
    /**
        Creates a new date at the last second of the same minute as the given date.
    
        - parameter date: The date for which to calculate the end of the minute.
    
        - returns: The newly created date representing the last second of the minute.
    */
    public func endOfMinute(date:NSDate) -> NSDate {
        let firstSecondOfNextMinute = self.beginningOfHour(
            self.calendar.dateByAddingUnit(.Minute, value: 1, toDate: date, options: [])!
        )
        
        return firstSecondOfNextMinute.dateByAddingTimeInterval(-1)
    }
    
    /**
        Creates a new date at the last second of the same hour as the given date.
    
        - parameter date: The date for which to calculate the end of the hour.
    
        - returns: The newly created date representing the last second of the hour.
    */
