Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MKCalendarView's first day based on user's locale + minor bugfix. #237

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
8 changes: 8 additions & 0 deletions src/TapkuLibrary/TKCalendarMonthView.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@
/** `TKCalendarMonthView` imitates the month grid in the Calendar app on iPhone. */
@interface TKCalendarMonthView : UIView

/** Initialize a Calendar Month Grid.

Uses locale's setting for first day of week.
@param timeZone The time zone of the grid,
@return A `TKCalendarMonthView` object or nil.
*/
- (id) init;

/** Initialize a Calendar Month Grid.
@param timeZone The time zone of the grid,
@return A `TKCalendarMonthView` object or nil.
Expand Down
3 changes: 1 addition & 2 deletions src/TapkuLibrary/TKCalendarMonthView.m
Original file line number Diff line number Diff line change
Expand Up @@ -738,8 +738,7 @@ - (id) initWithSundayAsFirst:(BOOL)sunday{
return self;
}
- (id) init{
self = [self initWithSundayAsFirst:YES];
return self;
return [self initWithSundayAsFirst:[[NSCalendar currentCalendar] firstWeekday] == 1];
}
- (id) initWithFrame:(CGRect)frame{
self = [self init];
Expand Down
6 changes: 4 additions & 2 deletions src/TapkuLibrary/TKCalendarMonthViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@
/** The `TKCalendarMonthViewController` class creates a controller object that manages a calendar month grid. */
@interface TKCalendarMonthViewController : UIViewController <TKCalendarMonthViewDelegate,TKCalendarMonthViewDataSource>

/** Initializes a month view controller to manage a month grid. Sunday will be the left-most day.
/** Initializes a month view controller to manage a month grid. Sunday will be the left-most day
if current locale's weeks begin on Sunday, otherwise Monday.
@return A newly create month view controller.
*/
- (id) init;
Expand All @@ -57,7 +58,8 @@
*/
- (id) initWithSunday:(BOOL)sundayFirst timeZone:(NSTimeZone*)timeZone;

/** Initializes a month view controller to manage a month grid. Sunday will be the left-most day.
/** Initializes a month view controller to manage a month grid. Sunday will be the left-most day
if current locale's weeks begin on Sunday, otherwise Monday.
@param timeZone The time zone for the calendar grid.
@return A newly create month view controller.
*/
Expand Down
6 changes: 3 additions & 3 deletions src/TapkuLibrary/TKCalendarMonthViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@ @interface TKCalendarMonthViewController ()
@implementation TKCalendarMonthViewController

- (id) init{
self = [self initWithSunday:YES];
self = [self initWithSunday:[[NSCalendar currentCalendar]firstWeekday] == 1];
return self;
}
- (id) initWithSunday:(BOOL)sundayFirst{
self = [self initWithSunday:sundayFirst timeZone:[NSTimeZone defaultTimeZone]];
return self;
}
- (id) initWithTimeZone:(NSTimeZone *)timeZone{
self = [self initWithSunday:YES timeZone:self.timeZone];
self = [self initWithSunday:[[NSCalendar currentCalendar]firstWeekday] == 1 timeZone:timeZone];
return self;
}
- (id) initWithSunday:(BOOL)sundayFirst timeZone:(NSTimeZone *)timeZone{
Expand All @@ -60,7 +60,7 @@ - (id) initWithSunday:(BOOL)sundayFirst timeZone:(NSTimeZone *)timeZone{
- (id) initWithCoder:(NSCoder *)decoder {
if(!(self=[super initWithCoder:decoder])) return nil;
self.timeZone = [NSTimeZone defaultTimeZone];
self.sundayFirst = YES;
self.sundayFirst = [[NSCalendar currentCalendar]firstWeekday] == 1;
return self;
}

Expand Down