Created
April 19, 2012 15:13
-
-
Save zachwaugh/2421586 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// static var to store shared date formatter | |
static NSDateFormatter *_formatter = nil; | |
@implementation NSDate (Extras) | |
// Simple comparison, create a string from today and date, see if they're the same | |
- (BOOL)isToday | |
{ | |
// Lazy load and cache formatter, date formatters are slow to init | |
if (!_formatter) | |
{ | |
_formatter = [[NSDateFormatter alloc] init]; | |
[_formatter setTimeStyle:NSDateFormatterNoStyle]; | |
[_formatter setDateStyle:NSDateFormatterShortStyle]; | |
} | |
// Do stuff with formatter... | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment