diff --git a/SSToolkit/NSDate+SSToolkitAdditions.h b/SSToolkit/NSDate+SSToolkitAdditions.h index 6b14392..54e78eb 100644 --- a/SSToolkit/NSDate+SSToolkitAdditions.h +++ b/SSToolkit/NSDate+SSToolkitAdditions.h @@ -32,62 +32,62 @@ - (NSString *)ISO8601String; -///--------------- -/// @name Time Ago -///--------------- +///-------------------- +/// @name Time In Words +///-------------------- /** - Returns a string representing the time interval from now in words. + Returns a string representing the time interval from now in words (including seconds). The strings produced by this method will be similar to produced by Twitter for iPhone or Tweetbot in the top right of the tweet cells. - Internally, this does not use `timeAgoInWordsFromTimeInterval:includingSeconds:`. + Internally, this does not use `timeInWordsFromTimeInterval:includingSeconds:`. @return A string representing the time interval from now in words */ -- (NSString *)briefTimeAgoInWords; +- (NSString *)briefTimeInWords; /** - Returns a string representing a time interval in words. + Returns a string representing the time interval from now in words (including seconds). The strings produced by this method will be similar to produced by ActiveSupport's `time_ago_in_words` helper method. - @param intervalInSeconds The time interval to convert to a string - - @param includeSeconds `YES` if seconds should be included. `NO` if they should not. - - @return A string representing the time interval in words + @return A string representing the time interval from now in words - @see timeAgoInWords - @see timeAgoInWordsIncludingSeconds: + @see timeInWordsIncludingSeconds: + @see timeInWordsFromTimeInterval:includingSeconds: */ -+ (NSString *)timeAgoInWordsFromTimeInterval:(NSTimeInterval)intervalInSeconds includingSeconds:(BOOL)includeSeconds; +- (NSString *)timeInWords; /** - Returns a string representing the time interval from now in words (including seconds). + Returns a string representing the time interval from now in words. The strings produced by this method will be similar to produced by ActiveSupport's `time_ago_in_words` helper method. + @param includeSeconds `YES` if seconds should be included. `NO` if they should not. + @return A string representing the time interval from now in words - @see timeAgoInWordsIncludingSeconds: - @see timeAgoInWordsFromTimeInterval:includingSeconds: + @see timeInWordsIncludingSeconds: + @see timeInWordsFromTimeInterval:includingSeconds: */ -- (NSString *)timeAgoInWords; +- (NSString *)timeInWordsIncludingSeconds:(BOOL)includeSeconds; /** - Returns a string representing the time interval from now in words. + Returns a string representing a time interval in words. The strings produced by this method will be similar to produced by ActiveSupport's `time_ago_in_words` helper method. + @param intervalInSeconds The time interval to convert to a string + @param includeSeconds `YES` if seconds should be included. `NO` if they should not. - @return A string representing the time interval from now in words + @return A string representing the time interval in words - @see timeAgoInWordsIncludingSeconds: - @see timeAgoInWordsFromTimeInterval:includingSeconds: + @see timeInWords + @see timeInWordsIncludingSeconds: */ -- (NSString *)timeAgoInWordsIncludingSeconds:(BOOL)includeSeconds; ++ (NSString *)timeInWordsFromTimeInterval:(NSTimeInterval)intervalInSeconds includingSeconds:(BOOL)includeSeconds; @end diff --git a/SSToolkit/NSDate+SSToolkitAdditions.m b/SSToolkit/NSDate+SSToolkitAdditions.m index 19d0893..8cee2ed 100644 --- a/SSToolkit/NSDate+SSToolkitAdditions.m +++ b/SSToolkit/NSDate+SSToolkitAdditions.m @@ -82,7 +82,7 @@ - (NSString *)ISO8601String { } -- (NSString *)briefTimeAgoInWords { +- (NSString *)briefTimeInWords { NSTimeInterval seconds = fabs([self timeIntervalSinceNow]); // Seconds @@ -134,7 +134,7 @@ - (NSString *)briefTimeAgoInWords { } -+ (NSString *)timeAgoInWordsFromTimeInterval:(NSTimeInterval)intervalInSeconds includingSeconds:(BOOL)includeSeconds { ++ (NSString *)timeInWordsFromTimeInterval:(NSTimeInterval)intervalInSeconds includingSeconds:(BOOL)includeSeconds { NSTimeInterval intervalInMinutes = round(intervalInSeconds / 60.0f); if (intervalInMinutes >= 0 && intervalInMinutes <= 1) { @@ -177,13 +177,13 @@ + (NSString *)timeAgoInWordsFromTimeInterval:(NSTimeInterval)intervalInSeconds i } -- (NSString *)timeAgoInWords { - return [self timeAgoInWordsIncludingSeconds:YES]; +- (NSString *)timeInWords { + return [self timeInWordsIncludingSeconds:YES]; } -- (NSString *)timeAgoInWordsIncludingSeconds:(BOOL)includeSeconds { - return [[self class] timeAgoInWordsFromTimeInterval:fabs([self timeIntervalSinceNow]) includingSeconds:includeSeconds]; +- (NSString *)timeInWordsIncludingSeconds:(BOOL)includeSeconds { + return [[self class] timeInWordsFromTimeInterval:fabs([self timeIntervalSinceNow]) includingSeconds:includeSeconds]; }