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:
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.
- Objective-C Library For Easier String Formatting/Masking Using Regular Expressions
- Easy To Use iOS String And UIText Validation Library (Regex Comparisons and More)
- Open Source iOS Library Inspired By Nokogiri and JQuery For Easier XML/HTML Parsing
- Xcode Code Formatter Tool Enabling Automatic Code Formatting Based On A Custom Rule Set
- Tutorial: Easy iOS In-App Purchase Validation
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.