This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension NSDate { | |
convenience init(ISO8601:String) { | |
let dateStringFormatter = NSDateFormatter() | |
dateStringFormatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ssZZZZZ" | |
dateStringFormatter.locale = NSLocale.systemLocale() | |
let d = dateStringFormatter.dateFromString(ISO8601) | |
self.init(timeInterval:0, sinceDate:d!) | |
} | |
class func getLastDayOfMonthFrom(month:Int,year:Int) -> NSDate { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (BOOL)isSameDayWithDateOne:(NSDate *)dateOne dateTwo:(NSDate *)dateTwo{ | |
NSCalendar *calender = [NSCalendar currentCalendar]; | |
unsigned unitFlags = NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit; | |
NSDateComponents *compOne = [calender components:unitFlags fromDate:dateOne]; | |
NSDateComponents *compTwo = [calender components:unitFlags fromDate:dateTwo]; | |
return ([compOne day] == [compTwo day] && [compOne month] == [compTwo month] && [compOne year] == [compTwo year]); |