NSDateFormatter, Interface Builder, and System Preference date formats
NSDateFormatter, Interface Builder, and System Preference date formats
- Subject: NSDateFormatter, Interface Builder, and System Preference date formats
- From: "Sean McBride" <email@hidden>
- Date: Sun, 1 Aug 2004 12:35:07 -0400
Hello,
The classic Mac OS Toolbox APIs allowed the creation (and Carbon still
does) of 3 forms of date strings, specified by the DateForm typedef:
shortDate, longDate, and abbrevDate. These APIs created strings that
matched the user's preferred date formatting. It was easier to use these
than rolling your own.
To this day (10.3.4), System Preferences' "International" pane allows a
user to customise the display of these 3 forms, and shows 3 example date
strings at the bottom.
Now I don't have much Cocoa experience, but it seems to me that things
have been tuned upside down!
In Interface Builder, adding an NSDateFormatter doesn't seem to provide a
way to get these 3 forms, instead there are a list of strftime-style
format strings like "%m/%d/%y" which hardcode a form that is not
necessarily the users preferred form. AFAICT, only "%c" uses the user's
preferences. Yes, you can use a custom format like "%x", but I still
don't see any format string that gets me the 3 forms. The list of format
strings is here:
<
http://developer.apple.com/documentation/Cocoa/Conceptual/
DataFormatting/Concepts/DateFormatters.html#//apple_ref/doc/uid/20000194/
CJBFEHBD>
Even if I have just missed them, it's unfortunate that IB's UI is the way
it is. I suspect it leads to developers choosing their own favourite
format and users having to deal with dates being different in every app.
And yes, I have filed a bug about this: <rdar://2803021>. 3 years ago!!
I see that NSUserDefaults has NSDateFormatString, which seems to
correspond to longDate; and NSShortDateFormatString which seems to
correspond to shortDate; but I see nothing that corresponds to
abbrevDate. In any case, how can I make use of these from IB? Or are
they only available programatically?
So anyway, my question is: how do I make my NSDateFormatter display an
abbrevDate? Something like "%b %d, %Y" but using the users customisations.
Thanks!
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.