Re: Displaying a scaling, relative time or date
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