• 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: Representing UTC time in a readable format
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Representing UTC time in a readable format


  • Subject: Re: Representing UTC time in a readable format
  • From: Malte Tancred <email@hidden>
  • Date: Fri, 4 Jun 2004 22:12:30 +0200

On 4 jun 2004, at 20.23, Jeremy Dronfield wrote:
All of which is academic, ...

I agree.

... however, since all I'm asking for is guidance on how to turn the value returned by the Carbon function GetUTCDateTime into a readable date.

But why can't you use NSDate? Or perhaps better, NSCalendarDate? In your initial mail you asked:

How can I translate this into a standard human-readable representation of UTC time? I'm not clear about the relationship between the high and low bits, and which I should use.

Why not create an NSCalendarDate and set the time zone. Then you simply print the calendar date.

I just ran this:

#import <Foundation/Foundation.h>

int main() {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSCalendarDate *date = [NSCalendarDate date];
NSLog(@"Date's default time zone: %@", [date timeZone]);
NSLog(@"Date with default time zone: %@", date);

[date setTimeZone:[NSTimeZone timeZoneWithName:@"UTC"]];
NSLog(@"New time zone: %@", [date timeZone]);
NSLog(@"Date with new time zone: %@", date);
[pool release];
exit(0);
return 0;
}

The ouput for me (in Sweden):

2004-06-04 22:06:27.777 utc[501] Date's default time zone: <CFTimeZone 0x505c70 [0xa01900e0]>{name = Europe/Stockholm; abbreviation = CEST; GMT offset = 7200; is DST = true}
2004-06-04 22:06:27.783 utc[501] Date with default time zone: 2004-06-04 22:06:27 +0200
2004-06-04 22:06:27.807 utc[501] New time zone: <CFTimeZone 0x5081d0 [0xa01900e0]>{name = UTC; abbreviation = UTC; GMT offset = 0; is DST = false}
2004-06-04 22:06:27.809 utc[501] Date with new time zone: 2004-06-04 20:06:27 +0000

Regards,
Malte

--
Malte Tancred
Computer Programmer
Oops AB, http://oops.se/
_______________________________________________
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.


  • Follow-Ups:
    • Re: Representing UTC time in a readable format
      • From: Jeremy Dronfield <email@hidden>
References: 
 >Representing UTC time in a readable format (From: Jeremy Dronfield <email@hidden>)
 >Re: Representing UTC time in a readable format (From: j o a r <email@hidden>)
 >Re: Representing UTC time in a readable format (From: Jeremy Dronfield <email@hidden>)
 >Re: Representing UTC time in a readable format (From: Malte Tancred <email@hidden>)
 >Re: Representing UTC time in a readable format (From: Jeremy Dronfield <email@hidden>)
 >Re: Representing UTC time in a readable format (From: Andreas Mayer <email@hidden>)
 >Re: Representing UTC time in a readable format (From: Jeremy Dronfield <email@hidden>)

  • Prev by Date: Fwd: NSImageView's images are invisible until clicked
  • Next by Date: Project Builder and 10.1
  • Previous by thread: Re: Representing UTC time in a readable format
  • Next by thread: Re: Representing UTC time in a readable format
  • Index(es):
    • Date
    • Thread