develooper Front page | perl.perl5.porters | Postings from October 1999

Making -DPERL_Y2KWARN useful after 946684800

Michael G Schwern
October 18, 1999 09:39
Making -DPERL_Y2KWARN useful after 946684800
Message ID:
Color me stupid... but its the middle of October 1999 and we're adding
Y2K warnings to Perl?  Will 5.6 even stable before New Year's?  Will
there be another release of 5.004 before 2000?

I find the usefulness of this feature to be marginal as it currently
stands.  Too little, too late and better implemented outside the core
(ala mjd's y2k module, but that's another argument entirely.)

As long as its going in, let's make it useful.  Its functionality
could be extended INTO THE NEXT CENTURY <that has to be said in a
majestic Buck Rogers voice> with a little bit more work.

Expect to see the following complaints on clp.misc after New Year's...
"20$year" prints 20100!
$year -= 100;  "20$year" prints 200!  (or "20%d", $year)
I put $year -= 100; printf "20%02d" into my program and then ran
localtime() with a time in 1999 and now I get 20-1!
I put $year -= 100; print "200$year" and now I get 20010 (we'll be
seeing this in 10 years)
(This is the greatest granddaddy of them all, I actually found this in
a book written by our dear friends "Selena Sol")

  $year = ($sc_current_century-1) . "$year";
  $date = "$days[$wday], $months[$mon] $mday, $year at
  return $date;

Yes, $sc_current_century is a hard coded constant.

I think "20$year" should be stomped on just as hard as "19$year" is
and it should be stressed that $year += 1900 is the proper way to
prepare the year for output.  It doesn't appear difficult to add
checks for 20 to the existing PERL_Y2KWARN flag.  Perhaps it should be
changed to PERL_YEAR_WARN?

If it sounds sensible I'll prepare a patch.


Michael G Schwern                                 
     /(?:(?:(1)[.-]?)?\(?(\d{3})\)?[.-]?)?(\d{3})[.-]?(\d{4})(x\d+)?/i Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About