SC 4.8 Dates

Need help with a script? This is the place to discuss how to get your code running!

SC 4.8 Dates

Postby sctell » Mon Apr 30, 2018 10:18 am

Does anyone know the reference date in SuperCard.

I am building an external that references SC seconds but NSDate works from a different date than Carbon

You can use another reference date which is why i need to know.

Thanks

Terry
sctell
 
Posts: 1150
Joined: Sun Jul 06, 2008 10:41 am

Re: SC 4.8 Dates

Postby Mike » Mon Apr 30, 2018 3:55 pm

SuperCard seconds are from: 12:00 AM January 1, 1904.

I believe the offset between SuperCard seconds and UNIX is 2082844800
Mike Yenco
YENCO.COM
User avatar
Mike
 
Posts: 217
Joined: Sun Jul 06, 2008 8:54 am
Location: Massachusetts, USA

Re: SC 4.8 Dates

Postby sctell » Mon Apr 30, 2018 10:26 pm

Mike wrote:SuperCard seconds are from: 12:00 AM January 1, 1904.

I believe the offset between SuperCard seconds and UNIX is 2082844800


Thanks Mike,

I did figure out how many years by letting my external do it's thing with NSDate and then comparing with SC's Date giving a difference of 66 years. Converting dates with seconds is not straightforward because of leap years etc but Cocoa takes care of all that for you. Here is my Cocoa function (if anyone is interested) that takes a SC date in seconds as a sting and converts it to a Cocoa NSDate as a string.

Code: Select all
-(NSString*)formatDateWithString:(NSString*)tString
{
    float tTempDouble = [tString doubleValue];
    NSDate* tDate = [NSDate dateWithTimeIntervalSince1970:tTempDouble];
   
    NSDateComponents* tCorrectSCDate = [NSDateComponents new];
    tCorrectSCDate.year = -66;
    NSDate *tCorrectDate = [[NSCalendar currentCalendar] dateByAddingComponents:tCorrectSCDate toDate:tDate options:0];

    NSString* tDateString = [pDateFormat stringFromDate:tCorrectDate];
    return tDateString ;
}


All the best

Terry
sctell
 
Posts: 1150
Joined: Sun Jul 06, 2008 10:41 am


Return to Scripting in SuperTalk

Who is online

Users browsing this forum: No registered users and 1 guest