Skip to content

Commit

Permalink
Code cleanup in setSelectedDate()
Browse files Browse the repository at this point in the history
  • Loading branch information
alexeyismirnov committed Oct 14, 2014
1 parent 4eae09f commit 81b3dd0
Showing 1 changed file with 6 additions and 18 deletions.
24 changes: 6 additions & 18 deletions RDVCalendarView/RDVCalendarView.m
Original file line number Diff line number Diff line change
Expand Up @@ -425,24 +425,12 @@ - (void)setSelectedDate:(NSDate *)selectedDate {

if (![oldDate isEqualToDate:selectedDate]) {
NSCalendar *calendar = [self calendar];

if (![self selectedDay]) {
[self setSelectedDay:[[NSDateComponents alloc] init]];
}

NSDateComponents *selectedDateComponents = [calendar components:NSYearCalendarUnit|
NSMonthCalendarUnit|
NSDayCalendarUnit
fromDate:selectedDate];

if (![self selectedDay]) {
[self setSelectedDay:[[NSDateComponents alloc] init]];
}

[[self selectedDay] setMonth:[selectedDateComponents month]];
[[self selectedDay] setYear:[selectedDateComponents year]];
[[self selectedDay] setDay:[selectedDateComponents day]];


_selectedDay = [calendar components:NSYearCalendarUnit|
NSMonthCalendarUnit|
NSDayCalendarUnit
fromDate:selectedDate];

self.month = [calendar components:NSYearCalendarUnit|
NSMonthCalendarUnit|
NSDayCalendarUnit|
Expand Down

0 comments on commit 81b3dd0

Please sign in to comment.