GithubHelp home page GithubHelp logo

ssuchanowski / tfgrelativedateformatter Goto Github PK

View Code? Open in Web Editor NEW

This project forked from tomguthrie/tfgrelativedateformatter

0.0 2.0 0.0 119 KB

Mail.app style relative date formatter.

License: MIT License

XML 14.84% Ruby 4.90% Objective-C 80.26%

tfgrelativedateformatter's Introduction

Build Status Version Platform

Mail.app style relative date formatter.

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.

tfgrelativedateformatter's People

Contributors

ssuchanowski avatar tomguthrie avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.