Skip to content

Instantly share code, notes, and snippets.

@notjosh
Created November 9, 2011 13:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save notjosh/1351451 to your computer and use it in GitHub Desktop.
Save notjosh/1351451 to your computer and use it in GitHub Desktop.
NSDate+Comparison - adios NSOrdered*
//
// NSDate+Comparison.h
//
// Created by Joshua May on 4/11/11.
// Copyright (c) 2011 Joshua May. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface NSDate (Comparison)
- (BOOL)isBeforeDate:(NSDate *)date;
- (BOOL)isAfterDate:(NSDate *)date;
- (BOOL)isSameAsDate:(NSDate *)date;
@end
//
// NSDate+Comparison.m
//
// Created by Joshua May on 4/11/11.
// Copyright (c) 2011 Joshua May. All rights reserved.
//
#import "NSDate+Comparison.h"
@implementation NSDate (Comparison)
- (BOOL)isBeforeDate:(NSDate *)date {
return (NSOrderedAscending == [self compare:date]);
}
- (BOOL)isAfterDate:(NSDate *)date {
return (NSOrderedDescending == [self compare:date]);
}
- (BOOL)isSameAsDate:(NSDate *)date {
return (NSOrderedSame == [self compare:date]);
}
@end
@johankool
Copy link

You're missing two methods. :-)

- (BOOL)isBeforeOrSameAsDate:(NSDate *)date;
- (BOOL)isAfterOrSameAsDate:(NSDate *)date;

@ijansch
Copy link

ijansch commented Apr 19, 2012

  • (BOOL)isSafeForDeLoreanTimeJump;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment