Skip to content

Instantly share code, notes, and snippets.

@Li-blog
Created August 8, 2016 14:21
Show Gist options
  • Save Li-blog/fb8eba27b2e858b7b31401e18ecf4dd6 to your computer and use it in GitHub Desktop.
Save Li-blog/fb8eba27b2e858b7b31401e18ecf4dd6 to your computer and use it in GitHub Desktop.
NSString *getWeekStr(int weekInt) {
NSDate *startDate = [WCPreferencesManager sharedManager].startDate;
NSInteger dur = [WCPreferencesManager sharedManager].duration;
NSInteger startDay = [[WCPreferencesManager sharedManager].weekStartDay isEqualToString:@"Monday"] ? 1 : 0;
WCSemester *sem = [[WCSemester alloc] initWithStartDate:startDate duration:dur weekStartAt:startDay];
NSInteger week = [sem weekNo:[NSDate date]];
if (week == -1) { return @""; }
else {
NSString *display = [WCPreferencesManager sharedManager].displayFormat;
display = [display stringByReplacingOccurrencesOfString:@"\%W" withString:[NSString stringWithFormat:@"%ld", (long)week + weekInt]];
return [display stringByAppendingString:@" "];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment