SPUG: Dates, anyone?

William Julien moonbeam at catmanor.com
Thu Dec 30 21:20:15 CST 1999


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

tm_year year in the unix time.h "struct tm", is documented as "The
number of years since 1900.". So, employing a windowing technique is
not necessary. All you have to do is add 1900 to correctly get the
correct year.

This is a timely question. I think the above really illustrates that the
Y2K issue is really a people problem. Before tomorrow, programmers could
use the raw scalar result from (localtime($time_t))[5] as the current year;
ignoring the definition. I agree with Tom Christiansen's point of view.

    "Is Perl ``Year 2000 Compliant''? The answer is that Perl is every
    bit as Y2K compliant as is your pencil; no more, and no less."

    see ... http://www.perl.org/phbs/y2k.html

---
        _,'|            _.-''``-...___..--';
       /, \'.      _..-' ,      ,--...--'''
      < \   .`--'''      `     /| William Julien moonbeam at catmanor.com
       `-,;'              ;   ; ; http://www.catmanor.com/moonbeam/
 __...--''     __...--_..'  .;.'  vi is my shepherd; i shall not font.
(,__....----'''      (,..--''     
perl -e 'print $i=pack(c5,(41*2),sqrt(7056),(unpack(c,H)-2),oct(115),10);'


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