• 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: NSDateFormatter bug in timeZone
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSDateFormatter bug in timeZone


  • Subject: Re: NSDateFormatter bug in timeZone
  • From: Alastair Houghton <email@hidden>
  • Date: Mon, 27 Apr 2009 10:27:04 +0100

On 27 Apr 2009, at 02:41, Jon wrote:

it appears there is a bug in Apple's date formatter:

NSDateFormatter *inputFormatter = [[NSDateFormatter alloc] init];
[inputFormatter setDateFormat:@"MMM-dd-yy HH:mm:ss zzz"];
NSDate *theDate = [inputFormatter dateFromString:@"Apr-04-09 10:30:03 PDT"];


this gives the wrong timezone in "theDate"??? (unless of course you happen to be in the PDT timezone) it looks like it ignores the format, and just puts in current time zone.

I'm not sure that things are quite as simple as you think :-)

The problem with the three-letter time zone codes is that many of them are ambiguous. For instance, you might think EST meant UTC-5, whereas an Australian would expect EST to be UTC+10. As a result, you probably need to specify a bit more information rather than just "PDT"; I'm not 100% certain, but the following *might* work:

NSDate *theDate = [inputFormatter dateFromString:@"Apr-04-09 10:30:03 PST8PDT"];

also using the natural language formater properly gives me the correct time Zone, but as soon as you store it in a Data Source, it comes back out with the current time zone, and the time adjusted so that it is correct time at least... but this shouldn't happen? should it.

You can't store something in a data source, at least not for the usual Cocoa meaning of data source. Data sources are a type of delegate object, usually one that you implement yourself (unless you're using bindings, in which case the system does it for you).


Where are you storing the date? And in what form? Are you using bindings or Core Data, or did you implement your own data source object?

Kind regards,

Alastair.

--
http://alastairs-place.net



_______________________________________________

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: NSDateFormatter bug in timeZone
      • From: jon <email@hidden>
    • Re: NSDateFormatter bug in timeZone
      • From: jon <email@hidden>
References: 
 >NSDateFormatter bug in timeZone (From: Jon <email@hidden>)

  • Prev by Date: Re: figuring out which TableView I am?
  • Next by Date: Cocoa application memory leak check
  • Previous by thread: NSDateFormatter bug in timeZone
  • Next by thread: Re: NSDateFormatter bug in timeZone
  • Index(es):
    • Date
    • Thread