NVDate is library for handling NSDate
manipulation in iOS Development.
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 !
Download the source, then follow these steps:
-
Objective-C
Copy both
NVDate.h
andNVDate.m
files into your project#import "NVDate.h"
-
Swift
Copy
NVDate.Swift
Installing NVDate using CocoaPods is easier. Simply add the following line to your Podfile
:
pod 'NVDate'
NVDate *date = [[NVDate alloc] initUsingToday];
NSLog(@"today is : %@", [date stringValue]);
// today is : Wednesday, February 5, 2014, 4:56:35 PM Western Indonesia Time
let date = NVDate(isUsingToday: true)
NSLog("today is : %@", date.stringValue());
// today is : Wednesday, February 5, 2014, 4:56:35 PM Western Indonesia Time
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-2014
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-2014
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:36
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:36
BOOL isFriday = [[[[NVDate alloc] initUsingToday] previousDay] isCurrentDayName:NVDayUnitFriday];
NSLog(@"is yesterday was friday ? %@", isFriday ? @"yes" : @"no");
// is yesterday was friday ? no
Bool isFriday = NVDate(isUsingToday: true).previousDay().isCurrentDayName(.Friday)
NSLog("is yesterday was friday ? %@", isFriday ? "yes" : "no");
// is yesterday was friday ? no
NVDate *nvDate = [[NVDate alloc] initUsingToday];
NSString someday = nvDate.previousDay.previousWeek.nextDay.stringValue;
NSLog(@"someday %@", someday);
// someday 2013-12-08 17:03:36
var nvDate = NVDate(isUsingToday: true);
String someday = nvDate.previousDay().previousWeek().nextDay().stringValue();
NSLog(@"someday %@", someday);
// someday 2013-12-08 17:03:36
https://github.com/novalagung/NVDate/wiki/API-Reference
Feel free to add contribution to this project by fork
-> pull request