• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Cocoa-dev Digest, Vol 5, Issue 2191
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Cocoa-dev Digest, Vol 5, Issue 2191


  • Subject: Re: Cocoa-dev Digest, Vol 5, Issue 2191
  • From: "Kenneth Bruno" <email@hidden>
  • Date: Mon, 22 Dec 2008 14:48:38 -0500

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 (email@hidden)

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:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Cocoa-dev Digest, Vol 5, Issue 2191
      • From: mmalc Crawford <email@hidden>
  • Prev by Date: Re: CharacterAtIndex method?
  • Next by Date: Re: Cocoa-dev Digest, Vol 5, Issue 2191
  • Previous by thread: Re: CharacterAtIndex method?
  • Next by thread: Re: Cocoa-dev Digest, Vol 5, Issue 2191
  • Index(es):
    • Date
    • Thread