Time, a question to the mach-o os-x carbon users (3.2.1)
John M McIntosh
johnmci at smalltalkconsulting.com
Thu Jan 17 21:24:19 UTC 2002
Now it seems I got a note from a squeaker that let me know on his
machine when he starts Squeak up a Time now or the clock morphic runs
about 51 minutes slow as compared to what the Finder shows in the
menu bar. Hint he is somewhere near
Boulogne Billancourt Cedex, FR
heh? if it was an hour diff, or he was in newfoundland well I could
understand a time zone thing, but 51 minutes? So do I have another
Squeaker or two who I suspect is running the french version of OS-X
(10.1.2 btw) out there to see if they can recreate the problem? Let
alone anyone else who can report werid Time values?
Now the macintosh C code which I bet is older than my 9 year old is.
int ioSeconds(void) {
struct tm timeRec;
time_t time1904, timeNow;
/* start of ANSI epoch is midnight of Jan 1, 1904 */
timeRec.tm_sec = 0;
timeRec.tm_min = 0;
timeRec.tm_hour = 0;
timeRec.tm_mday = 1;
timeRec.tm_mon = 0;
timeRec.tm_year = 4;
timeRec.tm_wday = 0;
timeRec.tm_yday = 0;
timeRec.tm_isdst = 0;
time1904 = mktime(&timeRec);
timeNow = time(NULL);
/* Squeak epoch is Jan 1, 1901, 3 non-leap years earlier than
ANSI one */
return (timeNow - time1904) + (3 * 365 * 24 * 60 * 60);
}
Under Unix we do
time_t convertToSqueakTime(time_t unixTime)
{
#ifdef HAVE_TM_GMTOFF
unixTime+= localtime(&unixTime)->tm_gmtoff;
#else
# ifdef HAVE_TIMEZONE
unixTime+= ((daylight) * 60*60) - timezone;
# else
# error: cannot determine timezone correction
# endif
#endif
/* 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);
}
/* returns the local wall clock time */
int ioSeconds(void)
{
return convertToSqueakTime(time(0));
}
--
--
===========================================================================
John M. McIntosh <johnmci at smalltalkconsulting.com> 1-800-477-2659
Corporate Smalltalk Consulting Ltd. http://www.smalltalkconsulting.com
===========================================================================
More information about the Squeak-dev
mailing list
|