Latest 1.2.2
Homepage https://github.com/Bogdan-Stasjuk/NSDate-Helpers
License MIT
Platforms ios 6.0, requires ARC
Authors

NSDate-Helpers

Category on NSDate that includes useful methods for work with date and time.

There are ENUMs for TimeZone and DateFormat:

typedef NS_ENUM(NSUInteger, NSDateTimeZone) {
    NSDateTimeZoneUTC,
    NSDateTimeZoneGMT,
};

typedef NS_ENUM(NSUInteger, NSDateFormat) {
    NSDateFormatHm24,
    NSDateFormatHms24,
    NSDateFormatDmy4,
    NSDateFormatDmy4Hm24,
};

And constants for often used time intervals in seconds:

static NSUInteger const BSMinute    = 60;
static NSUInteger const BSHour      = 3600;
static NSUInteger const BSDay       = 86400;
static NSUInteger const BSWeek      = 604800;
static NSUInteger const BSYear      = 31556926;

Static methods

+ (NSDictionary *)timeZoneAbbreviations;
+ (NSTimeZone *)timeZone:(NSDateTimeZone)timeZone;
+ (NSDateFormatter *)dateFormatterWithFormat:(NSDateFormat)format andTimeZone:(NSDateTimeZone)dateTimeZone;

+ (NSString *)stringFromDate:(NSDate *)date withFormat:(NSDateFormat)format andTimeZone:(NSDateTimeZone)timeZone;
+ (NSDate *)dateFromString:(NSString *)string withFormat:(NSDateFormat)format andTimeZone:(NSDateTimeZone)dateTimeZone;

+ (NSDate *)dateWithoutTime:(NSDate *)dateTime;
+ (NSDate *)nowPlusDays:(NSUInteger)day;

Nonstatic methods

- (BOOL)isEqualToDateIgnoringTime:(NSDate *)otherDate;

Demo

Clone project and run it. You can find examples of usage at NSDateHelpersUsingViewController.m.

Compatibility

This class has been tested back to iOS 6.0.

Installation

Cocoapods: pod 'NSDate+Helpers'
Manual: Copy the NSDate+Helpers folder in your project

Import header in your project. .pch is a good place ;)

#import "NSDate+Helpers.h"

License

This code is released under the MIT License. See the LICENSE file for
details.

Latest podspec

{
    "name": "NSDate+Helpers",
    "version": "1.2.2",
    "summary": "A category on NSDate that extends NSDate class functionality.",
    "description": "NSDate class's cetogory that adds useful methods for work with date and time.",
    "homepage": "https://github.com/Bogdan-Stasjuk/NSDate-Helpers",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Bogdan Stasjuk": "[email protected]"
    },
    "source": {
        "git": "https://github.com/Bogdan-Stasjuk/NSDate-Helpers.git",
        "tag": "1.2.2"
    },
    "social_media_url": "https://twitter.com/Bogdan_Stasjuk",
    "platforms": {
        "ios": "6.0"
    },
    "requires_arc": true,
    "source_files": "NSDate+Helpers/*.{h,m}",
    "public_header_files": "NSDate+Helpers/*.h"
}

Pin It on Pinterest

Share This