Re: Using NSDateFormatter, and sorting issues
Re: Using NSDateFormatter, and sorting issues
- Subject: Re: Using NSDateFormatter, and sorting issues
- From: Deborah Goldsmith <email@hidden>
- Date: Fri, 17 Feb 2006 17:26:28 -0800
NSDateFormatter is not really the right thing to use for durations,
because it's going to wrap around at 24 hours (you can't have more
than 24 hours in a time of day).
You could work around the time zone issue by making an NSTimeZone for
UTC (GMT) and attaching that to the NSDateFormatter, but there's no
workaround for the 24 hour limitation.
Unfortunately, there is not good support in Mac OS X for formatting
durations right now. It's recognized as an issue. Of course, having
another bug report from an external developer never hurts. :-)
The best workaround I can think of right now involves getting the
medium time format string, parsing it to find the separator
character, and then constructing the duration yourself. That should
work for nearly all locales. Make sure you use an NSNumberFormatter
for the components of the duration so that you get native digits (not
necessarily ASCII).
Deborah Goldsmith
Internationalization, Unicode liaison
Apple Computer, Inc.
email@hidden
On Feb 17, 2006, at 2:35 PM, Tom Jones wrote:
I have an app that reads a tab-delimited file into an NSDictionary.
One of the pieces of data in the file is the elapsed time in seconds,
I want to display this in this format HH:MM:SS, so I attached a
NSDateFormatter to the column. Unfortunately the results I get are not
at all what I expected. For instance if my data was 75 seconds, it's
displayed as 18:01:15...my guess is that it's taking six hours off the
time because I am at GMT -6. How do I stop it from doing this?
The second issue is I can't get my numeric data to sort correctly, I
tried padding the numbers with 0's(in the format string), but it still
puts 011 before 002. Any ideas?
_______________________________________________
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
_______________________________________________
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