The caldaytime 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, caldaytime exits 100. If it encounters a temporary
error, caldaytime exits 111. Otherwise it exits 0.
Dates are in either ISO format (YYYY-MM-DDThh:mm:ssXhhmm) or basic format
(YYYYMMDDhhmmss). 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.
Whitespace may appear in place of the literal T, and before the sign X, which is either + or -.
The timezone offset hhmm must consist of four characters, two for hours and two for
minutes. The basic format requires two digits for month, day, hour, minute, and second, but
permits zero or more year digits. The basic format does not support a timezone
offset.
By default, caldaytime works with dates in ISO format.
Options
General Options:
- -b: Scan datetimes in basic format. Applies to all datetime inputs, including
subsequent arguments.
- -f: Read base datetimes from standard input and not command line.
- -B: Format datetimes in basic format.
- -y n: Set base datetime year to n.
- -m n: Set base datetime month to n.
- -d n: Set base datetime day to n.
- -h n: Set base datetime hour to n.
- -u n: Set base datetime minute to n.
- -s n: Set base datetime second to n.
- -z n: Set base datetime timezone offset to n.
- -Y: Print days in year of base datetime.
- -M: Print days in month of base datetime.
- -W: Print days in week of base datetime.
- -D n: Print n days from base datetime.
- -L datetime: Print days by increment to datetime.
- -i datetime: Output increment.
- -o datetime: Pre-range offset.
- -O datetime: 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, caldaytime performs the following steps:
- Normalize to a calendar date.
- Set the datetime components per y, m, d, h, u, s, and z options.
- 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 caldaytime 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.