• 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 and Date formatters
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSDate and Date formatters


  • Subject: Re: NSDate and Date formatters
  • From: Adrian Bool <email@hidden>
  • Date: Thu, 15 Jan 2004 14:18:50 +0100

On 15 Jan 2004, at 01:34, Louis C. Sacha wrote:
NSCalendarDate has a method -(void)setTimeZone:(NSTimeZone *)zone, which you should be able to use to set the time zone of the NSCalendarDate to GMT. I haven't tested it, but the following should work the way you want:

/* typed in mail, etc... */

NSCalendarDate *elapsedTime = [NSCalendarDate dateWithTimeIntervalSinceReferenceDate: seconds];
[elapsedTime setTimeZone:[NSTimeZone timeZoneForSecondsFromGMT:0]];
[timeRemainingTextField setObjectValue:elapsedTime] ;

It might be a bit more efficient to store the NSTimeZone instance as an instance variable instead of making a new autoreleased one each time, since you are likely updating the counter every second...

Hi Luis,

Thanks for the suggestion. In the end, seeing that I did not really want to display a date as such - just a time, I created my own very small TimeFormatter class - which just takes an integer in an NSNumber object and displays it in the format I desire... No time zone problems to worry about at all!

Cheers,

aid
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >NSDate and Date formatters (From: Adrian Bool <email@hidden>)
 >Re: NSDate and Date formatters (From: Daniel Todd Currie <email@hidden>)
 >Re: NSDate and Date formatters (From: Adrian Bool <email@hidden>)
 >Re: NSDate and Date formatters (From: "Louis C. Sacha" <email@hidden>)

  • Prev by Date: Re: Saving "objects" & opening them up in a non-document based App
  • Next by Date: Re: xcode/gdb automation
  • Previous by thread: Printing two views in a single print job
  • Next by thread: index of line wrap
  • Index(es):
    • Date
    • Thread