Latest 0.1.1
Homepage https://github.com/ivanshevelev/HRDate
License MIT
Platforms ios 8.0, osx 10.9, tvos 9.0, watchos 2.0, requires ARC
Frameworks Foundation
Authors

Version
License
Platform

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.

Latest podspec

{
    "name": "HRDate",
    "version": "0.1.1",
    "summary": "HRDate is a set of categories for simple date management.",
    "description": "NSDate, NSDateFormatter, NSDateComponents, NSTimeZone and NSCalendar categories.",
    "homepage": "https://github.com/ivanshevelev/HRDate",
    "license": "MIT",
    "authors": {
        "Ivan Shevelev": "[email protected]"
    },
    "source": {
        "git": "https://github.com/ivanshevelev/HRDate.git",
        "tag": "0.1.1"
    },
    "social_media_url": "https://twitter.com/antsy_ivan",
    "platforms": {
        "ios": "8.0",
        "osx": "10.9",
        "tvos": "9.0",
        "watchos": "2.0"
    },
    "requires_arc": true,
    "source_files": "Pod/Classes/**/*",
    "public_header_files": "Pod/Classes/**/*.h",
    "frameworks": "Foundation"
}

Pin It on Pinterest

Share This