Re: Thoroughly confused on date formatting
Re: Thoroughly confused on date formatting
- Subject: Re: Thoroughly confused on date formatting
- From: Mike Abdullah <email@hidden>
- Date: Thu, 28 Sep 2006 22:06:12 +0100
I want the user's preferred format, but without any sort of seconds
setting, regardless of whether the user's settings specify seconds or
not.
The value I'm setting has no seconds value so it is pointless to
display it to the user. Honestly, NSDatePicker gets it just right
On 28 Sep 2006, at 20:24, Nir Soffer wrote:
On Sep 28, 2006, at 11:24 AM, Mike Abdullah wrote:
In my app, I want to have an NSTextField for formatting times
only. I see that NSDateFormatter (the 10.4 version) has the
ability to do this using the setTimeStyle: method
I need to display hours and minutes only. I could just force the
user to my chosen format, but I'd rather they have their own
choice of 12/24 hour clock etc.
I figured that the NSDateFormatterShortStyle constant would pull
what I needed, but the docs say:
"The format for these date and time styles is not exact because
they depend on the locale, user preference settings, and the
operating system version. Do not use these constants if you want
an exact format."
So, if I want to set a date formatter up to display hours and
minutes only, where can I reliably pull this information from?
Will I have to take the user's preference from NSUserDefaults and
manually parse it? NSDatePicker seems to manage things properly
by itself!
I understand it like this:
1. If you want the user format, use style. If you use "short" time
style, most users will get the default short time format, because
most users do not change preferences. there is statistics about 90%
of users never changing defaults, but I don't know it it is correct
for mac users (probably not). Users that have changed the short
style (see System Preferences > International > Format > Customize)
will get exactly what they see as correct short style, which can be
anything.
2. If you want specific format, use the ICU library format string.
The user will get exactly what you define.
See http://icu.sourceforge.net/userguide/formatDateTime.html
Best Regards,
Nir Soffer
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden