Inherits from NSDateComponentsFormatter
Declared in CSTimeIntervalFormatter.h

Overview

A subclass of NSDateComponentsFormatter that makes it a bit easier and more reliable to format time intervals when dealing with a high volume of concurrent requests, such as in the context of a web-server.

The preffered way of using it is through the class methods stringFromTimeInterval:, stringFromDate:toDate: and stringFromDateComponents:, but it can also be used as any regular NSDateComponentsFormatter.

Tasks

Getting a Formatted String from two NSDate Objects

  • + stringFromDate:toDate:

    Returns the human-readable formatted value of the NSTimeInterval between endDate and startDate. This efectively returns the value from an NSDateComponentsFormatter set to use abbreviated units style, without time left and approximation phrase.

Getting a Formatted String from an NSTimeInterval

  • + stringFromTimeInterval:

    Returns the human-readable formatted value of timeInterval. This efectively returns the value from an NSDateComponentsFormatter set to use abbreviated units style, without time left and approximation phrase.

Getting a Formatted String from an NSDateComponents Object

Class Methods

stringFromDate:toDate:

+ (nullable NSString *)stringFromDate:(NSDate *)startDate toDate:(NSDate *)endDate
Discussion

Returns the human-readable formatted value of the NSTimeInterval between endDate and startDate. This efectively returns the value from an NSDateComponentsFormatter set to use abbreviated units style, without time left and approximation phrase.

Parameters

startDate

The start date

endDate

The end date

Return Value

A human-readable formatted value of the NSTimeInterval between endDate and startDate or nil if an error has occured

Declared In

CSTimeIntervalFormatter.h

stringFromDateComponents:

+ (nullable NSString *)stringFromDateComponents:(NSDateComponents *)components

stringFromTimeInterval:

+ (nullable NSString *)stringFromTimeInterval:(NSTimeInterval)timeInterval
Discussion

Returns the human-readable formatted value of timeInterval. This efectively returns the value from an NSDateComponentsFormatter set to use abbreviated units style, without time left and approximation phrase.

Parameters

timeInterval

The NSTimeInterval to be formatted

Return Value

A human-readable formatted value of timeInterval or nil if an error has occured

Declared In

CSTimeIntervalFormatter.h