Skip to content

Commit

Permalink
Rename date categories
Browse files Browse the repository at this point in the history
  • Loading branch information
soffes committed May 8, 2012
1 parent a8841aa commit 226d4b8
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 30 deletions.
48 changes: 24 additions & 24 deletions SSToolkit/NSDate+SSToolkitAdditions.h
Expand Up @@ -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
12 changes: 6 additions & 6 deletions SSToolkit/NSDate+SSToolkitAdditions.m
Expand Up @@ -82,7 +82,7 @@ - (NSString *)ISO8601String {
}


- (NSString *)briefTimeAgoInWords {
- (NSString *)briefTimeInWords {
NSTimeInterval seconds = fabs([self timeIntervalSinceNow]);

// Seconds
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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];
}


Expand Down

0 comments on commit 226d4b8

Please sign in to comment.