On Jan 7, 2015, at 6:18 PM, Graham Cox <graham....@bigpond.com> 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 (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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com