[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] Time::localtime not Y2K.



on 01/18/2000 9:48 AM, jean-michel meyer at mjm@aix.pacwan.net wrote:

> 
> Thu, 30-12-99 19:0:13 GMT no connexion
> Thu, 6-1-100 17:1:51 GMT no connexion
> 
> Happy to learn that after 1999, we are in 19100. :-)
> 

In case you didn't see the docs, here is a good snippet for you:

my($sec,
   $min,
   $hour,
   $mday,
   $mon,
   $year,
   $wday,
   $yday,
   $isdst) = localtime(time()); # The time now...

# Y2k issue repairs start here...
$year += 1900; # The current year is exactly 'num yrs since 1900.'
$mday  = sprintf("%02d", $mday);   # Make sure we have two digits.
$mon   = sprintf("%02d", ++$mon); # Ditto here...
$sec   = sprintf("%02d", $sec);   # Ditto here...
$min   = sprintf("%02d", $min);   # Ditto here...
$hour  = sprintf("%02d", $hour);  # Ditto here...
$yday  = sprintf("%03d", $yday);  # 3 digits here...

#IE - 183417101219995343
#      1 2 3 4 5   67  8

# Are -
#   1 - seconds
#   2 - minutes
#   3 - hours
#   4 - day of month
#   5 - month   
#   6 - year
#   7 - day of week (5 = Friday)
#   8 - Julian date (day 343 into this year :)
# Y2k issue repairs end...

Even works on MacOS, Windows, Unix, BeOS, ...

HTH, -Sneex-  :]
____________________________________________________________________
Bill Jones * Systems Programmer * http://www.fccj.org/cgi/mail?sneex

                                   ('>   Running -
                                   //\   Perl, Apache, MySQL, PHP3,
                                   v_/_  Ultra 10, LinuxPPC, BeOS...


# ===== Want to unsubscribe from this list?
# ===== Send mail with body "unsubscribe" to macperl-request@macperl.org