Re: Remove redundant AM/PM when formatting a time range?
Re: Remove redundant AM/PM when formatting a time range?
- Subject: Re: Remove redundant AM/PM when formatting a time range?
- From: Ben Kazez <email@hidden>
- Date: Tue, 15 Apr 2014 19:12:33 +0200
>> I’m trying to create a compact time range format, like “2am-4pm” or “2-5:30pm”. I am constructing the format string using -dateFormatFromTemplate:options:locale:, omitting the minutes from the template if that component is zero. Is there an internationalization-safe way that I can remove the AM/PM from one of the times if it is redundant? What about the space, if a locale considers that space optional?
>
> Can you do this by making the format strings themselves localizable? For instance you might have special format string IDs for use when both times are AM or both PM, one for the first time and one for the second. The localizer can then decide which of those two format strings should drop the AM/PM indicator.
Hi Jens,
Thanks for the quick reply! This should work great, but do you know if there's a good way to let localizers use the system-provided localized format as a starting point, for more consistency? Perhaps it would be simpler to simply split the formatted time strings on " " -- not the correct solution, to be sure, but it seems to work in a wide range of locales.
Ben
_______________________________________________
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