Latest 1.0.0
Homepage https://github.com/tomguthrie/TFGRelativeDateFormatter
License MIT
Platforms ios 7.0, requires ARC
Authors

Mail.app style relative date formatter.

Note: This repo will be deprecated in favour of
RelativeDateFormatter
some time in the future.

Examples

en_GB en_US
Same Day 13:45 1:45 PM
Yesterday Yesterday Yesterday
Same Week Monday Monday
Same Year 15 Mar Mar 15
Last Year 22/04/2013 4/22/13

Usage

NSDate *date = ...;
TFGRelativeDateFormatter *formatter = [[TFGRelativeDateFormatter alloc] init];
NSString *relativeString = [formatter stringForDate:date];

TFGRelativeDateFormatter has similar cavets to a NSDateFormatter (it is used
internally) meaning its a good idea to cache instances and not modify the locale.
A handy class method +sharedFormatter is provided to get around this for the
common case where locale is never changed.

NSDate *date = ...;
NSString *relativeString = [[TFGRelativeDateFormatter sharedFormatter] stringForDate:date];

Thread Safety: TFGRelativeDateFormatter is fully thread safe on iOS 7 and
OS X 10.9 (Mordern 64-bit apps). Earlier versions are not however and its recommended
to only use an instance per thread. (More information about thread safety can be
found by reading the NSDateFormatter class reference.)

Installation

TFGRelativeDateFormatter is available through
CocoaPods, to install it simply add the following line
to your Podfile:

pod 'TFGRelativeDateFormatter'

Alternatively, simply drag TFGRelativeDateFormatter.h and TFGRelativeDateFormatter.m to your project.

Contact

Thomas Guthrie
@tomguthrie

License

TFGRelativeDateFormatter is available under the MIT license. See the LICENSE
file for more info.

Latest podspec

{
    "name": "TFGRelativeDateFormatter",
    "version": "1.0.0",
    "license": "MIT",
    "summary": "Mail.app style relative date formatter.",
    "homepage": "https://github.com/tomguthrie/TFGRelativeDateFormatter",
    "social_media_url": "https://twitter.com/tomguthrie",
    "authors": {
        "Thomas Guthrie": "[email protected]"
    },
    "source": {
        "git": "https://github.com/tomguthrie/TFGRelativeDateFormatter.git",
        "tag": "1.0.0"
    },
    "source_files": "TFGRelativeDateFormatter",
    "requires_arc": true,
    "platforms": {
        "ios": "7.0"
    }
}

Pin It on Pinterest

Share This