Skip to content
This repository has been archived by the owner on May 23, 2020. It is now read-only.

Commit

Permalink
Fix issue omz#234 Off-by-one in month report title
Browse files Browse the repository at this point in the history
  • Loading branch information
kcergfalo committed May 28, 2013
1 parent ed895af commit 8483297
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions Classes/SalesViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -239,21 +239,18 @@ - (void)reloadData
for (Report *dailyReport in sortedDailyReports) {
NSDateComponents *dateComponents = [calendar components:NSYearCalendarUnit | NSMonthCalendarUnit fromDate:dailyReport.startDate];
if (!prevDateComponents || (dateComponents.month != prevDateComponents.month || dateComponents.year != prevDateComponents.year)) {
if (reportsInCurrentMonth) {
// New month discovered. Make a new ReportCollection to gather all the daily reports in this month.
reportsInCurrentMonth = [NSMutableArray array];
[reportsInCurrentMonth addObject:dailyReport];
ReportCollection *monthCollection = [[[ReportCollection alloc] initWithReports:reportsInCurrentMonth] autorelease];
monthCollection.title = [monthFormatter stringFromDate:dailyReport.startDate];
[sortedCalendarMonthReports addObject:monthCollection];
}
reportsInCurrentMonth = [NSMutableArray array];
}
} else {
// This report is from the same month as the previous report. Append the daily report to the existing collection.
[reportsInCurrentMonth addObject:dailyReport];
}
prevDateComponents = dateComponents;
}
if ([reportsInCurrentMonth count] > 0) {
ReportCollection *monthCollection = [[[ReportCollection alloc] initWithReports:reportsInCurrentMonth] autorelease];
monthCollection.title = [monthFormatter stringFromDate:[monthCollection firstReport].startDate];
[sortedCalendarMonthReports addObject:monthCollection];
}

// Group daily reports by fiscal month:
[sortedFiscalMonthReports removeAllObjects];
Expand Down

0 comments on commit 8483297

Please sign in to comment.