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

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



In message <199604040924.SAA11067@jms.jeton.or.jp> Dan Kogai writes:
>At 01:18 96.04.04, Matthias Ulrich Neeracher wrote:

>>>[...].  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.
>
>  Sorry.  You are right and so is Mac's time().  It is just a matter of Epoc
>h and ANY Epoch is bound to be relative unless we set the Epoch to the very
>moment of Big Bang.  (I wonder how large the int must be to implement such s
>cale of time.  Even quadword looks not big enough).

Hmm, I thought the age of the universe was commonly considered to be around
10E10 years, give or take one order of magnitude. Since a year has about
Pi*10E7 seconds, 10E18 seconds should be enough, and a quadword easily holds
10E19 seconds.

>   Your view, IMHO, is quite reasonabile and for the time being, I'll rewrit
>e newtimelocal.pl and other releated time-releated libraries of mine to be M
>acPerl compatible.  Now the question is, what is the best way to find whethe
>r the code is running on MacPerl or not.  In the previous mail I said I can
>do so by checking the value of $[, but this can be easily tricked by renamin
>g the application.  Another way to go is the check the value of $ENV{'MACPER
>L'}; if empty it's not MacPerl.  But is this a guaranteed way?

The current answer to this is $MacPerl::Version, which contains a meaningful
value under all versions of MacPerl. Recently, it was decided to introduce in
all Perl5 ports an $^O built-in, which returns the OS. i haven't decided on the
exact value yet, but "MacOS" is the most likely candidate.

Another question is whether you *have* to special case for MacPerl at
all. Would it maybe be possible to make your library auto-calibrating by
calling something like gmtime(0) at the beginning?

Matthias

-----
Matthias Neeracher <neeri@iis.ee.ethz.ch> http://err.ethz.ch/members/neeri.html
   "One fine day in my odd past..." -- Pixies, _Planet of Sound_