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

Re: [MacPerl] MacPerl & timelocal....



Too much going on today... let's try this again.

}wls@oculus.jsei.ucla.edu writes:
}}Help!!
}}
}}I can't get timelocal to work on my mac(s)
}}It works on on my sun.
}
}Doesn't look like it.  In fact, it looks like your Sun is wrong.
}
}}It's the very recent download... system 7.5.5 mac IIfx & more...
}}
}}here's my test:
}}
}}#!/home/johnh/BIN/perl5 -w
}}
}}require "timelocal.pl";
}}
}}# prints :
}}# raw local time is 03/07/1997 13:12:24 5 65 0
}}# timelocal = ffffffff
}
}All 1 bits?

On the Mac (I thought it was your Sun giving this) this is almost certainly
a symptom of a bug in Perl 5.002.  There are comparisons in timelocal.pl
that have to be made floating point in order to get them to evaluate
properly.  I have a fixed timelocal.pl (which is what I used below since I
have it installed in my MacPerl lib folder) at
<ftp://mors.gsfc.nasa.gov/pub/MacPerl/Scripts/Fixed_Library_Routines/>.
What you should really do, though, is instead of using the ancient
timelocal.pl use Time::Local, which Matthias has already fixed.

}
}}# ... on my mac.
}}# prints :
}}# printf (...) interpreted as function at timelocal.pl line 8.
}}# raw local time is 03/07/1997 13:13:18 5 65 0
}}# timelocal = 332084ee
}}# ... on my sun
}}
}}
}} @timearray = localtime(time);
}} ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = @timearray;
}} printf ("raw local time is %02d/%02d/%04d %02d:%02d:%02d %d %d %d\n",
}}          $mon+1,$mday,1900+$year,$hour,$min,$sec,$wday,$yday,$isdst);
}} $ltime = &timelocal(@timearray);
}} printf ("timelocal = %8x\n",$ltime);
}
}Here's what I get under MacPerl:
}
}raw local time is 03/07/1997 17:05:18 5 65 0
}timelocal = af45a6ee
}
}and on my Sun (Perl 5.003, SunOS 4.1.4)
}
}raw local time is 03/07/1997 17:07:46 5 65 0
}timelocal = 332091b2
}
}I haven't checked to see whether the hex is right, but it should be on both.
}
}I don't know exactly what you're expecting.  Looks to me like Perl on your
}Sun may be messed up; notice the message about printf.  You do realize that

And I missed the fact that you were using -w, hence the message about
printf.  It's been one of those days.

}the Unix and Mac zeroes of time are different, so the last hex numbers will
}differ substantially?
}
}
}---
}Paul J. Schinder
}NASA Goddard Space Flight Center
}Code 693, Greenbelt, MD 20771
}schinder@pjstoaster.pg.md.us


---
Paul J. Schinder
NASA Goddard Space Flight Center
Code 693, Greenbelt, MD 20771
schinder@pjstoaster.pg.md.us