Skip to content

Instantly share code, notes, and snippets.

@damirstuhec
Created January 30, 2014 14:05
Show Gist options
  • Save damirstuhec/8709011 to your computer and use it in GitHub Desktop.
Save damirstuhec/8709011 to your computer and use it in GitHub Desktop.
NSDate *fireDate = nil;
NSDate *startDate = [card getLatestDateOfActivities:@[ACTIVITY_CARD_CREATED, ACTIVITY_TIME_SET, ACTIVITY_TIME_CHANGED]];
NSDate *endDate = card.time.date;
NSTimeInterval deltaHours = (abs([startDate timeIntervalSinceReferenceDate] - [endDate timeIntervalSinceReferenceDate]) / 3600);
NSString *invitesNamesSentence = [card getInvitesNamesSentenceWithYourFriendsOption:YES];
NSMutableString *alertBody = [[NSMutableString alloc] initWithFormat:@"%@ wants to meet you ", invitesNamesSentence];
if (endDate && deltaHours < 24)
{
fireDate = [startDate dateByAddingMinutes:30];
[alertBody appendFormat:@"%@. Don't wait and respond on card %@.", [card.time getUniversalTimeDateString], card.category.name];
}
else
{
fireDate = [startDate dateByAddingHours:5];
[alertBody appendFormat:@"for %@", card.category.name];
if (endDate)
{
[alertBody appendFormat:@", %@", [card.time getUniversalTimeDateString]];
}
if (card.location)
{
[alertBody appendFormat:@" at %@ and is still waiting for you to respond.", card.location.name];
}
else
{
[alertBody appendFormat:@". Don’t wait, respond right away."];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment