Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Why does localtime() return 1900-$YEAR?

by bart (Canon)
on Jan 31, 2011 at 12:00 UTC ( [id://885255]=note: print w/replies, xml ) Need Help??


in reply to Why does localtime() return $YEAR-1900?

It's $year-1900, not 1900-$year.

And it's a fix for an old custom that started a long time ago (70s - 80s) when they thought "2-digit years should be enough for any date".

So when 2000 came along, they had a problem. Replacing 2 digit years with years since 1900 was the easiest, backward compatible fix.

Replies are listed 'Best First'.
Re^2: Why does localtime() return 1900-$YEAR?
by apl (Monsignor) on Jan 31, 2011 at 12:44 UTC
    Further, you need 11 bits to specify 1999, while only 7 are necessary for 99. Believe it or not, being able to to save 4 bits a record (or structure) was a big deal back in the '70s...

    Yes, I'm a dinosaur, as I've been programming since 1972...

      Perl was first released in 1987. The memory issue was much less important by that time and I am quite sure people were already aware of the bug 2000.

      Though that's an interesting other question. When did people start to talk about "bug 2000"?

        Dunno, but Perl has already addressed the y2038 bug. That's when the years would overflow even when subtracting 1900.
        Hmm, I worked on a COBOL system with 2 digit dates in the late 80's / early 90's and there was no pressure to modify the date structures. So I'm not sure people were as prescient as you assume.

        The first time I heard mention of the Y2K issue was '97 when a friend let it be known to a recruiter that I could work in COBOL >>>Shudder<<<

        print "Good ",qw(night morning afternoon evening)[(localtime)[2]/6]," fellow monks."
        Perl was first released in 1987.
        Quite true, but the Unix time structure (which defined the year as an offset from 1900) has been a de facto standard since around 1975.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (4)
As of 2024-04-24 05:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found