• 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: Getting relative day-of-week name?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Getting relative day-of-week name?


  • Subject: Re: Getting relative day-of-week name?
  • From: Jon Hull <email@hidden>
  • Date: Wed, 24 Feb 2010 17:08:14 -0800

I wrote a fully localized calendar control for 10.2 (even supported
Japanese properly :-), but stopped supporting it when apple came out with
their own official calendar control.  At the time I had to roll my own to
get the best behavior.  It is really easy to do though...

For yesterday, today, and tomorrow you just use the built in natural
language formatter. For less than 7 days, you use the localized day of the
week (%A). I used a "month day" (%B %e) format for a few months after that
(unless there was a year break), and then a "month day, year" (%b %e,%Y)
format for anything too far out in the future, past the new year, or
anything before yesterday.

Basically, you are building a custom formatter that passes the problem to
different built-in formatters depending on how far away the date is.  My
primary computer is in the shop or I would post the code (I'll try to
remember when I get it back).  You should be able to figure it out for
yourself though... it is only 2 methods IIRC.  Might be a little different
with the new date objects though, haven't looked at it in a while (I think
you have to use unicode syntax now, but the theory should be the same).

Thanks,
Jon


On Wed, 24 Feb 2010 12:04:45 -0800, Rick Mann <email@hidden>
wrote:
> I'd like to take an NSDate and get a relative day-of-week name. For
> example, if today is 2/24, and the NSDate is some time on 2/23, it would
be
> "Yesterday." If the NSDate were 2/22, it would be "Monday."
>
> Is there an existing format specifier for this (fully localized, etc)? Or
> must I roll my own for this?
>
>

_______________________________________________

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: Getting relative day-of-week name?
      • From: Rick Mann <email@hidden>
References: 
 >Getting relative day-of-week name? (From: Rick Mann <email@hidden>)

  • Prev by Date: Re: Stuck on NSTreeController bindings
  • Next by Date: Re: Getting relative day-of-week name?
  • Previous by thread: Re: Getting relative day-of-week name?
  • Next by thread: Re: Getting relative day-of-week name?
  • Index(es):
    • Date
    • Thread