LinuxSA Mailing list archives

Index: [thread] [date] [subject] [author]
  From: Andrew Speer <andrew.speer@isolutions.com.au>
  To  : Phil Pittard , linuxsa@linuxsa.org.au
  Date: Fri, 07 Jan 2000 13:29:50 +1030

Re: Y2K (year=100)

Phil,

This is from the perlfunc man page, and it shows the usual level of dry perl
humour in the last comment:

**start**

       localtime EXPR
               Converts a time as returned by the time function
               to a 9-element array with the time analyzed for
               the local time zone.  Typically used as follows:

                   #  0    1    2     3     4    5     6     7     8
                   ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =

localtime(time);

               All array elements are numeric, and come straight
               out of a struct tm.  In particular this means that
               $mon has the range 0..11 and $wday has the range
               0..6 with sunday as day 0.  Also, $year is the
               number of years since 1900, that is, $year is 123
               in year 2023, and not simply the last two digits
               of the year.  If you assume it is, then you create
               non-Y2K-compliant programs--and you wouldn't want
               to do that, would you?

**end**

To get the 4 digit year:

perl -e 'my $year=(localtime())[5]+1900; print $year'

To get a 2 digit year:

perl -e 'my $year=(localtime())[5]+1900; $year=~s/^..//; print $year'

Remember though, in Perl TMTOWDTI (There More Than One Way To Do It)


Andrew Speer


----- Original Message -----
From: Phil Pittard <vk5ham@seol.net.au>
To: <linuxsa@linuxsa.org.au>
Cc: <linuxsa@linuxsa.org.au>
Sent: Friday, January 07, 2000 11:52 AM
Subject: Y2K (year=100)


> On the subject of the Year appearing as 100 - I have noticed that a
> number of Linux Perl scripts I have written, which display the date,
> also show the date as dd/mm/100
> Phil
> -----
>
> --
> LinuxSA WWW: http://www.linuxsa.org.au/  IRC: #linuxsa on irc.linux.org.au
> To unsubscribe from the LinuxSA list:
>   mail linuxsa-request@linuxsa.org.au with "unsubscribe" as the subject


Index: [thread] [date] [subject] [author]
Return to the LinuxSA Mailing List Information Page