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

Re: [MacPerl] localtime() behavior question



> I tried
>
> print scalar (localtime(-1));
>
> on a Unix machine and got 1 second before epoch.
>
> If I try the same on Macperl, I just get the epoch, unmodified.
>
> Is this a known behavior? Can I get dates before Jan 1, 1904 using 
> localtime()?


Proper Macintosh behavior (ignoring Perl for a moment) would probably be 
for the result to be the suitable representation of February 6, 2040, at 
6:28:15 AM.

Time on Mac is unsigned (despite the annoyance that caused in the Pascal 
days of the Mac, with Pascal not doing unsigned), and when viewed as signed 
has always been negative for dates during the Mac's lifetime (and back to 
the early morning of January 19, 1972).

Mac time in its 32-bit form cannot go before 00:00 on Jan 1, 1904 (or after 
the above date in 2040, until "windowing" takes over).  In its modern 
signed 64-bit form, time can go quite a bit farther back (over 30,000 
years, if one could get the calendar folks to agree on which one to project 
back that far).

Matthias has to keep the Perl porters (and us) happy with localtime()'s 
behavior (which likely precludes using the Mac 64-bit time).  He would have 
to patch 23:59:59 Dec 31 1903 together "by hand" to match the behavior you 
quote for Unix.

See also Chris' better (because briefer and more useful) reply.
   --John
--
John Baxter   jwblist@olympus.net      Port Ludlow, WA, USA
Give a man a fish and you feed him for a day.  Teach him to fish,
and you get rid of him for the weekend.

***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch