billymeltdown / nsdate-helper

A category to extend Cocoa's NSDate class with some convenience functions.
http://www.zetetic.net/blog/
456 stars 107 forks source link

Implement instance methods for returning strings #2

Closed billymeltdown closed 10 years ago

billymeltdown commented 14 years ago

I'm not really sure why I didn't do this in the first place, but this would be a lot easier to use and look a tad nicer if I implemented something like:

NSDate *date = [NSDate date];
NSString *dbString = [date string];
NSString *formattedString = [date stringWithFormat:@"yyyy"];

That last one strikes me as nice-to-have and possibly over-complicating things, but definitely need to get some instance methods going here to replace the need to call class methods in a clumsier fashion, e.g.:

NSString *dbString = [NSDate stringFromDate:date];
NSString *formatted = [NSDate stringFromDate:date withFormat:@"yyyy"];
billymeltdown commented 10 years ago

Done some time ago.