NSDateFormatter time zone not "sticking"?
NSDateFormatter time zone not "sticking"?
- Subject: NSDateFormatter time zone not "sticking"?
- From: Doug Knowles <email@hidden>
- Date: Tue, 20 Sep 2005 16:36:02 -0400
Hi, all,
I'm trying to display a table with a date column which renders dates
in a specific time zone (not the current time zone of the system).
My table column is bound to an NSDate value, and the NSTableColumn has
an NSDateFormatter configured appropriately. I've created an outlet
in my window controller that is connected to the NSDateFormatter, so I
have programmatic access to the formatter.
When I reload the data for the table, I invoke setTimeZone: on the
date formatter with the appropriate time zone; however, the dates are
always displayed in the current time zone of my system. The absolute
times are correct; they're just not adjusting for the time zone (i.e.,
it shows sunrise in England as 1:55AM US/Eastern).
When I try some logging for debugging, it appears that NSDateFormatter
is ignoring my setTimeZone calls:
// update the time zone of the date formatter
NSTimeZone *tz = [NSTimeZone timeZoneWithName:[currentStation timeZoneStr]];
NSLog( @"...setting time zone to %@", tz );
[ibTideTableDateFormatter setTimeZone:tz];
NSLog( @"...reading back time zone as %@", [ibTideTableDateFormatter
timeZone] );
...yields:
2005-09-20 16:30:26.965 OSXTide[22333] ...setting time zone to
Europe/London (BST) offset 3600 (Daylight)
2005-09-20 16:30:26.965 OSXTide[22333] ...reading back time zone as
Local Time Zone [US/Eastern (EDT) offset -14400 (Daylight)]
Explicitly retaining the NSTimeZone object (which didn't seem like it
should be necessary) didn't affect the results.
I see NSCalendarDate supports a time zone specification; should I be
using it in place of NSDate?
Thanks in advance...
Doug K;
_______________________________________________
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