Skip to content
This repository has been archived by the owner on Mar 29, 2018. It is now read-only.

fix NSDate support iOS 7 #130

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 26 additions & 1 deletion ExSwift/NSDate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,32 @@ public extension NSDate {
let calendar = NSCalendar.currentCalendar()
let components = calendar.components(component, fromDate: self)

return components.valueForComponent(component)
if component & NSCalendarUnit.CalendarUnitYear != nil {
return components.year
}
if component & NSCalendarUnit.CalendarUnitMonth != nil {
return components.month
}
if component & NSCalendarUnit.CalendarUnitDay != nil {
return components.day
}
if component & NSCalendarUnit.CalendarUnitWeekday != nil {
return components.weekday
}
if component & NSCalendarUnit.CalendarUnitWeekOfMonth != nil {
return components.weekOfMonth
}
if component & NSCalendarUnit.CalendarUnitHour != nil {
return components.hour
}
if component & NSCalendarUnit.CalendarUnitMinute != nil {
return components.minute
}
if component & NSCalendarUnit.CalendarUnitSecond != nil {
return components.second
}

return 0
}
}

Expand Down