Introduction
NVDate is library for handling NSDate manipulation in iOS Development.
Features
NVDate have many features that help to solve your problem.
- Capable to do lot of date manipulation task
- User friendly naming convention
- Chainable functions
- Easy to use
- Open Source !
Installation
Manually
Download the source, then follow these steps:
-
Objective-C
Copy both
NVDate.handNVDate.mfiles into your project#import "NVDate.h"
-
Swift
Copy
NVDate.Swift
CocoaPods
Installing NVDate using CocoaPods is easier. Simply add the following line to your Podfile :
pod 'NVDate'Simple Example
Full date of today
Objective-C
NVDate *date = [[NVDate alloc] initUsingToday];
NSLog(@"today is : %@", [date stringValue]);
// today is : Wednesday, February 5, 2014, 4:56:35 PM Western Indonesia TimeSwift
let date = NVDate(isUsingToday: true)
NSLog("today is : %@", date.stringValue());
// today is : Wednesday, February 5, 2014, 4:56:35 PM Western Indonesia TimeLast day of next 2 months
Objective-C
NVDate *date = [[NVDate alloc] initUsingToday];
[date nextMonths:2];
[date lastDayOfMonth];
NSLog(@"next 2 months from today is : %@", [date stringValueWithFormat:@"dd-MM-yyyy"]);
// next 2 months from today is : 30-04-2014Swift
var date = NVDate(isUsingToday: true)
date.nextMonths(2);
date.lastDayOfMonth(2);
NSLog("next 2 months from today is : %@", date.stringValue(dateFormat: "dd-MM-yyyy"));
// next 2 months from today is : 30-04-2014Second week of 2 months ago
Objective-C
NVDate *date = [[[[[NVDate alloc] initUsingToday] previousMonths:2] firstDayOfMonth] nextWeek];
date.dateFormatUsingString = @"yyyy-MM-dd HH:mm:ss";
NSLog(@"second week of 2 months ago is : %@", [date stringValue]);
// second week of 2 months ago is : 2013-12-08 17:03:36Swift
var date = NVDate(isUsingToday: true).previousMonths(2).firstDayOfMonth().nextWeek()
date.dateFormatUsingString = "yyyy-MM-dd HH:mm:ss";
NSLog("second week of 2 months ago is : %@", date.stringValue());
// second week of 2 months ago is : 2013-12-08 17:03:36Detect if yesterday is friday
Objective-C
BOOL isFriday = [[[[NVDate alloc] initUsingToday] previousDay] isCurrentDayName:NVDayUnitFriday];
NSLog(@"is yesterday was friday ? %@", isFriday ? @"yes" : @"no");
// is yesterday was friday ? noSwift
Bool isFriday = NVDate(isUsingToday: true).previousDay().isCurrentDayName(.Friday)
NSLog("is yesterday was friday ? %@", isFriday ? "yes" : "no");
// is yesterday was friday ? noDot syntax
Objective-C
NVDate *nvDate = [[NVDate alloc] initUsingToday];
NSString someday = nvDate.previousDay.previousWeek.nextDay.stringValue;
NSLog(@"someday %@", someday);
// someday 2013-12-08 17:03:36Swift
var nvDate = NVDate(isUsingToday: true);
String someday = nvDate.previousDay().previousWeek().nextDay().stringValue();
NSLog(@"someday %@", someday);
// someday 2013-12-08 17:03:36Documentation
https://github.com/novalagung/NVDate/wiki/API-Reference
Contribution
Feel free to add contribution to this project by fork -> pull request
