-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathItenWired+NSDate.swift
63 lines (46 loc) · 1.63 KB
/
ItenWired+NSDate.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
//
// ItenWired+NSDate.swift
// Conference App
//
// Created by Felipe N. Brito on 7/21/16.
//
//
import Foundation
extension NSDate {
func isGreaterThanDate(dateToCompare: NSDate) -> Bool {
var isGreater = false
if self.compare(dateToCompare) == NSComparisonResult.OrderedDescending {
isGreater = true
}
return isGreater
}
func isLessThanDate(dateToCompare: NSDate) -> Bool {
var isLess = false
if self.compare(dateToCompare) == NSComparisonResult.OrderedAscending {
isLess = true
}
return isLess
}
func equalToDate(dateToCompare: NSDate) -> Bool {
var isEqualTo = false
if self.compare(dateToCompare) == NSComparisonResult.OrderedSame {
isEqualTo = true
}
return isEqualTo
}
func addDays(daysToAdd: Int) -> NSDate {
let secondsInDays: NSTimeInterval = Double(daysToAdd) * 60 * 60 * 24
let dateWithDaysAdded: NSDate = self.dateByAddingTimeInterval(secondsInDays)
return dateWithDaysAdded
}
func addHours(hoursToAdd: Int) -> NSDate {
let secondsInHours: NSTimeInterval = Double(hoursToAdd) * 60 * 60
let dateWithHoursAdded: NSDate = self.dateByAddingTimeInterval(secondsInHours)
return dateWithHoursAdded
}
func addSeconds(secondsToAdd: Double) -> NSDate {
let seconds: NSTimeInterval = secondsToAdd
let dateWithSecondsAdded: NSDate = self.dateByAddingTimeInterval(seconds)
return dateWithSecondsAdded
}
}