Date formatting
Date formatting
- Subject: Date formatting
- From: Ryan McGann <email@hidden>
- Date: Fri, 26 Sep 2003 11:42:04 -0700
I've had this question for a while, and it's starting to really bother me. What is the correct way to format dates in Cocoa?
We have an NSTableView with a column that displays dates, and we want to display the date (when in English) as something like 9/26/2003 12:24 pm. Ideally, it would also display today as "Today 12:24pm" like it did when our application was in Carbon, but since I'm not sure that's possible in Cocoa automatically, I'll just drop it for now.
If we attach an NSDateFormatter to the column, and set its custom format to %m/%d/%y %I:%M %p, everything is fine in English...that ignores the user's preference for the 12/24 hour clock, but I can live with it. But in Japanese, the time shows up in a 12 hour clock without the AM/PM. Makes sense, so I try constructing the formatter on the fly, by combining NSShortDateFormatString and NSTimeFormatString. But NSTimeFormatString doesn't contain the AM/PM, and contains the seconds.
It seems like in Carbon, this came out exactly how I wanted it no matter what language and no matter what the user's settings were for the 12/24 hour clock. How can I get this column to display correctly in any language using the format that I want, and conforms to the user's International locale settings?
Thanks,
Ryan
email@hidden
_______________________________________________
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.