1 ;# ctime.pl is a simple Perl emulation for the well known ctime(3C) function.
3 ;# Waldemar Kebsch, Federal Republic of Germany, November 1988
4 ;# kebsch.pad@nixpbe.UUCP
5 ;# Modified March 1990 to better handle timezones
6 ;# $Id: ctime.pl,v 1.3 90/03/22 10:49:10 hakanson Exp $
7 ;# Marion Hakanson (hakanson@cse.ogi.edu)
8 ;# Oregon Graduate Institute of Science and Technology
12 ;# #include <ctime.pl> # see the -P and -I option in perl.man
13 ;# $Date = &ctime(time);
15 @DoW = ('Sun','Mon','Tue','Wed','Thu','Fri','Sat');
16 @MoY = ('Jan','Feb','Mar','Apr','May','Jun',
17 'Jul','Aug','Sep','Oct','Nov','Dec');
21 local($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst);
23 # Use GMT if can't find local TZ
24 $TZ = defined($ENV{'TZ'}) ? $ENV{'TZ'} : 'GMT';
25 ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) =
26 ($TZ eq 'GMT') ? gmtime($time) : localtime($time);
27 # Hack to deal with 'PST8PDT' format of TZ
28 if ( $TZ =~ /-?\d+/ ) {
29 $TZ = $isdst ? $' : $`;
31 $TZ .= " " unless $TZ eq "";
32 $year += ($year < 70) ? 2000 : 1900;
33 sprintf("%s %s %2d %2d:%02d:%02d %s%4d\n",
34 $DoW[$wday], $MoY[$mon], $mday, $hour, $min, $sec, $TZ, $year);