[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[MacPerl] "Epoch-making difference"--time()



Dear Matthias and All Mac-perl users,

My name is Dan Kogai, a network consultant who uses perl intensively on busi
ness.  My choice of Internet client is a Mac and server Unix  I recently dow
nloaded MacPerl 5.07r1m and instantly it hit my soul--it is one of the best
perl implementations! (I only wish it had a perl-specific text editor window
like MacGambit for scheme).

  The problem arose when I tested newtimelocal.pl, an improved version of ti
melocal.pl that comes with every Perl including MacPerl (you can get the cur
rent version via http://www.dnsa.or.jp/~dankogai/newtimelocal).  I tested th
e compatibility of newtimelocal with the original, old timelocal.pl (with ch
eat!) and found that while localtime() was compatible, gmtime() was not.

  I took a look at the code and output carefully and found the "epoch-making
difference"; Perl's time() was supposed to return seconds since 1970/01/01 (
or Epoch) like time() of Unix system call.  Mac's time(), on the other hand,
returns seconds since 1904/01/01 just like that of toolbox and HyperTalk's "
the seconds".  as a result timegm() of my newtimelocal.pl was off 2082877200
seconds, or whatever &timegm(0,0,0,1,0,70) of original timelocal.pl returns.

  I first thought of rewriting newtimelocal.pl so that it is compatible with
Mac's time() (The crude way to do so is to add 2082877200 to the result of "
unix" timelocal when $[ =~ /Mac/).  But perl's manual was quite clear its Ep
och, mother of all time, is 1970/01/01.

  So I would like to ask you guys this;  should time() of MacPerl be correct
ed or leave it as is?.  I think the best way to go is to correct time() of M
acPerl and add mactime() function which returns seconds since MacEpoch, 1904
/01/01.  Tell me what you think.

Dan the Man with Too Many Perl implementations to play with [96.04.03 JST]