• 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
Re: NSDate / NSXMLParser
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSDate / NSXMLParser


  • Subject: Re: NSDate / NSXMLParser
  • From: Nick Zitzmann <email@hidden>
  • Date: Tue, 3 Nov 2009 14:16:07 -0700


On Nov 3, 2009, at 1:56 PM, David Rowland wrote:

In this code "today" gets created correctly. The display shows current Pacific hours and an offset of -0800.

Of course it does. NSDate objects are always displayed as if they were in your local time zone; it just prints the time zone in the description just so it's perfectly clear.


However, when I create "interval" by effectively subtracting quakeTime from today, it's wrong because quakeTime is UTC hours plus an erroneous -0800 offset which it picked up from the parser. If the parser would recognize that 'Z' everything would be fine, but I have tried many different ways, and none seem to work.

NSDateFormatter won't pick up on that. You'll have to at least partially parse the string yourself to figure out if you need to use an alternate time zone. I once wrote some code that parses ISO 8601 date-time strings, but I don't have it on me right now... All I remember is I parsed it manually using NSScanner and NSDateComponents, because it was faster and I had better control over handling issues like this.


If you need to encapsulate a time zone in a date, then use NSCalendarDate instead. NSCalendarDate is deprecated, but as of now, it's the only built-in date class that uses time zones.

The documentation says it does not exist in iPhone.

You can probably do this by not encapsulating time zones within dates, but if you need to do that for some reason on the iPhone OS, then you might have to subclass NSDate, override its primitives, and add a timeZone property. I wouldn't recommend this unless you really know what you're doing, though, since NSDate is a class cluster.


Nick Zitzmann
<http://www.chronosnet.com/>



_______________________________________________

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: David Rowland <email@hidden>
References: 
 >NSDate / NSXMLParser (From: David Rowland <email@hidden>)
 >Re: NSDate / NSXMLParser (From: Nick Zitzmann <email@hidden>)
 >Re: NSDate / NSXMLParser (From: David Rowland <email@hidden>)
 >Re: NSDate / NSXMLParser (From: Nick Zitzmann <email@hidden>)
 >Re: NSDate / NSXMLParser (From: David Rowland <email@hidden>)

  • Prev by Date: Re: NSDate / NSXMLParser
  • Next by Date: Re: Handling calculations with many decimal places
  • Previous by thread: Re: NSDate / NSXMLParser
  • Next by thread: Re: NSDate / NSXMLParser
  • Index(es):
    • Date
    • Thread