Skip to content

Commit

Permalink
Refactor refresh method to goToToday
Browse files Browse the repository at this point in the history
setCurrentDate in refresh method
  • Loading branch information
Husseinhj committed Nov 11, 2017
1 parent 2b9efe4 commit 59cd4cc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion ios_calendar/Sources/CalendarView.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ typedef NS_ENUM(NSInteger, CalendarEvent)

- (instancetype)initWithPosition:(CGFloat)x y:(CGFloat)y;
- (void)setMode:(NSInteger)m;
- (void)refresh;
- (void)goToToday;
- (void)reload;
- (void)advanceCalendarContents;
- (void)rewindCalendarContents;
Expand Down
9 changes: 4 additions & 5 deletions ios_calendar/Sources/CalendarView.m
Original file line number Diff line number Diff line change
Expand Up @@ -233,10 +233,6 @@ - (void)setup
NSCalendar *calendar = [[NSCalendar alloc] initWithCalendarIdentifier:self.calendarIdentifier];
NSDateComponents *components = [calendar components:(NSCalendarUnitYear | NSCalendarUnitMonth | NSCalendarUnitDay) fromDate:now];

currentDay = [components day];
currentMonth = [components month];
currentYear = [components year];

todayDay = [components day];
todayMonth = [components month];
todayYear = [components year];
Expand Down Expand Up @@ -299,13 +295,16 @@ - (NSLocale *) locale{

#pragma mark - reload

- (void) reload{
- (void) goToToday{
[self setup];
}
#pragma mark - Refresh

- (void)refresh
{
NSDate *now = [NSDate date];
[self setCurrentDate:now];

if (self.calendarIdentifier == NSCalendarIdentifierPersian) {
[self generatePersianDayRects];
} else {
Expand Down

0 comments on commit 59cd4cc

Please sign in to comment.