The easiest way is to set the timezone on the formatter:

[dateFormatter setTimeZone:[NSTimeZone timeZoneForSecondsFromGMT:0]];


On Nov 3, 2009, at 21:54, David Rowland wrote:

Thanks to all for this useful discussion. I think I have solved my problem by taking the data from the parser as is and then applying a correction for my offset from GMT when I do my arithmetic. Like this,

 int offset = [[NSTimeZone localTimeZone] secondsFromGMT];
 NSDate *today = [NSDate date];
NSTimeInterval interval = [today timeIntervalSinceDate:quakeTime] - offset;
 if (interval < 3600)  //within the hour


That should be valid everywhere and at any time.

I think it's an error that the parser does not pick up the indicated time zone 'Z'. Perhaps there is a way, but I tried a number of formatting strings and none worked.

2009-10-30T18:37:14Z
is a very definite point in time. If the parser picks up 2009-10-30T18:37:14 and interprets it as in the local time zone, that is not definite. It varies according to where you stand, and that is strange for a parser, no?

David

_______________________________________________

Cocoa-dev mailing list ([email protected])

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/in.cocoadev %40iriz.net

This email sent to [email protected]



_______________________________________________

Cocoa-dev mailing list ([email protected])

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 [email protected]

Reply via email to