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

[MacPerl] newtimelocal.pl to repleace timelocal.pl



Dear Perl Hackers,

  I have written newtimelocal.pl, a replacement for timelocal.pl that comes
with every perl.  I wrote newtimelocal primarily because I wanted such timel
ocal() (or timegm() or mktime()) that is compatible with that of C; The orig
inal timelocal() checks ranges for mday and month, which is often pain in th
e neck when you want to do something like;

        @now = localtime();
        @now[4] -= 3;
        $threemonthago = timelocal(@now);

To get the time of 3 month ago.  timelocal() or mktime() of most C library,
on the other hand, returns a proper value even when the argument is out of r
ange.  You can find the copy at

        http://www.dnsa.or.jp/~dankogai/newtimelocal/

The copy of newtimelocal.pl contains pod so newtimelocal.pl should suffice.
For those who want to test, there is also test.pl available.
  If okay, I would like to have the original timelocal.pl with mine or anyth
ing analogous.  Many expect timelocal.pl to behave the same as that of C lib
raries, as far as I browse comp.lang.perl.*;  I, for one, would not have wri
tten newtimelocal if the original behaved how I expected....

Dan the Man Lost in Time.

P.S.  I'm crossmailing this to both perl5-posters and mac-perl because the c
urrent version of newtimelocal treats MacPerl specially because of the funny
output of gmtime(0), which is used to find when Epoch is.