Library For Working With Dates Providing Helpers For Formatting, Parsing, Validation And Manipulation

I’ve mentioned a number of helper libraries for working with NSDate such as this library for grabbing locale aware dates and times and a handy collection of NSFormatter classes including helpers for showing the time between two NSDate objects.

Here’s an excellent library for working with dates called NSMoment from Yannick Loriot.

NSMoment is inspired by the Moment.js library and provides an extensive number of methods for formatting, parsing, validating and manipulating dates.

Here’s a few examples from the readme showing off some of the included formatting, localization, and calculation methods in the library:

NSLog(@"%@", [moment format:@"MMMM dd yyyy, h:mm:ss a"]); // October 27 2013, 10:49:48 AM

NSMoment *moment1 = [NSMoment momentWithDateAsString:@"20111031"];
NSLog(@"%@", [moment1 fromNow]); // 2 years ago

NSMoment *french = [[NSMoment now] addAmountOfTime:-3 forUnitKey:@"s"];
[french setLocale:[NSLocale localeWithLocaleIdentifier:@"fr_FR"]];
NSLog(@"%@", [french fromNow]); // il y a quelques secondes

You can find NSMoment on Github here.

A very useful library for working with dates.

FacebookTwitterDiggStumbleUponGoogle Plus

Original article: Library For Working With Dates Providing Helpers For Formatting, Parsing, Validation And Manipulation

©2013 iOS App Dev Libraries, Controls, Tutorials, Examples and Tools. All Rights Reserved.

Leave a Reply

Your email address will not be published. Required fields are marked *