Skip to content

Instantly share code, notes, and snippets.

@EskiMag EskiMag/gist:805853
Created Feb 1, 2011

What would you like to do?
Cocoa vs. Rails method returning the end of current month
- (NSDate *)endOfThisMonth {
NSDate *endOfMonth = [NSDate date];
NSCalendar *calendar = [NSCalendar currentCalendar];
NSDateComponents *comp = [calendar components:(NSWeekdayCalendarUnit | NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit) fromDate:[NSDate date]];
[comp setMonth:[comp month]+1];
[comp setDay:1];
endOfMonth = [calendar dateFromComponents:comp];
return [endOfMonth dateByAddingTimeInterval:-(60*60*24)];
def end_of_this_month
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.