On Dec 22, 2008, at 2:53 AM, Keith Blount wrote:

> All I want to do is this: I would like to generate the names of all the
> months for a specified year. Then for each month in that year, I would
> like to generate the names of every day. For instance:
> 
> 2009
> - January
> -- Thursday, 1st January 2009
> -- Friday, 2nd January 2009
> ... and so on
> - February
> -- ... etc.

I didn't bother converting the ordinals for you (1st, 2nd, etc) but
here's a relatively simple way to do what you want.  Basically,
NSCalendarDate gets you pretty much what you need:

NSCalendarDate *aDate = [NSCalendarDate dateWithYear:2008 month:1 day:1
hour:0 minute:0 second:0 timeZone:0];

NSLog([aDate descriptionWithCalendarFormat:@"%Y"]);

do
{
        if([aDate dayOfMonth] == 1)
                NSLog([aDate descriptionWithCalendarFormat:@"- %B"]);
        
        NSLog([aDate descriptionWithCalendarFormat:@"-- %A, %e %B %Y"]);
        
        aDate = [aDate dateByAddingYears:0 months:0 days:1 hours:0 minutes:0 
seconds:0];
        
} while([aDate dayOfYear] > 1);
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to