There are cases where that's totally appropriate. Maybe in a report it requires a leading zero. You still want to respect the user's settings in all other areas.

On Aug 11, 2009, at 11:48 AM, Sean McBride wrote:

On 8/11/09 6:39 PM, Houdah - ML Pierre Bernard said:

I am trying to format dates for display. So far I have been using this
formatter:

        NSDateFormatter *dateFormatter = [[[NSDateFormatter alloc] init]
autorelease];
        
        [dateFormatter setFormatterBehavior:NSDateFormatterBehavior10_4];
        [dateFormatter setDateStyle:NSDateFormatterShortStyle];
        [dateFormatter setTimeStyle:kCFDateFormatterMediumStyle];


Now, I want to add leading zeros to days and month values. It seems
there is no way of teaching the above formatter to do so. It goes with
whatever format the user has set in System Preferences.

Thus I am trying the below formatter:

        NSDateFormatter *dateFormatter = [[[NSDateFormatter alloc] init]
autorelease];
        
        [dateFormatter setFormatterBehavior:NSDateFormatterBehavior10_4];
        [dateFormatter setDateFormat:@"dd/mm/yy hh:MM:ss a"];

This works fine, except for the fact that I have now hardcoded the
fact that I display day/month/year rather than month/day/year.

It would seem that NSLocale should know about the user's preferences.
Yet I can find no way to query it for date format.

So you want to use the user's preference and yet you don't. The choice
of leading zeros or no is part of the user's choice.  But if you must,
you could get the user's format string and carefully alter it to add
leading zeros.

--
____________________________________________________________
Sean McBride, B. Eng                 s...@rogue-research.com
Rogue Research                        www.rogue-research.com
Mac Software Developer              Montréal, Québec, Canada


_______________________________________________

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:
http://lists.apple.com/mailman/options/cocoa-dev/alex%40webis.net

This email sent to a...@webis.net

Alex Kac - President and Founder
Web Information Solutions, Inc.

"There will always be death and taxes; however, death doesn't get worse every year."
-- Anonymous




_______________________________________________

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to