HRDate 0.1.1

HRDate 0.1.1

TestsTested
LangLanguage Obj-CObjective C
License MIT
ReleasedLast Release Jul 2016

Maintained by Ivan Shevelev.



HRDate 0.1.1

Forget about NSDateFormatter, NSDateComponents, NSTimeZone brainf%ck for get simple data from NSDate. HRDate is a simple API for NSDate!

Usage

Constants(like a seconds in hour):

extern NSUInteger const HRDateHoursInDay;
extern NSUInteger const HRDateMinutesInHour;
extern NSUInteger const HRDateMinutesInDay;
extern NSUInteger const HRDateSecondsInMinute;
extern NSUInteger const HRDateSecondsInHour;
extern NSUInteger const HRDateSecondsInDay;

Date Comparing:

-(BOOL)hrIsEqualToDateIgnoringTime:(nonnull NSDate *)date;

-(BOOL)hrIsToday;

-(BOOL)hrIsTomorrow;

-(BOOL)hrIsYesterday;

Get ALL! date components from date:

@property (nonatomic, readonly) NSInteger hrEra;
@property (nonatomic, readonly) NSInteger hrDay;
@property (nonatomic, readonly) NSInteger hrMonth;
@property (nonatomic, readonly) NSInteger hrYear;
@property (nonatomic, readonly) NSInteger hrHour;
@property (nonatomic, readonly) NSInteger hrMinute;
@property (nonatomic, readonly) NSInteger hrSecond;
@property (nonatomic, readonly) NSInteger hrWeekday;
@property (nonatomic, readonly) NSInteger hrWeekdayOrdinal;
@property (nonatomic, readonly) NSInteger hrWeekOfMonth;
@property (nonatomic, readonly) NSInteger hrWeekOfYear;
@property (nonatomic, readonly) NSInteger hrYearForWeekOfYear;
@property (nonatomic, readonly) NSInteger hrNanosecond;
@property (nonatomic, readonly, nonnull) NSTimeZone *hrTimeZone;
@property (nonatomic, readonly, nonnull) NSCalendar *hrCalendar;

A lot of NSDate new factory methods:

-(nonnull NSDate *)hrDateAfterDays:(NSInteger)days;

-(nonnull NSDate *)hrDateAfterHours:(NSInteger)hours;

+(nonnull NSDate *)hrYesterday;

+(nonnull NSDate *)hrTomorrow;

+(nullable NSDate *)hrDateFromString:(nonnull NSString *)string withDateFormat:(nonnull NSString *)dateFormat;

+(nullable NSDate *)hrDateFromString:(nonnull NSString *)string withDateStyle:(NSDateFormatterStyle)dateStyle andTimeStyle:(NSDateFormatterStyle)timeStyle;

//this method is awesome!
+(nullable NSDate *)hrDateWithHour:(NSUInteger)hour minute:(NSUInteger)minute second:(NSUInteger)second day:(NSUInteger)day month:(NSUInteger)month andYear:(NSUInteger)year;

//this method is awesome!
+(nullable NSDate *)hrDateWithDay:(NSUInteger)day month:(NSUInteger)month andYear:(NSUInteger)year;

+(nullable NSDate *)hrDateWithHourDifference:(NSInteger)hourDifference;

And date strings ofc:

-(nullable NSString *)hrDateStringWithDateFormat:(nonnull NSString *)dateFormat;

-(nonnull NSString *)hrDateStringWithDateStyle:(NSDateFormatterStyle)dateStyle andTimeStyle:(NSDateFormatterStyle)timeStyle;

For NSDateFormatter, NSTimeZone, NSDateComponents and NSCalendar features, see documentation.

Requirements

iOS 8.0 or higher.

Installation

HRDate is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "HRDate"

Author

Ivan Shevelev, [email protected]

License

HRDate is available under the MIT license. See the LICENSE file for more info.