The calday program
Interface
where opts is a series of getopt-style options and data is a set of date values.
If it encounters a permanent error, calday exits 100. If it encounters a temporary error,
calday exits 111. Otherwise it exits 0.
Dates are in either ISO format (YYYY-MM-DD) or basic format (YYYYMMDD).
A date may carry a leading sign character. The ISO format requires at least one
year digit but otherwise permits arbitrary numbers of digits per component. The
basic format requires two digits for month and day, but permits zero or more year
digits.
By default, calday works with dates in ISO format.
Options
General Options:
- -b: Scan dates in basic format. Applies to all date inputs, including subsequent
arguments.
- -f: Read base dates from standard input and not command line.
- -B: Format dates in basic format.
- -y n: Set base date year to n.
- -m n: Set base date month to n.
- -d n: Set base date day to n.
- -Y: Print days in year of base date.
- -M: Print days in month of base date.
- -W: Print days in week of base date.
- -D n: Print n days from base date.
- -L date: Print days by increment to date.
- -i date: Output increment.
- -o date: Pre-range offset.
- -O date: Post-range offset.
- -w weekdays: Print output only if day of week appears in comma-separated
list weekdays. Day 0 is Sunday.
Algorithm
For each input date, calday performs the following steps:
- Normalize to a calendar date.
- Set the date components per y, m, and d.
- Apply the offset accumulated from o options.
- Normalize to a calendar date.
- Calculate the range of dates to print.
- Apply the offset accumulated from O options.
- For each date in range, print the normalized date iff it is in the list of weekdays
specified by w options (all days by default).
Date range determinations with options W, M, Y, D, and L options are mutually exclusive. If
the i option appears, then calday steps through the range in increments given by
the argument to i. Otherwise the increment is one day. The default range is one
day.
Copyright © 2009 by SuperScript Technology, Inc. All rights reserved.