Skip to content

Instantly share code, notes, and snippets.

View zerolethanh's full-sized avatar
😀

LE VAN THANH zerolethanh

😀
View GitHub Profile
@lukewakeford
lukewakeford / Swift NSDate Extensions
Last active August 31, 2016 18:43
Swift NSDate Extensions
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 {
@jonahsiegle
jonahsiegle / gist:9837352
Created March 28, 2014 16:45
Check if two NSDate objects are on the same day.
- (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]);