Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cornell!uw-beaver!uw-june!smann From: smann@cs.washington.edu (Stephen Mann) Newsgroups: comp.lang.postscript Subject: pscal again Message-ID: <10312@june.cs.washington.edu> Date: 9 Jan 90 03:09:36 GMT Distribution: na Organization: U of Washington, Computer Science, Seattle Lines: 512 Keywords: calendar, csh, postscript Well, as long as everyone else is posting their version of pscal, I may as well post my latest version. It's still a csh script. Although I like the look of the 5 row format, the 6 row format avoids the doubling of days (and holidays for those days). Changes others made didn't make it into my version. Changes from the last version I posted include: - PostScript will appear on standard output instead of sending it directly it to a printer. The user now must redirect the output to a printer. - The command line semantics were changed as follows: - with no arguments, print the calendar for the current month; - with one argument (a year) print the calendar for the entire year; - with two arguments (month and year) print the calendar for that month and year. If month is 0, then print it for the entire year; - If the lone arguement of '-man' is given, print the man page; - Months can now be specified as a string of 3 characters (first three characters of the month, first letter capitalized) - Corrections to 'isleap' and 'startday' mentioned earlier were incorporated - A crummy facility for showing full and new moons was added (basically, you list them in a file). Maybe someday I'll get around to allowing arbitrary PostScript in the holiday file, clipping of holidays to the day box, and writing a better holiday processor. Maybe. Steve ----------------- #!/bin/csh -f #+ # # NAME: # pscal # # SYNOPSIS: # pscal [[month] year] # # DESCRIPTION: # `Pscal' is a PostScript program to generate calendars. # There are multiple ways of invoking the program. # If no arguments are given, then the calendar for the # current month/year is generated. # If one argument is given, then it is assumed to be a year, # and the calendar for the entire year is printed. # If two arguments are given, then the first is taken to # be the month, and the second the year. # # The month may be in one of two formats: first, it can be # a number from 0 to 12. The numbers correspond to the # obvious month; '0' is special, and will indicates that # the calendar for the entire year should be generated. # 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 capitolized. # # The file $home/.holiday is read and used to print short messages # on specified days. The .holiday file should consist of lines of # the form # month:day:message string # Messages should be 20 characters or less, with no more than 4 # messages per day. No spaces should appear from the beginning # of a line until after the second colon. # Month and day should be numbers in the obvious ranges. # # Also, you may have a ~/.holiday.moon. file. # This is a real ugly hack to put pictures of the full # and new moon on the calendar. Form of the lines # should be # month day full # (or new, if it is a new moon). If there are two full (new) # moons in a month, an entry should be made for each. # Like I said, a real ugly hack. # # If invoked with the single argument '-man', pscal will # print this man page. # # NOTES: # This version differs from previous versions! The calendar # is printed on standard output. It is up to the user # to redirect the output to a printer. # # 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) # @Shell stuff added 3/9/87 by King Ables # @Made pretty by tjt 1988 # @Holiday and printer flag passing hacks added Dec 1988 # @ by smann@june.cs.washington.edu # @Command line processing changed; character string months # @ added; printing of entire year added; phase of moon # @ hacked in; corrections to isleap and startday (noted # @ elsewhere) made; added -man switch; # @ by smann@june.cs.washington.edu Jan 1990 # # BUGS: # `Pscal' doesn't work for months before 1753 (weird stuff happened # in September, 1752). # # A better format for the dates of holidays would be nice. # An escape to allow holiday messages to be raw PostScript would # also be nice. # The holiday messages should be handled more intelligently (ie, # the messages should be clipped to the day). # # END-OF-MAN set dmon = (Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec) set flags set date = (`date`) switch ($#argv) case 0: 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: $0 [[month] year]" exit 1 endsw set month = 0 set year = $argv[1] breaksw case 2: 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 default: echo "usage: $0 [[month] year]" exit 1 breaksw endsw if ( $month != 0 ) then set monthlist = ($month) else set monthlist = (12 11 10 9 8 7 6 5 4 3 2 1) endif cat <