kebsch@nixpbe.UUCP (12/03/88)
Posting-number: Volume 5, Issue 64 Submitted-by: "A. Nonymous" <kebsch@nixpbe.UUCP> Archive-name: ctime.pl #! /bin/sh # This is a shell archive, meaning: # 1. Remove everything above the #! /bin/sh line. # 2. Save the resulting text in a file. # 3. Execute the file with /bin/sh (not csh) to create: # ctime.pl # ctest # This archive created: Sun Nov 27 17:04:35 1988 export PATH; PATH=/bin:/usr/bin:$PATH if test -f 'ctime.pl' then echo shar: "will not over-write existing file 'ctime.pl'" else sed 's/^X//' << \SHAR_EOF > 'ctime.pl' X;# ctime.pl is a simple Perl emulation for the well known ctime(3C) function. X;# X;# Waldemar Kebsch, Federal Republic of Germany, November 1988 X;# kebsch.pad@nixpbe.UUCP X;# My private System: 80286 with Microport System V/AT 2.2 X;# X;# usage: X;# X;# #include <importenv.pl> # see Perl library. We need the X;# # environment variable TZ. X;# #include <ctime.pl> # see the -P and -I option in perl.man X;# $Date = do ctime(time); X X@DoW = ('Sun','Mon','Tue','Wed','Thu','Fri','Sat'); X@MoY = ('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'); X Xsub ctime { X local($time) = @_; X local($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst); X local($date); X X ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) X = localtime($time); X $year += ($year < 70)? 2000: 1900; X $date = sprintf("%s %s %2d %2d:%02d:%02d %s %4d\n", X $DoW[$wday], $MoY[$mon], $mday, $hour, $min, $sec, $TZ, $year); X return $date; X} SHAR_EOF if test 1025 -ne "`wc -c < 'ctime.pl'`" then echo shar: "error transmitting 'ctime.pl'" '(should have been 1025 characters)' fi fi if test -f 'ctest' then echo shar: "will not over-write existing file 'ctest'" else sed 's/^X//' << \SHAR_EOF > 'ctest' Xeval "exec perl -PS $0 $*" X if $running_under_some_shell; X;# Simple Test of ctime.pl Waldemar Kebsch X;# X X#include <importenv.pl> X#include <ctime.pl> X X$Date = do ctime(time); Xprint $Date; SHAR_EOF if test 188 -ne "`wc -c < 'ctest'`" then echo shar: "error transmitting 'ctest'" '(should have been 188 characters)' fi fi exit 0 # End of shell archive