• 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: Displaying a scaling, relative time or date
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Displaying a scaling, relative time or date


  • Subject: Re: Displaying a scaling, relative time or date
  • From: "Gary L. Wade" <email@hidden>
  • Date: Thu, 08 Jan 2015 06:43:24 -0800

When it comes to any localized date or number formatters, see if ICU supports it, especially the included version on the earlier OS you need to support. If not but a later one does, you could just include it in your app.
--
Gary L. Wade (Sent from my iPad)
http://www.garywade.com/

> On Jan 7, 2015, at 4:52 PM, Ken Thomases <email@hidden> wrote:
>
>> On Jan 7, 2015, at 6:18 PM, Graham Cox <email@hidden> wrote:
>>
>> I want a label in my interface to display a relative time using a "sensible" approximate scale depending on the value. I'm not sure if I can use NSDateFormatter for this - it seems it's a bit too fixed in using only the units you assign.
>>
>> For example, if the value is less than a minute, it should say "x seconds ago", if it's in the range of 1-59 minutes, "x minutes ago", "about an hour ago", "x hours ago", "yesterday", "x days ago", "about a week ago", "x weeks ago", "about a month ago", "x months ago" - you get the picture. Is this possible using NSDateFormatter, or do I have to roll my own for this?
>
> If you can require 10.10 or iOS 8, there's a new class for this: NSDateComponentsFormatter.  There's no class reference for it yet.  It's described in the Foundation release notes <https://developer.apple.com/library/mac/releasenotes/Foundation/RN-Foundation/#10_10Formatters> and in its header file.
>
> If you can't require those versions of the OSes, then I think you have to roll your own.  Or find a third-party library/framework/class.
>
> Regards,
> Ken

_______________________________________________

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: Displaying a scaling, relative time or date
      • From: Jens Alfke <email@hidden>
References: 
 >Displaying a scaling, relative time or date (From: Graham Cox <email@hidden>)
 >Re: Displaying a scaling, relative time or date (From: Ken Thomases <email@hidden>)

  • Prev by Date: Re: Am I Reinventing the Wheel? (Part I)
  • Next by Date: Re: Am I Reinventing the Wheel? (Part I)
  • Previous by thread: Re: Displaying a scaling, relative time or date
  • Next by thread: Re: Displaying a scaling, relative time or date
  • Index(es):
    • Date
    • Thread