• 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: David Rowland <email@hidden>
  • Date: Tue, 3 Nov 2009 12:56:48 -0800


On Nov 3, 2009, at 12:19 PM, Nick Zitzmann wrote:


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

It still gets the hours right but tags the time zone as -0800 (Pacific).

If you're basing that off of the description of the NSDate, then of course it does; NSDate objects have no knowledge of time zones, so the description shows the date & time as if they were in your time zone.

But NSDate does have a knowledge of time zones. The reason I am doing this it to do some arithmetic on the dates - like this,



NSDate *today = [NSDate date]; NSTimeInterval interval = [today timeIntervalSinceDate:quakeTime]; if (interval < 3600) //within the hour


In this code "today" gets created correctly. The display shows current Pacific hours and an offset of -0800. 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.


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.


_______________________________________________

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: Nick Zitzmann <email@hidden>
    • Re: NSDate / NSXMLParser
      • From: Kyle Sluder <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>)

  • Prev by Date: Maryland (USA) Cocoaheads - Re: [MEET] November CocoaHeads Mac Developer Meetings
  • Next by Date: Re: NSDate / NSXMLParser
  • Previous by thread: Re: NSDate / NSXMLParser
  • Next by thread: Re: NSDate / NSXMLParser
  • Index(es):
    • Date
    • Thread