jbr0@cbnews.att.com (joseph.a.brownlee) (10/06/90)
#!/bin/sh # This is part 02 of a multipart archive # ============= pcal.hlp ============== if test -f 'pcal.hlp' -a X"$1" != X"-c"; then echo 'x - skipping pcal.hlp (File already exists)' else echo 'x - extracting pcal.hlp (Text)' sed 's/^X//' << 'SHAR_EOF' > 'pcal.hlp' && 1 PCAL X Pcal generates PostScript to produce landscape or portrait X orientated calendars for any month and year. The defaults for X month and year are the current month and year. X X VMS Version X Execution format: X X pcal [options] [mm yy] [n] X X If a file named CALENDAR.DAT resides in the caller's home X directory (or in a directory defined by the logical name PCAL_DIR, X if it exists), it will be searched for lines with leading dates X matching the requested month and year (current by default). Any X text following the date will be printed on the calendar under the X appropriate day of the month. Dates in the CALENDAR.DAT file may X consist of a numeric or alpha month (at least the first 3 X characters for month names) followed by a numeric day and X optionally followed by a year. Any non-numeric character may X separate numeric dates. Holidays may be flagged by following the X date immediately with '*'; this will cause the date to be printed X in gray. Lines in the CALENDAR.DAT file consisting of "year xxxx" X (where xxxx is a numeric year) can be used to set the year for X following entries. This assumes that the following entries do not X contain a year; any date entries containing year information will X set the remembered year to that year. Lines consisting of X "opt <options>" can be used to override defaults for all command- X line flags except -e, -f, -D, and -U; any flags set in this manner X are themselves overridden by flags specified explicitly on the X command line. Comments ('#' through end-of-line) are permitted. X X Example: X X # sample CALENDAR.DAT file - Raytheon holidays and exempt paydays, 1990 X X opt -t Helvetica-Bold -d Helvetica-Bold # override default fonts X opt -M # print moon phase X X year 1990 # set default year X X 7/4* Independence Day # '*' flags 7/4 as holiday X 7/12/90 Exempt payday # full numeric date X Aug 16 Exempt payday # alternate date format X 9/3* Labor Day X 9/20 Exempt payday X 10/8* Columbus Day (observed) X 10/25 Exempt payday X 11/20 Exempt payday X 11/22* Thanksgiving X 11/23* X 12/13 Exempt payday X 12/24* X 12/25* Christmas X X Pcal supports rudimentary cpp-like functionality in the date file, X supporting define | undef, if{n}def ... {else ...} endif, and X include: X X define meetings X X ifdef meetings X include meetings.dat X undef meetings X endif X X Symbol names are case-insensitive. It is not an error to "undef" X an undefined symbol, nor to "define" a previously-defined one. X X "ifdef" alone is always false; "ifndef" alone is always true. X X The name of the file in the "include" directive may optionally be X surrounded by either "" or <>, both of which are ignored. If the X name is not an absolute path, it is taken to be relative to the X directory where the file containing the directive is located. X X Pcal allows the user to print additional notes in an unused X calendar box via lines of the form "note <month> <text>", where X <month> specifies the month (numeric or alphabetic form) and X <text> is the text to add. All such text will appear in the X "Thursday" box on the last line (next to the small calendars). X X Pcal also looks for global symbol PCAL_OPTS; if defined, its X contents are parsed as command-line flags. These override the X program defaults, but are overridden by any specified via "opt" X lines in the date file or on the command line. Example: X X $ define PCAL_OPTS "-n Helvetica -D meetings" ! login.com X X $ pcal -"U" meetings 9 90 ! un-define symbol at runtime X 2 parameters X mm yy n X "mm" and "yy" are numeric values of the month (1-12) and year X (0-99) (i.e., July 1990 would be 7 90). If you just include the X "yy" option, an entire 12 months of calendars will be generated. X A specific month can be produced by including the "mm" parameter. X The "n" parameter will produce the "n" consecutive months of X calendars starting with the requested month. X X The following flags may be specified (in increasing order of X precedence) in global symbol PCAL_OPTS, in "opt" lines in the date X file (all but -e, -f, -D, -U), or on the command line. Any flag X which normally takes an argument may be specified without the X argument; this resets its value to the program default. (-D X alone thus clears all defined symbols; -U alone has no effect.) X X The '-' flag has been added to disambiguate cases where an X argument-less flag has been specified immediately before a numeric X parameter: X X $ pcal -t - 9 90 X 2 -e X Print an empty calendar (i.e., do not print entries from a X CALENDAR.DAT file.) X 2 -f <FILE> X Directs pcal to use the file name <FILE> as the input file in X place of the default CALENDAR.DAT file in the callers home X directory or in the directory specified by logical name PCAL_DIR. X 2 -o <FILE> X Directs pcal to write the PostScript calendar into FILE X (default: CALENDAR.PS in the current directory.) X 2 -l X This will cause the output to come out in landscape mode X (default). X 2 -p X This will cause the output to come out in portrait mode X instead of landscape mode. X 2 -b <DAY> | all X This will cause all dates on weekday DAY to be printed in X black; "-b all" causes all dates to be printed in black unless X explicitly flagged as a holiday. X 2 -g <DAY> | all X This will cause all dates on weekday DAY to be printed in X gray; "-g all" causes all dates to be printed in gray. Default is X to print Saturdays and Sundays in gray and other dates in black. X 2 -F <DAY> X This will cause the weekday DAY to be the first day of each X week; weekday DAY will appear in the left-most column of each X calendar. X 2 -t <FONT> X This option can be used to change the font the title is X printed in (ie. pcal -t Times-Roman). The default is Times-Bold. X 2 -d <FONT> X This option is the same as -t except that the font used to X print the day numbers is changed. The default is Times-Bold. X 2 -n <FONT> X This option is the same as -n except that the font used to X print the notes in the calendar boxes is changed. The default is X Helvetica-Narrow. X 2 -m X This option causes a moon to be printed on days corresponding X to a full, half, or new moon (default: no moons). X 2 -"M" X This option causes a moon to be printed on all days (default: X no moons). X 2 -"L" <STRING> X This will cause STRING to be printed as a left footer. X 2 -"C" <STRING> X This will cause STRING to be printed as a center footer. X 2 -"R" <STRING> X This will cause STRING to be printed as a right footer. X 2 -"D" <SYM> X This will define symbol SYM prior to reading the date file; X -D alone clears all defined symbols. X 2 -"U" <SYM> X This will undefine symbol SYM prior to reading the date file. X 2 CREDITS X The original PostScript code to generate the calendars was X written by Patrick Wood (Copywrite (c) 1987 by Patrick Wood of X Pipeline Associates, Inc.), and authorized for modification and X redistribution. The CALENDAR.DAT file inclusion code was X originally written in "bs(1)" by Bill Vogel of AT&T. Patrick's X original PostScript was modified and enhanced several times by X others whose names have regrettably been lost. Ken Keirnan of X Pacific Bell assembled the original "C" version upon which this is X based; additional modifications and enhancements were the work of X Joseph P. Larson, Ed Hand, Andrew W. Rogers, Mark Kantrowitz, Joe X Brownlee, and Jamie Zawinski. This VMS HELP file was written by X Richard Dyson and updated by Andrew W. Rogers and Joe Brownlee. X SHAR_EOF chmod 0644 pcal.hlp || echo 'restore of pcal.hlp failed' Wc_c="`wc -c < 'pcal.hlp'`" test 8035 -eq "$Wc_c" || echo 'pcal.hlp: original size 8035, current size' "$Wc_c" fi # ============= pcal.man ============== if test -f 'pcal.man' -a X"$1" != X"-c"; then echo 'x - skipping pcal.man (File already exists)' else echo 'x - extracting pcal.man (Text)' sed 's/^X//' << 'SHAR_EOF' > 'pcal.man' && .TH PCAL 1 .SH NAME pcal \- generate PostScript calendars .SH SYNOPSIS .BR pcal " [" .BR \-e " | " \-f .I cal ] [ .BI \-o " file" ] [ .BR \-l " | " \-p ] [ .BR \-m " | " \-M ] [ .BI \-b " day" | all ] [ .BI \-g " day" | all ] [ .BI \-F " day" ] [ .BI \-t " title_font" ] [ .BI \-d " day_font" ] [ .BI \-n " text_font" ] [ .BI \-L " footer_string" ] [ .BI \-C " footer_string" ] [ .BI \-R " footer_string" ] [ .BI \-D " symbol" ] [ .BI \-U " symbol" ] [ .B month ] [ .B year ] [ .B nmonths ] .SH DESCRIPTION .I Pcal generates PostScript to produce landscape or portrait calendars for any month and year. The arguments .BR month , .BR year , and .BR nmonths , if provided, should be numeric. The .BR month value should be in the range 1 \- 12, and the .BR year value should be specified as 1 or 2 digits or as the full 4 digit year. If no numeric arguments are provided, the calendar for the current month and year will be generated. .PP If one numeric argument is provided, it is interpreted as the .BR year value, and calendars for the entire year will be generated. Otherwise, .BR nmonth months, starting with .BR month and .BR year , will be generated. .PP If a file named .I \.calendar (or .I calendar for compatibility with older versions) exists in the caller's home directory or in the directory pointed to by environment variable .BR PCAL_DIR , it will be searched for lines with leading dates matching the requested month and year. Any text following the dates found will be printed on the calendar under the appropriate day of the month. Dates in the .I \.calendar file may consist of a numeric or alphabetic month (at least the first 3 characters for month names), followed by a numeric day and optionally followed by a year. Any non-numeric character may separate numeric dates. Holidays may be flagged by following the date immediately with `*'; this will cause the date to be printed in gray. .PP Lines in the .I \.calendar file consisting of .B year XXXX (where .B XXXX is a numeric year) can be used to set the year for following entries. This assumes that the following entries do not contain a year; any date entries containing year information will set the remembered year to that year. .PP Lines in the .I \.calendar file consisting of .B opt <options> can be used to override the defaults for any command-line flags except .BR \-e , .BR \-f , .BR \-D ", and" .BR \-U . Any flags specified in this manner are, in turn, overridden by those specified explicitly on the command line. .PP Lines in the .I \.calendar file consisting of .B note <month> can be used to place notes regarding the entire month is one of the unused blocks of the calendar. The .B <month> indicator may be either a number 1 through 12 or an alphabetic month name as described above. .PP Comments are supported in the .I \.calendar file. Any characters following a `#' character through the end of the line are ignored. .PP .I Pcal supports rudimentary cpp-like functionality in the date file, allowing the following constructs: .BR "define | undef" , .B if{n}def ... {else ...} endif, and .BR include . Note that these are not preceded by `#' as they are in C. Symbol names defined using these keywords are case-insensitive. It is not an error to .BR undef an undefined symbol, nor to .BR define a previously-defined one. An .BR ifdef alone is always false; an .BR ifndef alone is always true. .PP The name of the file in the .BR include directive may optionally be surrounded by either "" or <>, both of which are ignored. If the name is not an absolute path, it is taken to be relative to the directory where the file containing the directive is located. .I Pcal is smart enough to translate .B ~/ to the user's home directory. .PP .I Pcal has many options: .P .TP 12 .B \-e Prints an empty calendar. Do not print entries from a .I \.calendar file. .TP .BI \-f " cal" Directs .I pcal to use the file name .I cal as the input file in place of the default .I \.calendar file in the user's home directory (or the directory pointed to by .BR PCAL_DIR ). .TP .BI \-o " file" Directs .I pcal to write the output to .I file instead of to stdout. .TP .B \-l Causes the output to be in landscape mode (default). .TP .B \-p Causes the output to be in portrait mode. .TP .B \-m Causes moon icons to be printed on dates corresponding to new, half, and full moons (the default is that no moons are printed). .TP .B \-M Causes moon icons to be printed on all dates (the default is that no moons are printed). .TP .BI \-b " day" " | all" Causes all dates falling on weekday .I day to be printed in black; .B \-b all causes all weekdays to be printed in black. .TP .BI \-g " day" " | all" Causes all dates falling on weekday .I day to be printed in gray; .B \-g all causes all weekdays to be printed in gray. .IP The default for the .BR \-b " and " \-g flags is to print Saturdays and Sundays in gray and other days, unless flagged as holidays, in black. .TP .BI \-F " day" Selects weekday .I day as the first day of the week. The given day will appear in the left-most column of the calendar. .TP .BI \-t " title_font" Sepcoifies the name of a font to use to print the month name and year at the top of the calendar. For example, .BR "pcal \-t Times-Roman" . .TP .BI \-d " day_font" Similar to the .B \-t option, but selects the font used to print the day numbers. .TP .BI \-n " text_font" Similar to the .B \-t option, but selects the font used to print the text inside each day and in the notes block. .TP .BI \-D " symbol" Defines the named symbol prior to reading the date file. .TP .BI \-U " symbol" Un-defines the named symbol prior to reading the date file. .TP .BI \-L " string" Causes the accompanying string to be printed as a left-justified footer. .TP .BI \-C " string" Causes the accompanying string to be printed as a centered footer. .TP .BI \-R " string" Causes the accompanying string to be printed as a right-justified footer. .PP Any option which normally takes an argument may be specified without the argument in order to reset the value to the program default. Note that while the .B \-D option alone clears all the defined symbols, the .B \-U option alone has no effect. The .B \- (or .BR "\- \-" , System V people) flag may be used to disambiguate command lines such as: .IP .B pcal \-t 9 90 .PP This could be written instead as one of the following: .IP .B pcal \-t \- 9 90 .br .B pcal \-t \- \- 9 90 .PP If the environment variable .BR PCAL_OPTS is defined, its contents are parsed as a command line. Flags set via .BR PCAL_OPTS override the program defaults, but are overridden by flags set via .B opt lines in the .I \.calendar file or explicitly on the command line. .SH SEE ALSO cal(1) .SH AUTHORS The original PostScript code to generate the calendars was written by Patrick Wood (Copywrite (c) 1987 by Patrick Wood of Pipeline Associates, Inc.), and authorized for modification and redistribution. The calendar file inclusion code was originally written in .IR bs (1) by Bill Vogel of AT&T. Patrick's original PostScript was modified and enhanced several times by others whos names have regrettably been lost. Ken Keirnan of Pacific Bell assembled the original ``C'' version upon which this is based; additional modifications and enhancements are the work of Joseph P. Larson, Ed Hand, Andrew W. Rogers, Mark Kantrowitz, Joe Brownlee, and Jamie Zawinski. SHAR_EOF chmod 0644 pcal.man || echo 'restore of pcal.man failed' Wc_c="`wc -c < 'pcal.man'`" test 7393 -eq "$Wc_c" || echo 'pcal.man: original size 7393, current size' "$Wc_c" fi # ============= pcalinit.c ============== if test -f 'pcalinit.c' -a X"$1" != X"-c"; then echo 'x - skipping pcalinit.c (File already exists)' else echo 'x - extracting pcalinit.c (Text)' sed 's/^X//' << 'SHAR_EOF' > 'pcalinit.c' && /* X * Create a .h file from a .ps file. Strips out leading and trailing X * whitespace, blank lines, and lines consisting solely of comments, X * except for the very first block of comments/blanklines, which are X * turned into C comments at the top of the file. X * X * 14-sep-90 Jamie Zawinski created. X */ X #include <stdio.h> #include <ctype.h> #include <string.h> X char *strip_white (string) X char *string; { X int n; X for (; *string == ' ' || *string == '\t' || *string == '\n'; string++); X n = strlen(string)-1; X for (; string[n] == ' ' || string[n] == '\t' || string[n] == '\n'; n--) X string[n] = '\0'; X return string; } X main (argc, argv) X int argc; char *argv[]; { X FILE *in, *out; X char line[256], *L; X int in_initial_comments = 1; X if (argc != 3) { X fprintf(stderr, "usage: %s <infile>.ps <outfile>.h\n", argv[0]); X exit(-1); } X X in = fopen(argv[1], "r"); X if (NULL == in) { X fprintf(stderr, "%s: couldn't open %s\n", argv[0], argv[1]); X exit(-1); } X X out = fopen(argv[2], "w"); X if (NULL == out) { X fprintf(stderr, "%s: couldn't open %s\n", argv[0], argv[2]); X exit(-1); } X X fprintf (out, X "/* automatically generated from \"%s\" - DO NOT EDIT THIS FILE!\n *\n", X argv[1]); X for (;;) { X if (NULL == fgets (line, 255, in)) break; X L = strip_white(line); X if ( in_initial_comments ) { X if ( L[0] != '%' && L[0] != '\0' ) { X in_initial_comments = 0; X fprintf(out, " */\n\nchar *header[] = {\n \"%s\",\n", L); } X else X fprintf(out, " * %s\n", L); X } X else if (L[0] != '%' && L[0] != '\0' ) X fprintf(out, " \"%s\",\n", L); X } X fprintf(out, " (char *)0,\n};\n"); X fclose(out); X fclose(in); } SHAR_EOF chmod 0644 pcalinit.c || echo 'restore of pcalinit.c failed' Wc_c="`wc -c < 'pcalinit.c'`" test 1792 -eq "$Wc_c" || echo 'pcalinit.c: original size 1792, current size' "$Wc_c" fi # ============= pcalinit.ps ============== if test -f 'pcalinit.ps' -a X"$1" != X"-c"; then echo 'x - skipping pcalinit.ps (File already exists)' else echo 'x - extracting pcalinit.ps (Text)' sed 's/^X//' << 'SHAR_EOF' > 'pcalinit.ps' && %!ps % pcalinit.ps - provides the PostScript routines for pcal.c % % 2.5 modified by Joe Brownlee: % % made day numbers smaller, providing more room for event text % repositioned event text and moons accordingly % added support for variable first day of week % % 2.4 * no modifications * % % 2.3 modified by Jamie Zawinski <jwz@lucid.com>: % % merged in moon routines (originally by Mark Hanson) % % 2.2 modified by Joe Brownlee: % % add "notetext" to print notes in unused calendar box % % 2.1 modified by Mark Kantrowitz: % % use symbolic names instead of magic numbers throughout % support -L, -C, -R, -n options (all new) % print holiday text in otherwise-wasted space next to date % use larger text for dates in large calendars % % 2.0 modified by Andrew W. Rogers: % % skip printing days of week on small calendars % center month and year at top of calendar % use correct algorithm for leap year calculation % get month and day names from main program % use table to determine color (black/gray) of weekdays and holidays % use hanging indent to print continued text lines X /titlefontsize 48 def /weekdayfontsize 12 def /footfontsize 12 def /datefontsize 25 def /savedatefontsize datefontsize def /notesfontsize 6 def /daywidth 100 def /dayheight 80 def /negdaywidth 0 daywidth sub def /negdayheight 0 dayheight sub def /prtnum { 3 string cvs show} def X /drawgrid { % draw calendar boxes X dayfont findfont weekdayfontsize scalefont setfont X 0 1 6 { X /i exch def X submonth 0 eq { X i daywidth mul 40 moveto X day_names i get X daywidth center X } if X i daywidth mul 35 moveto X 1.0 setlinewidth X 0 1 5 { X gsave X daywidth 0 rlineto X 0 negdayheight rlineto X negdaywidth 0 rlineto X closepath stroke X grestore X 0 negdayheight rmoveto X pop } for X } for } def X X /drawnums { % place day numbers on calendar X dayfont findfont datefontsize scalefont setfont X /start startday def X /days ndays def X /fontdiff datefontsize savedatefontsize sub def X /n 0 def X start daywidth mul 5 add 15 fontdiff sub rmoveto X 1 1 days { X /day exch def X gsave X submonth 0 eq { X /gray day_gray day start add 1 sub 7 mod get def X day holidays n get eq { X /gray holiday_gray def X /n n 1 add def X } if X gray { X 0.8 setgray X } if X } if X day prtnum X grestore X day start add 7 mod 0 eq X { X currentpoint exch pop dayheight sub 5 exch moveto X } X { X daywidth 0 rmoveto X } ifelse X } for } def X X /drawfill { % place fill squares on calendar X /start startday def X /days ndays def X 0 35 rmoveto X 1.0 setlinewidth X 0 1 start 1 sub { X gsave X .9 setgray X daywidth 0 rlineto X 0 negdayheight rlineto X negdaywidth 0 rlineto X closepath fill X grestore X daywidth 0 rmoveto X pop } for X submonth 1 eq X { X /lastday 42 def X 600 -365 moveto X } X { X note_block X { X /lastday 39 def X 300 -365 moveto X } X { X /lastday 40 def X 400 -365 moveto X } ifelse X } ifelse X lastday -1 ndays start 1 add add X { X /day exch def X gsave X .9 setgray X daywidth 0 rlineto X 0 negdayheight rlineto X negdaywidth 0 rlineto X closepath fill X grestore X day 7 mod 1 eq X { 600 -365 dayheight add moveto } X { negdaywidth 0 rmoveto } X ifelse X } for } def X X /isleap { % is this a leap year? X year 4 mod 0 eq % multiple of 4 X year 100 mod 0 ne % not century X year 400 mod 0 eq or and % or divisible by 400 } def X /isleap_2 { % is some other year a leap year? X /a_year exch def X a_year 4 mod 0 eq % multiple of 4 X a_year 100 mod 0 ne % not century X a_year 400 mod 0 eq or and % or divisible by 400 } def X /days_month [ 31 28 31 30 31 30 31 31 30 31 30 31 ] def X /ndays { % number of days in this month X days_month month 1 sub get X month 2 eq % Feb X isleap and X { X 1 add X } if } def X /ndays_2 { % number of days in some other month X /a_month exch def X /a_year exch def X days_month a_month 1 sub get X a_month 2 eq % February X a_year isleap_2 and X { 1 add } X if } def X X /startday { % starting day-of-week for this month X /off year 2000 sub def % offset from start of epoch X off X off 4 idiv add % number of leap years X off 100 idiv sub % number of centuries X off 400 idiv add % number of years divisible by 400 X 6 add 7 mod 7 add % offset from Jan 1 2000 X /off exch def X 1 1 month 1 sub { X /idx exch def X days_month idx 1 sub get X idx 2 eq X isleap and X { X 1 add X } if X /off exch off add def X } for X off dayoffset sub 7 add 7 mod % 0--first day of week, 1--second, etc. } def X X /center { % center string in given width X /width exch def X /str exch def width str X stringwidth pop sub 2 div 0 rmoveto str show } def X X /strcat { % concatenate two strings X 2 copy X length exch length X dup 3 -1 roll add X string X dup 0 6 -1 roll putinterval X dup 3 -1 roll 4 -1 roll putinterval } def X X /calendar { X titlefont findfont titlefontsize scalefont setfont X /month_name month_names month 1 sub get def X /yearstring year 10 string cvs def X 0 60 moveto X month_name ( ) strcat yearstring strcat 700 center % month_name show % daywidth 7 mul yearstring stringwidth pop sub 60 moveto % yearstring show X X submonth 0 eq { X titlefont findfont footfontsize scalefont setfont X /bottomrow { dayheight 6 mul 20 sub neg } def X 0 bottomrow moveto X Lfootstring show X daywidth 7 mul Rfootstring stringwidth pop sub X bottomrow moveto X Rfootstring show X daywidth 7 mul Cfootstring stringwidth pop sub 2 div X bottomrow moveto X Cfootstring show X } if X 0 0 moveto X drawnums X 0 0 moveto X drawfill X 0 0 moveto X drawgrid X 0 0 moveto X submonth 0 eq { drawmoons } if } def X X /daytext { X notesfont findfont notesfontsize scalefont setfont X /mytext exch def /myday exch def X startday myday 1 sub add dup 7 mod daywidth mul 2 add % gives column X exch 7 idiv negdayheight mul 6 add % gives row X dup /ypos exch def moveto X /LM currentpoint pop def /RM LM 95 add def X mytext { dup (.p) eq { crlf pop} {prstr ( ) show} ifelse } forall } def X X /holidaytext { X notesfont findfont notesfontsize scalefont setfont X /mytext exch def /myday exch def X startday myday 1 sub add dup 7 mod daywidth mul X myday 10 lt {20} {33} ifelse add % gives column X exch 7 idiv negdayheight mul 27 add % gives row X dup /ypos exch def moveto X /LM currentpoint pop def /RM LM myday 10 lt {75} {60} ifelse add def X /day myday def X do-moon-p { /RM RM 16 sub def } if X mytext { dup (.p) eq { crlf pop} {prstr ( ) show} ifelse } forall } def X X /notetext { X dayfont findfont 12 scalefont setfont X 4 daywidth mul 4 add % title column X 5 negdayheight mul 24 add % title row X moveto X (Notes) show X notesfont findfont notesfontsize scalefont setfont X /mytext exch def X 4 daywidth mul 4 add % gives column X 5 negdayheight mul 16 add % gives row X dup /ypos exch def moveto X /LM currentpoint pop def /RM LM 95 add def X mytext { dup (.p) eq { crlf pop} {prstr ( ) show} ifelse } forall } def X /crlf { X ypos notesfontsize sub /ypos exch def LM ypos moveto } def X /prstr { X dup stringwidth pop currentpoint pop X add RM gt {crlf ( ) show} if show } def X /printmonth { X landscape-p X { 90 rotate 50 -120 translate } X { 0.75 0.75 scale 50 500 translate } X ifelse X /submonth 0 def X calendar X month 1 sub 0 eq X { X /lmonth 12 def X /lyear year 1 sub def X } X { X /lmonth month 1 sub def X /lyear year def X } ifelse X month 1 add 13 eq X { X /nmonth 1 def X /nyear year 1 add def X } X { X /nmonth month 1 add def X /nyear year def X } ifelse X /savemonth month def X /saveyear year def X /submonth 1 def X /savedatefontsize datefontsize def X /year lyear def X /month lmonth def X /datefontsize 48 def X gsave X 500 -365 translate X gsave X .138 .138 scale X 10 -120 translate X calendar X grestore X /submonth 1 def X /year nyear def X /month nmonth def X 100 0 translate X gsave X .138 .138 scale X 10 -120 translate X calendar X grestore X /month savemonth def X /year saveyear def X /submonth 0 def X /datefontsize savedatefontsize def X grestore } def X % Moon functions... X /doy { % year month day doy -- returns the number of the day of the year X /theday exch def X /themonth exch def X /theyear exch def X /dayofyear 0 def X themonth 1 ne { X 1 1 themonth .5 sub { X /mo exch cvi def X /dayofyear theyear mo X ndays_2 X dayofyear add X def X } for X } if X dayofyear theday add } def X /findphase { % Find the difference between any day and the reference day of the full moon % Note: will probably be one off if the reference is a leap year X /thisday exch def X /thismonth exch def X /thisyear exch def X /daysdiff thisyear thismonth thisday doy X fullyear fullmonth fullday doy sub X longer mul def % try to be accurate about it X /yearsdiff thisyear fullyear sub def X yearsdiff 0 ne { X /daysdiff daysdiff yearsdiff daysperyear mul X yearsdiff 100 idiv yearsdiff 400 idiv sub sub add def X } if X daysdiff % return difference in days } def X /shrink { X 2 sqrt div } def X /transmogrify { % Take a real number and 'mod it down' so it is in the range 0->period or % -period->0. The 10000's preserve the accuracy. X 10000 mul cvi X period 10000 mul cvi mod 10000 div } def X /domoon { % draw the moon at the current phase X /phase exch def X X 0 0 radius % might as well push these on now X 0 0 radius X phase halfperiod lt { X 270 90 arc stroke % line on right, fill on left X 0 radius neg moveto X 270 90 arcn X } X { X 90 270 arc stroke % line on left, fill on right X 0 radius neg moveto X 270 90 arc X /phase phase halfperiod sub def % get rid of top halfperiod X } ifelse X X % scale it down to -r(root2) -> r(root2) X /phase phase quartperiod sub rect mul def X X phase % x1 X phase abs shrink % y1 need abs! X phase % x2 X phase abs shrink neg % y2 need abs! X 0 % x3 X radius neg % y3 X curveto X fill } def X /do-moon-p { X draw-moons true eq { X true X } X { X draw-moons 4 eq { X /p startphase day longer mul add X % AWR: tweaked to more accurately select date of X % new/half/full moons -- X % transmogrify neg period add X 0.5 sub transmogrify neg period add def X p 0.00 gt p 1.00 lt and X p 7.38 gt p 8.38 lt and or X p 14.76 gt p 15.76 lt and X p 22.15 gt p 23.15 lt and or X or X } X { X false X } ifelse X } ifelse } def X X /shiftdo { X do-moon-p { X /p startphase day longer mul add transmogrify neg period add def X p domoon X } if } def X X /drawmoons { X % The year/month/day combo below is that of a full moon. Any date of a X % full moon should work, but I haven't tried very many. I wouldn't X % make this reference date fall in a leap year, because wierdness will X % probably happen in findphase. You will probably gain or lose a day X % somewhere. -- MBH X /fullyear 1990 def X /fullmonth 2 def X /fullday 9 def X X /period 29.5306 def X /daysperyear 365.2422 def X /longer daysperyear 365 div def X /halfperiod period 2 div def X /quartperiod period 4 div def X /radius 6 def X /rect radius 2 sqrt mul quartperiod div def X /startphase year month 0 findphase transmogrify dup 0 lt { X period add X } if def X /start startday def X /days year month ndays_2 def X X gsave X 0.1 setlinewidth X newpath X daywidth radius sub 3 sub 35 radius 3 add sub translate X start daywidth mul 0 translate X 1 1 days { X /day exch def X shiftdo X day start add 1 sub 7 mod 6 eq { X daywidth 6 mul neg dayheight neg translate X } X { X daywidth 0 translate X } ifelse X } for X grestore } def SHAR_EOF chmod 0644 pcalinit.ps || echo 'restore of pcalinit.ps failed' Wc_c="`wc -c < 'pcalinit.ps'`" test 11138 -eq "$Wc_c" || echo 'pcalinit.ps: original size 11138, current size' "$Wc_c" fi exit 0