Skip to content
This repository has been archived by the owner on Feb 16, 2019. It is now read-only.

Commit

Permalink
Fix date calculation defect.
Browse files Browse the repository at this point in the history
  • Loading branch information
Arthur Dexter committed Feb 10, 2012
1 parent ab51368 commit 1b5657f
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions SSToolkit/NSDate+SSToolkitAdditions.m
Original file line number Diff line number Diff line change
Expand Up @@ -150,17 +150,19 @@ - (NSString *)unitsGroupStringFromDate:(NSDate *)date {
unsigned int unitFlags = NSYearCalendarUnit|NSMonthCalendarUnit|NSWeekOfMonthCalendarUnit|NSDayCalendarUnit;
NSDateComponents *selfComps = [cal components:unitFlags fromDate:self];
NSDateComponents *dateComps = [cal components:unitFlags fromDate:date];
if (dateComps.year - selfComps.year > 1) {
if ([self earlierDate:date] != self) {
result = NSLocalizedString(@"In The Future", @"In The Future");
} else if (dateComps.year - selfComps.year > 1) {
result = NSLocalizedString(@"More Than One Year Ago", @"More Than One Year Ago");
} else if (dateComps.year != selfComps.year) {
} else if (dateComps.year - selfComps.year > 0) {
result = NSLocalizedString(@"Last Year", @"Last Year");
} else if (dateComps.month != selfComps.month) {
} else if (dateComps.month - selfComps.month > 0) {
result = NSLocalizedString(@"This Year", @"This Year");
} else if (dateComps.weekOfMonth != selfComps.weekOfMonth) {
} else if (dateComps.weekOfMonth - selfComps.weekOfMonth > 0) {
result = NSLocalizedString(@"This Month", @"This Month");
} else if (dateComps.day - selfComps.day > 1) {
result = NSLocalizedString(@"This Week", @"This Week");
} else if (dateComps.day != selfComps.day) {
} else if (dateComps.day - selfComps.day > 0) {
result = NSLocalizedString(@"Yesterday", @"Yesterday");
} else {
result = NSLocalizedString(@"Today", @"Today");
Expand Down

0 comments on commit 1b5657f

Please sign in to comment.