package time; 1; sub RFC822time { # Returns today's date as an RFC822 compliant string with the # exception that the year is returned as four digits. In my # extremely valuable opinion RFC822 was wrong to specify the year # as two digits. Many email systems generate four-digit years. # Today is defined as the first parameter, if given, or else the # value that time() gives. my ($tsec,$tmin,$thour,$tmday,$tmon,$tyear,$twday,$tyday,$tisdst) = gmtime(shift || time()); $tyear += 1900; # as mentioned above, this is not RFC822 compliant, but is Y2K-safe. $tsec = "0$tsec" if $tsec < 10; $tmin = "0$tmin" if $tmin < 10; $thour = "0$thour" if $thour < 10; $tmon = ('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec')[$tmon]; $twday = ('Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat')[$twday]; return "$twday, $tmday $tmon $tyear $thour:$tmin:$tsec GMT"; }