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

NSCalendarDate -> UTCDateTime


  • Subject: NSCalendarDate -> UTCDateTime
  • From: Matt Ronge <email@hidden>
  • Date: Tue, 30 Apr 2002 19:42:30 -0500

I've been working with getting and setting file dates.

For example I have a number of methods like these:

- (NSDate *)creationDate
{
FSCatalogInfo catalogInfo;
OSErr err;
FSRef tempRef;
NSTimeInterval seconds;
//An epoch is the start of carbon time
NSCalendarDate *epoch = [self epoch];

tempRef = [self getFSRef];
err = FSGetCatalogInfo(&tempRef, kFSCatInfoCreateDate, &catalogInfo,
NULL, NULL, NULL);
seconds = (double)((unsigned long
long)catalogInfo.createDate.highSeconds << 32) +
(double)catalogInfo.createDate.lowSeconds +
(double)catalogInfo.createDate.fraction / 0xffff;
return [epoch addTimeInterval:seconds];
}

//Returns Epoch for use in date methods
- (NSCalendarDate *)epoch;
{
return [NSCalendarDate dateWithYear:1904 month:1 day:1 hour:0 minute:0
second:0 timeZone:[NSTimeZone timeZoneForSecondsFromGMT:0]];
}

A large section of it I got from an earlier post on this list. However, I
now need to set these attributes. Except I have no idea how to turn a
NSCalendarDate into a UTCDateTime struct. I've looked for a specification
for UTCDateTime, but there are none that explain the usages of the members
of the struct. So I can't really "reverse engineer" the code that turns the
struct into the seconds variable that I grabbed from the list.

Please point out in errors I have in my implementation above!

Thanks,
--
Matt Ronge
_______________________________________________
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.

  • Prev by Date: Re: How do I change the default scrolling behavior
  • Next by Date: Notification problem
  • Previous by thread: Re: Notification problem
  • Next by thread: [ANN] RRSpreadSheet BOF release
  • Index(es):
    • Date
    • Thread