• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
NSDate / NSXMLParser
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSDate / NSXMLParser


  • Subject: NSDate / NSXMLParser
  • From: David Rowland <email@hidden>
  • Date: Tue, 3 Nov 2009 08:26:04 -0800

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@hidden)

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:
This email sent to email@hidden


  • Follow-Ups:
    • Re: NSDate / NSXMLParser
      • From: Chunk 1978 <email@hidden>
    • Re: NSDate / NSXMLParser
      • From: Nick Zitzmann <email@hidden>
  • Prev by Date: Looking for guidance re: password/credential storage and Core Data
  • Next by Date: Re: Apple Remote Control Wrapper sends same button ID for all buttons.
  • Previous by thread: Re: Looking for guidance re: password/credential storage and Core Data
  • Next by thread: Re: NSDate / NSXMLParser
  • Index(es):
    • Date
    • Thread