Re: Representing UTC time in a readable format
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.