Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Converting epoch times after 2038

by jonadab (Parson)
on Apr 05, 2007 at 10:28 UTC ( #608441=note: print w/ replies, xml ) Need Help??


in reply to Re^2: Converting epoch times after 2038
in thread Converting epoch times after 2038

I too would consider it more a bug than a feature, nonetheless, it seems to be true. I'm getting 7pm Dec 31, 1969 with that one-liner. This is perl, v5.8.8 built for i386-freebsd-64int, running on a 32-bit x86 architecture (Celeron IIRC).

One supposes this means perl is relying too heavily on the underlying C library for certain things.

However, the DateTime::Format::Epoch::Unix code that ikegami posted works fine, so maybe the moral of the story is to always use DateTime modules when you're handling dates and times. (I've been doing that for years anyway, because it's better in other ways. A 2038 bug in localtime would just be the icing on the cake.)

-- 
We're working on a six-year set of freely redistributable Vacation Bible School materials.


Comment on Re: Converting epoch times after 2038
Download Code
Re^2: Converting epoch times after 2038
by duff (Vicar) on Apr 05, 2007 at 14:33 UTC

    I don't mean to snipe really, but do you think that perl should re-invent every wheel so that it can function identically on across operating systems? Perl doesn't rely "too heavily" on the underlying C library; it relies on the C library just appropriately.

      do you think that perl should re-invent every wheel so that it can function identically on across operating systems?

      Only certain necessary wheels. Perl is a high-level language, is supposed to be a *very* high level language. It certainly needs to re-invent data types as necessary to overcome architecture limitations. I don't want to add two integers together and get an overflow. I want it to auto-promote to whatever it needs to. I don't want to add stuff to a string or array and overflow the buffer or smash the stack. I want the necessary RAM to be automatically allocated. And I certainly don't want to add two time values together and get a time in the past because of an overflow. It should automatically promote to (or just be in the first place) however many bits are needed.

      There are things I don't expect perl to re-invent. The filesystem is a good example. Process tables are another. Those things are inherently operating system level concepts, and you don't expect to be able to, for instance, create a hard link on a FAT32 filesystem, or use the same hardcoded file path on different operating systems. But things like arithmetic and dates *should* be the same across all systems.

      -- 
      We're working on a six-year set of freely redistributable Vacation Bible School materials.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://608441]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (12)
As of 2014-07-11 16:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (232 votes), past polls