SPUG: Perl Y2K Bug on Display!

Andrew Sweger andrew at sweger.net
Mon Feb 26 14:55:50 PST 2007


On Mon, 26 Feb 2007, Tim Maher wrote:

> Just stumbled across a web page that suggests that some programmer out
> there didn't read the Camel closely enough. At the bottom of the page,
> the year 19101 appears, in classic Perl Y2K bug style! 8-}
> 
> It's coming from a ShowDate(); call embedded within <SCRIPT> tags.
> Anybody know where that function comes from?
> 
> http://web2.uwindsor.ca/registrar/records/transcpt.html

It's defined near the top of the HTML document:

function ShowDate() {
    lm_date = new Date(document.lastModified);
    m = new Array("January","February","March","April","May","June","July","August",
                "September","October","November","December");
    document.write(m[lm_date.getMonth()]+" "+lm_date.getDate()+",19"+lm_date.getYear());
}

Pretty obvious what they did wrong there. It's no wonder they didn't read
the Camel book. It's JavaScript. They should have read up on that instead. 

In http://www.w3schools.com/jsref/jsref_obj_date.asp regarding getYear():

  Returns the year, as a two-digit or a four-digit number, from a Date
  object. Use getFullYear() instead !!	

-- 
Andrew B. Sweger -- The great thing about multitasking is that several
                                things can go wrong at once.



More information about the spug-list mailing list