#!/bin/csh -f #+ # # NAME: # hpscal # # SYNOPSIS: # hpscal [[[day]month] year] # # DESCRIPTION: # `hpscal' is a PostScript program to generate a 17 week calendar. # There are multiple ways of invoking the program. # If no arguments are given, then the 17 weeks starting from # the current day are generated. # If one argument is given, then it is assumed to be a year, # and the 17 weeks starting from January 1st of that year are # generated. # If two arguments are given, then the first is taken to # be the month, and the second the year. The 17 weeks starting # from that month are then generated. # # The month may be in one of two formats: first, it can be # a number from 1 to 12. The numbers correspond to the # obvious month. # The second format for the month is as a string of three # characters. The format is the same one that the Unix 'date' # program uses: first three letters of the month, first # letter capitalized. # # If invoked with the single argument '-man', pscal will # print this man page. # # # AUTHOR: # Patrick Wood # Copyright (C) 1987 by Pipeline Associates, Inc. # Permission is granted to modify and distribute this free of charge. # # HISTORY: # @Original From: patwood@unirot.UUCP (Patrick Wood) # @Changed to 17 week format by smann@june.cs.washington.edu # # BUGS: # `hpscal' doesn't work for months before 1753 (weird stuff happened # in September, 1752). # # END-OF-MAN set dmon = (Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec) set flags set date = (`date`) set usage = "usage: $0 [-n num_weeks] [[[day] month] year]" set nweeks=17 if ("$1" == "-n") then set nweeks=$2 shift;shift endif switch ($#argv) case 0: set day = $date[3] set month = $date[2] set i = 1 foreach m ($dmon) if ( $m == $month ) then set month = $i break endif @ i++ end set year = $date[6] breaksw case 1: switch ($1) case -man: cat $0 | awk '{if ($2 == "END-OF-MAN") exit;else print}' | more exit case -*: echo "$usage" exit 1 endsw set day = 1 set month = 1 set year = $argv[1] breaksw case 2: set day = 1 set month = $argv[1] set i = 1 foreach m ($dmon) if ( $m == $month ) then set month = $i break endif @ i++ end set year = $argv[2] breaksw case 3: set day = $argv[1] set month = $argv[2] set i = 1 foreach m ($dmon) if ( $m == $month ) then set month = $i break endif @ i++ end set year = $argv[3] breaksw default: echo "$usage" exit 1 breaksw endsw @ month-- cat <