Created
February 24, 2015 12:48
-
-
Save Den-Rimus/32f2e5854fce00b45670 to your computer and use it in GitHub Desktop.
iOS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (elapse < 60) { | |
if(elapse<1) | |
elapse=1; | |
return [NSString stringWithFormat:@"%ds", (int)elapse]; | |
} | |
else if (elapse < 60 * 60) { | |
int minute = round(elapse / 60); | |
return [NSString stringWithFormat:@"%dm", minute]; | |
// } else if (elapse < 1.5 * 60 * 60) { | |
// return @"An hour"; | |
} else if (elapse < 24 * 60 * 60) { | |
int hour = round(elapse / 60 / 60); | |
return [NSString stringWithFormat:@"%dh", hour]; | |
// } else if (elapse < 48 * 60 * 60) { | |
// return @"Yesterday"; | |
} else if (elapse < 7 * 24 * 60 * 60) { | |
int day = floor(elapse / 24 / 60 / 60); | |
return [NSString stringWithFormat:@"%dd", day]; | |
} else//(elapse < 365 * 24 * 60 * 60) | |
{ | |
int day = floor(elapse / 24 / 60 / 60/7); | |
return [NSString stringWithFormat:@"%dw", day]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment