SPUG: Dates, anyone?

David Poncelow panache at wolfenet.com
Thu Dec 30 18:26:57 CST 1999


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...



On Thu, 30 Dec 1999, Steve Laybourn wrote:

> Hello!
> 
> I'm just a bit late with this posting, which I found out went to the  wrong 
> place the first time I posted it.
> 
> Here's a way I deal with changing a UNIX time into a valid time/date stamp:
> 
> @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; }
> $wk=(split("/",$wkd))[$wday];
> $mn=(split("/",$mz))[$nmon];
> $lastmod=sprintf("%s, %s-%s-%s %02d:%02d:%02d 
> PDT",$wk,$day,$mn,$year,$hour,$min,$sec);
> 
> This turns a large number of seconds into something like:
> 
> Thursday, 30-Dec-1999 14:59:43 PDT
> 
> I know this is probably not the best way to do this, but you don't have to 
> refer to any external modules and you can customize the subroutine to output 
> the date in any format you like...
> 
> Hope this helps!
> Steve Laybourn
> 
> The answer to your question REALLY is: Five tons of flax!
> 
> 
> 
> ______________________________________________________
> Get Your Private, Free Email at http://www.hotmail.com
> 
> 
>  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
>     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
> 
> 


 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    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