iSqueak Wikki : ioSeconds

HomePage :: Categories :: PageIndex :: RecentChanges :: RecentlyCommented :: Login/Register

sqInt ioSeconds(void)


Parms: NONE
return: seconds
From: Interpreter
Why:
return number of seconds since January 1, 1901 as an integer

Responsibility:
sqInt primitiveSecondsClock(void)

MacIntosh
os-9/OSXCarbon
Uses unix code

Cocoa:
TBD

iPhone
uses unix code

Unix
int ioSeconds(void) {
time_t unixTime;

unixTime = time(0);
unixTime += localtime(&unixTime)->tm_gmtoff;
/* Squeak epoch is Jan 1, 1901. Unix epoch is Jan 1, 1970: 17 leap years
and 52 non-leap years later than Squeak. */
return unixTime + ((52*365UL + 17*366UL) * 24*60*60UL);
}

Windows
GetLocalTime(&sysTime), then convert to squeak epoch

BUGS
And when do 32bits overflow?

There are no comments on this page. [Add comment]

Valid XHTML 1.0 Transitional :: Valid CSS :: Powered by WikkaWiki
Page was generated in -0.9659 seconds