SPUG: Dates, anyone?

Scott Blachowicz sab at rresearch.com
Thu Dec 30 18:59:18 CST 1999


On Thu, Dec 30, 1999 at 04:26:57PM -0800, David Poncelow wrote:
> Actually, in being too careful, you will find that you introduced a Y2K
> bug into your script-  as the Camel says, 'the year has had 1,900
> subtracted from it'.  As of Jan 1 (tomorrow night), that array element
> will be 100, not the 00 that you are counting on.  As a result, your date
> string will end up being Saturday, 1-Jan-2100 14:59:43 PDT...

Nope...he's adding 1900 if it's not '<80', so 100+1900 = 2000.  He's
using the "I'm not sure which way it'll go, but this'll cover them
both" algorithm :-). (assuming there's no way for this code to get a
date that is supposed to be before 1980).

> > @statz=stat("wossname.pl"); # or whatever file
> > $mz="Jan/Feb/Mar/Apr/May/Jun/Jul/Aug/Sep/Oct/Nov/Dec";
> > $wkd="Sunday/Monday/Tuesday/Wednesday/Thursday/Friday/Saturday";
> > ($sec,$min,$hour,$day,$nmon,$year,$wday,$yday,$isdst)=localtime($statz[9]);
> > if ($year<80) { $year+=2000; } else { $year+=1900; }

-- 
Scott.Blachowicz at seaslug.org

 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    POST TO: spug-list at pm.org        PROBLEMS: owner-spug-list at pm.org
 Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/
 SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe
        Email to majordomo at pm.org: ACTION spug-list your_address





More information about the spug-list mailing list