by Alex Matulich,
Unicorn Research Corporation
Version 4.1
By default, cal will display a calendar for the current month with the current day marked. By specifing certain arguments, cal will display a calendar for a whole year or a specified month and year.
The transition from the Julian to Gregorian calendar is assumed to have occured in 1752 on the 3rd of September. Ten days following that date were eliminated by the reformation, so the calendar for that month is a bit unusual.
If displaying a calendar in the single-month format, cal will look for a date file. If found, cal will read the file, looking for special date descriptions for that month which will be displayed to the right of the calendar. By default, up to 24 appointments may be displayed per month. If the current date happens to fall on one of these special dates, it will be flagged by an asterisk. If there is room, appointments for the next month may also be displayed with some limitations (currently, special dates such as the 3rd Thursday of will not be calculated for next month).
cal can also optionally use colors when displaying the calendar. It will not display colors any time the calendar is not directly displaying on the console. This is generally the desired behavior when your redirecting cal's output to another program or a file.
A verbally-specified month may be entered without specifying a year in the argument list; however, a single numerical argument will be interpreted as a year. Only the first 3 characters of the month name are significant for a verbally-specified month. NOTE: The command "cal 10" refers to 10 AD, not October, and not 1910.
The available options are:
There is an optional environment variable that can be used by cal if found. If CALOPT is set then cal will read it and use any valid command line options found. This allows any commonly used switches to be set in your environment and always used (e.g. --europe). Cal will produce its usage screen when run if any invalid options are set in this variable.
cal will search for a date file called cal.dat in the directory it was executed from. If not found it will search in the users $HOME directory for a file called .cal.dat. If still not found, it will look for a global cal.dat in a system wide directory. To find out where this location is you can run cal --help which will display the location.
The special date descriptions specified in the date file are single lines, formatted as follows:
YYYY MM DD NW xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
where
The data MUST occupy the character fields as shown. If YYYY is specified as -999, the month and day are assumed to be annual events such as holidays, and the description will be displayed for any year. If MM is specified as -9, the day is assumed to be a monthly event for the specified year. In the weekday-of-month code NW, N signifies on which weekday W the special date occurs. For example, 31 indicates the third sunday. Values of W range from 1 to 7, for Sunday to Saturday, respectively. A value of 9 for N indicates "last" as in 95 for "last thursday."
If ALL of the fields contain a positive number and the year is at least 1970, then the description is assumed to be periodic, starting at the given date, with the period in days specified in NW (e.g. 1995 01 06 14 will display the description every 2nd Friday using 6 January 1995 as the base date). The base date does not get displayed.
You can display birthdays and anniversaries by putting the year of birth (or other special event) inside brackets or braces, in the description. This number is converted to the number of years since the year you indicate and the brackets or braces are removed from the output. If braces {} are used the number will have an ordinal suffix, as in 21st, 32nd, 43rd, 54th, etc. If the number in brackets or braces is greater than the current year, the number will be displayed unchanged. Example: "Alex's {1961} birthday" will display as "Alex's 34th birthday" (if the current year is 1995). If you need to include brackets or braces in your output then you can escape them by prefixing it with a '\'. Example: "Alex's \{1961\} birthday" will be displayed as "Alex's {1961} birthday".
NOTE: If cal is invoked with the --europe or --monday switch, then the W values 1-7 denote Monday(1) to Sunday(7) rather than Sunday(1) to Saturday(7).
A line in cal.dat must start with -999 or a 4-digit number to be considered as data. The data lines may be in any order. All these appointments will be displayed in chronological order, regardless of the ordering in the appointment data file.
If cal was compiled with the reminder support then call will also search for the files dates and .dates in the same places as for the cal.dat equivalents. The dates file is used by the reminder(1) program and is an alternate, less-powerful format for specifying descriptions. A file in this format cannot be specified with the --data-file= option.
The reminder format consists of text lines of length < screen width in the following format:
DDDDDDDD:N:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx:yyyyyy:S
where
Blank lines are ignored. A line otherwise not in the above format is assume to specify a file name from which to read more events. The file is searched for in the usual places.
cal will search for a color definition file called cal.col in the directory it was executed from. If not found it will search in the users $HOME directory for a file called .cal.col. If still not found, it will look for a global cal.col in a system wide directory. To find out where this location is you can run cal --help which will display the location.
Users may override the default colors used when displaying calendars. This may be done by creating a color definition file.
Example of a color definition file:
Color definitions must appear as above, as a two-character field for the foreground color, followed by a space, folowed by a two-character field for the background color. The color definitions must start on the first line, and must not contain blank lines. Comments may appear after the second field, provided that the total line length does not exceed 80 characters.
Specifying a background color from 8 to 15 will result in a background color of 0 to 7, with flashing text.
Cal 4.0 had a bug where the line in cal.dat
-999 06 00 16 National Donut Day {1938}
would not display on the correct day. Fixed in 4.1.
Also corrected segfault when running under web environments where $HOME is not set. Fixed in 4.1.
The latest version of cal is available from http://unicorn.us.com/pub/cal41.zip
Alex Matulich - alex@unicorn.us.com
...with enhancements and modifications by other contributors.
© 1993-2002 by Unicorn Research Corporationdate(1), reminder(1), rs(1)