The SeismicXML sample code uses NSXMLParser to extract data from a file downloaded from the USGS. The time of an event appears in the file like this,
.....12:34:32Z....

According to rfc 822 'Z' means UTC (or GMT if you prefer).

I find that the NSDate from the parser is tagged as being in the Pacific time zone, my local time zone, while the hours are correct for UTC. That makes it 8 hours off for standard time.

The parser is told that the date format is,
[dateFormatter setDateFormat:@"yyyy-MM-dd'T'HH:mm:ss"];
which seems to ignore the Z and impose local time.

I have tried several variations on that formatting string. They all fail to deliver UTC.

[dateFormatter setDateFormat:@"yyyy-MM-dd' 'HH:mm:ssz"];   //says PDT
[dateFormatter setDateFormat:@"yyyy-MM-dd' 'HH:mm:ssZ"];   //says -0700
[dateFormatter setDateFormat:@"yyyy-MM-dd' 'HH:mm:sszz"];  //says PDT
[dateFormatter setDateFormat:@"yyyy-MM-dd' 'HH:mm:ss"]; //says nothing but still thinks its PDT

No doubt my inexperience with the parser or NSDate is at fault. How do I get the parser to recognize that the time really is UTC?


_______________________________________________

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