rename the command
Also delete docs for now. I don't know how to test manpages.
This commit is contained in:
parent
fb046c5d9a
commit
4872a9dfbe
8
Makefile
8
Makefile
|
@ -1,11 +1,7 @@
|
|||
PROG = ncal
|
||||
SRC = ncal.c calendar.c easter.c
|
||||
PROG = calpick
|
||||
SRC = calpick.c calendar.c easter.c
|
||||
FLAGS = -D_GNU_SOURCE -include bsd/string.h
|
||||
|
||||
LIBS += -ltinfo -lbsd -lncursesw
|
||||
|
||||
include config.mk
|
||||
|
||||
install-2:
|
||||
(cd $(bindir); ln -sf ncal cal)
|
||||
(cd $(mandir); ln -sf ncal.1 cal.1)
|
||||
|
|
15
README.md
15
README.md
|
@ -1,13 +1,26 @@
|
|||
Fork of the unix `cal` command (from https://packages.ubuntu.com/focal/bsdmainutils)
|
||||
that acts as an interactive date picker.
|
||||
|
||||
## Build
|
||||
## Getting started
|
||||
|
||||
```
|
||||
sudo apt build-dep bsdmainutils
|
||||
make
|
||||
```
|
||||
|
||||
Now try it out:
|
||||
|
||||
```
|
||||
./calpick -y > out
|
||||
```
|
||||
|
||||
You should see a display similar to `cal` or `ncal`. Most commandline args
|
||||
continue to work. In addition you will be able to move the highlighted date
|
||||
using arrow keys. To select a date, hit enter. You'll exit the date picker and
|
||||
the date you picked will be in file `out`.
|
||||
|
||||
## Known issues
|
||||
|
||||
Cursor can be moved out of the visible calendar.
|
||||
|
||||
There's no man page. `man ncal` should almost entirely be applicable.
|
||||
|
|
203
calendar.3
203
calendar.3
|
@ -1,203 +0,0 @@
|
|||
.\" Copyright (c) 1997 Wolfgang Helbig
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
.\" are met:
|
||||
.\" 1. Redistributions of source code must retain the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer.
|
||||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer in the
|
||||
.\" documentation and/or other materials provided with the distribution.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $FreeBSD: head/lib/libcalendar/calendar.3 267773 2014-06-23 08:23:05Z bapt $
|
||||
.\"
|
||||
.Dd November 29, 1997
|
||||
.Dt CALENDAR 3
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm easterg ,
|
||||
.Nm easterog ,
|
||||
.Nm easteroj ,
|
||||
.Nm gdate ,
|
||||
.Nm jdate ,
|
||||
.Nm ndaysg ,
|
||||
.Nm ndaysj ,
|
||||
.Nm week ,
|
||||
.Nm weekday
|
||||
.Nd Calendar arithmetic for the Christian era
|
||||
.Sh LIBRARY
|
||||
.Lb libcalendar
|
||||
.Sh SYNOPSIS
|
||||
.In calendar.h
|
||||
.Ft struct date *
|
||||
.Fn easterg "int year" "struct date *dt"
|
||||
.Ft struct date *
|
||||
.Fn easterog "int year" "struct date *dt"
|
||||
.Ft struct date *
|
||||
.Fn easteroj "int year" "struct date *dt"
|
||||
.Ft struct date *
|
||||
.Fn gdate "int nd" "struct date *dt"
|
||||
.Ft struct date *
|
||||
.Fn jdate "int nd" "struct date *dt"
|
||||
.Ft int
|
||||
.Fn ndaysg "struct date *dt"
|
||||
.Ft int
|
||||
.Fn ndaysj "struct date *dt"
|
||||
.Ft int
|
||||
.Fn week "int nd" "int *year"
|
||||
.Ft int
|
||||
.Fn weekday "int nd"
|
||||
.Sh DESCRIPTION
|
||||
These functions provide calendar arithmetic for a large range of years,
|
||||
starting at March 1st, year zero (i.e., 1 B.C.) and ending way beyond
|
||||
year 100000.
|
||||
.Pp
|
||||
Programs should be linked with
|
||||
.Fl lcalendar .
|
||||
.Pp
|
||||
The functions
|
||||
.Fn easterg ,
|
||||
.Fn easterog
|
||||
and
|
||||
.Fn easteroj
|
||||
store the date of Easter Sunday into the structure pointed at by
|
||||
.Fa dt
|
||||
and return a pointer to this structure.
|
||||
The function
|
||||
.Fn easterg
|
||||
assumes Gregorian Calendar (adopted by most western churches after 1582) and
|
||||
the functions
|
||||
.Fn easterog
|
||||
and
|
||||
.Fn easteroj
|
||||
compute the date of Easter Sunday according to the orthodox rules
|
||||
(Western churches before 1582, Greek and Russian Orthodox Church
|
||||
until today).
|
||||
The result returned by
|
||||
.Fn easterog
|
||||
is the date in Gregorian Calendar, whereas
|
||||
.Fn easteroj
|
||||
returns the date in Julian Calendar.
|
||||
.Pp
|
||||
The functions
|
||||
.Fn gdate ,
|
||||
.Fn jdate ,
|
||||
.Fn ndaysg
|
||||
and
|
||||
.Fn ndaysj
|
||||
provide conversions between the common "year, month, day" notation
|
||||
of a date and the "number of days" representation, which is better suited
|
||||
for calculations.
|
||||
The days are numbered from March 1st year 1 B.C., starting
|
||||
with zero, so the number of a day gives the number of days since March 1st,
|
||||
year 1 B.C.
|
||||
The conversions work for nonnegative day numbers only.
|
||||
.Pp
|
||||
The
|
||||
.Fn gdate
|
||||
and
|
||||
.Fn jdate
|
||||
functions
|
||||
store the date corresponding to the day number
|
||||
.Fa nd
|
||||
into the structure pointed at by
|
||||
.Fa dt
|
||||
and return a pointer to this structure.
|
||||
.Pp
|
||||
The
|
||||
.Fn ndaysg
|
||||
and
|
||||
.Fn ndaysj
|
||||
functions
|
||||
return the day number of the date pointed at by
|
||||
.Fa dt .
|
||||
.Pp
|
||||
The
|
||||
.Fn gdate
|
||||
and
|
||||
.Fn ndaysg
|
||||
functions
|
||||
assume Gregorian Calendar after October 4, 1582 and Julian Calendar before,
|
||||
whereas
|
||||
.Fn jdate
|
||||
and
|
||||
.Fn ndaysj
|
||||
assume Julian Calendar throughout.
|
||||
.Pp
|
||||
The two calendars differ by the definition of the leap year.
|
||||
The
|
||||
Julian Calendar says every year that is a multiple of four is a
|
||||
leap year.
|
||||
The Gregorian Calendar excludes years that are multiples of
|
||||
100 and not multiples of 400.
|
||||
This means the years 1700, 1800, 1900, 2100 are not leap years
|
||||
and the year 2000 is
|
||||
a leap year.
|
||||
The new rules were inaugurated on October 4, 1582 by deleting ten
|
||||
days following this date.
|
||||
Most catholic countries adopted the new
|
||||
calendar by the end of the 16th century, whereas others stayed with
|
||||
the Julian Calendar until the 20th century.
|
||||
The United Kingdom and
|
||||
their colonies switched on September 2, 1752.
|
||||
They already had to
|
||||
delete 11 days.
|
||||
.Pp
|
||||
The function
|
||||
.Fn week
|
||||
returns the number of the week which contains the day numbered
|
||||
.Fa nd .
|
||||
The argument
|
||||
.Fa *year
|
||||
is set with the year that contains (the greater part of) the week.
|
||||
The weeks are numbered per year starting with week 1, which is the
|
||||
first week in a year that includes more than three days of the year.
|
||||
Weeks start on Monday.
|
||||
This function is defined for Gregorian Calendar only.
|
||||
.Pp
|
||||
The function
|
||||
.Fn weekday
|
||||
returns the weekday (Mo = 0 ..\& Su = 6) of the day numbered
|
||||
.Fa nd .
|
||||
.Pp
|
||||
The structure
|
||||
.Fa date
|
||||
is defined in
|
||||
.In calendar.h .
|
||||
It contains these fields:
|
||||
.Bd -literal -offset indent
|
||||
int y; /\(** year (0000 - ????) \(**/
|
||||
int m; /\(** month (1 - 12) \(**/
|
||||
int d; /\(** day of month (1 - 31) \(**/
|
||||
.Ed
|
||||
.Pp
|
||||
The year zero is written as "1 B.C." by historians and "0" by astronomers
|
||||
and in this library.
|
||||
.Sh SEE ALSO
|
||||
.Xr ncal 1 ,
|
||||
.Xr strftime 3
|
||||
.Sh STANDARDS
|
||||
The week number conforms to ISO 8601: 1988.
|
||||
.Sh HISTORY
|
||||
The
|
||||
.Nm calendar
|
||||
library first appeared in
|
||||
.Fx 3.0 .
|
||||
.Sh AUTHORS
|
||||
This manual page and the library was written by
|
||||
.An Wolfgang Helbig Aq Mt helbig@FreeBSD.org .
|
||||
.Sh BUGS
|
||||
The library was coded with great care so there are no bugs left.
|
|
@ -14,13 +14,11 @@ DESTDIR ?=
|
|||
# are able to specify additional installation rules.
|
||||
# * To set additional linker flags, set the LDFLAGS variable in the
|
||||
# program Makefile.
|
||||
# * To specify a non-standard manpage, set the MAN variable.
|
||||
# * To add post-installation commands, define an install-2 target.
|
||||
# * To add additional sources, set the SRC variable.
|
||||
|
||||
# setup some defaults
|
||||
SRC ?= $(PROG).c
|
||||
MAN ?= $(PROG).1
|
||||
|
||||
sysconfdir=$(DESTDIR)/etc
|
||||
datadir=$(DESTDIR)/usr/share
|
||||
|
@ -44,7 +42,6 @@ endif
|
|||
# normal installation rule
|
||||
install-1: $(PROG)
|
||||
install -o root -g root -m 755 $(PROG) $(bindir)
|
||||
install -o root -g root -m 644 $(MAN) $(mandir)
|
||||
|
||||
install: install-1 install-2
|
||||
|
||||
|
|
248
ncal.1
248
ncal.1
|
@ -1,248 +0,0 @@
|
|||
.\" Copyright (c) 1997 Wolfgang Helbig
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
.\" are met:
|
||||
.\" 1. Redistributions of source code must retain the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer.
|
||||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer in the
|
||||
.\" documentation and/or other materials provided with the distribution.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $FreeBSD: head/usr.bin/ncal/ncal.1 267773 2014-06-23 08:23:05Z bapt $
|
||||
.\"
|
||||
.Dd March 14, 2009
|
||||
.Dt CAL 1
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm cal ,
|
||||
.Nm ncal
|
||||
.Nd displays a calendar and the date of Easter
|
||||
.Sh SYNOPSIS
|
||||
.Nm
|
||||
.Op Fl 31jy
|
||||
.Op Fl A Ar number
|
||||
.Op Fl B Ar number
|
||||
.Op Fl d Ar yyyy-mm
|
||||
.Oo
|
||||
.Op Ar month
|
||||
.Ar year
|
||||
.Oc
|
||||
.Nm
|
||||
.Op Fl 31j
|
||||
.Op Fl A Ar number
|
||||
.Op Fl B Ar number
|
||||
.Op Fl d Ar yyyy-mm
|
||||
.Fl m Ar month
|
||||
.Op Ar year
|
||||
.Nm ncal
|
||||
.Op Fl C
|
||||
.Op Fl 31jy
|
||||
.Op Fl A Ar number
|
||||
.Op Fl B Ar number
|
||||
.Op Fl d Ar yyyy-mm
|
||||
.Oo
|
||||
.Op Ar month
|
||||
.Ar year
|
||||
.Oc
|
||||
.Nm ncal
|
||||
.Op Fl C
|
||||
.Op Fl 31j
|
||||
.Op Fl A Ar number
|
||||
.Op Fl B Ar number
|
||||
.Op Fl d Ar yyyy-mm
|
||||
.Fl m Ar month
|
||||
.Op Ar year
|
||||
.Nm ncal
|
||||
.Op Fl 31bhjJpwySM
|
||||
.Op Fl A Ar number
|
||||
.Op Fl B Ar number
|
||||
.Op Fl H Ar yyyy-mm-dd
|
||||
.Op Fl d Ar yyyy-mm
|
||||
.Op Fl s Ar country_code
|
||||
.Oo
|
||||
.Op Ar month
|
||||
.Ar year
|
||||
.Oc
|
||||
.Nm ncal
|
||||
.Op Fl 31bhJeoSM
|
||||
.Op Fl A Ar number
|
||||
.Op Fl B Ar number
|
||||
.Op Fl d Ar yyyy-mm
|
||||
.Op Ar year
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Nm
|
||||
utility displays a simple calendar in traditional format and
|
||||
.Nm ncal
|
||||
offers an alternative layout, more options and the date of Easter.
|
||||
The new format is a little cramped but it makes a year fit
|
||||
on a 25x80 terminal.
|
||||
If arguments are not specified,
|
||||
the current month is displayed.
|
||||
.Pp
|
||||
The options are as follows:
|
||||
.Bl -tag -width indent
|
||||
.It Fl J
|
||||
Display Julian Calendar, if combined with the
|
||||
.Fl o
|
||||
option, display date of Orthodox Easter according to the Julian Calendar.
|
||||
.It Fl e
|
||||
Display date of Easter (for western churches).
|
||||
.It Fl j
|
||||
Display Julian days (days one-based, numbered from January 1).
|
||||
.It Fl m Ar month
|
||||
Display the specified
|
||||
.Ar month .
|
||||
If
|
||||
.Ar month
|
||||
is specified as a decimal number, appending
|
||||
.Ql f
|
||||
or
|
||||
.Ql p
|
||||
displays the same month of the following or previous year respectively.
|
||||
.It Fl o
|
||||
Display date of Orthodox Easter (Greek and Russian
|
||||
Orthodox Churches).
|
||||
.It Fl p
|
||||
Print the country codes and switching days from Julian to Gregorian
|
||||
Calendar as they are assumed by
|
||||
.Nm ncal .
|
||||
The country code as determined from the local environment is marked
|
||||
with an asterisk.
|
||||
.It Fl s Ar country_code
|
||||
Assume the switch from Julian to Gregorian Calendar at the date
|
||||
associated with the
|
||||
.Ar country_code .
|
||||
If not specified,
|
||||
.Nm ncal
|
||||
tries to guess the switch date from the local environment or
|
||||
falls back to September 2, 1752.
|
||||
This was when Great
|
||||
Britain and her colonies switched to the Gregorian Calendar.
|
||||
.It Fl w
|
||||
Print the number of the week below each week column.
|
||||
.It Fl y
|
||||
Display a calendar for the specified year. This option is implied when
|
||||
a year but no month are specified on the command line.
|
||||
.It Fl 3
|
||||
Display the previous, current and next month surrounding today.
|
||||
.It Fl 1
|
||||
Display only the current month. This is the default.
|
||||
.It Fl A Ar number
|
||||
Months to add after. The specified number of months is added to the
|
||||
end of the display. This is in addition to any date range selected by the
|
||||
.Fl y ,
|
||||
.Fl 3 ,
|
||||
or
|
||||
.Fl 1
|
||||
options. For example,
|
||||
.Dq Li cal -y -B2 -A2
|
||||
shows everything from November of the previous year to
|
||||
February of the following year. Negative numbers are allowed, in which
|
||||
case the specified number of months is subtracted. For example,
|
||||
.Dq Li cal -y -B-6
|
||||
shows July to December. And
|
||||
.Dq Li cal -A11
|
||||
simply shows the next 12 months.
|
||||
.It Fl B Ar number
|
||||
Months to add before. The specified number of months is added to the
|
||||
beginning of the display. See
|
||||
.Fl A
|
||||
for examples.
|
||||
.It Fl C
|
||||
Completely switch to
|
||||
.Nm cal
|
||||
mode. For
|
||||
.Nm cal
|
||||
like output only, use
|
||||
.Fl b
|
||||
instead.
|
||||
.It Fl N
|
||||
Switch to
|
||||
.Nm ncal
|
||||
mode.
|
||||
.It Fl d Ar yyyy-mm
|
||||
Use
|
||||
.Ar yyyy-mm
|
||||
as the current date (for debugging of date selection).
|
||||
.It Fl H Ar yyyy-mm-dd
|
||||
Use
|
||||
.Ar yyyy-mm-dd
|
||||
as the current date (for debugging of highlighting).
|
||||
.It Fl M
|
||||
Weeks start on Monday.
|
||||
.It Fl S
|
||||
Weeks start on Sunday.
|
||||
.It Fl b
|
||||
Use oldstyle format for ncal output.
|
||||
.El
|
||||
.Pp
|
||||
A single parameter specifies the year (1\(en9999) to be displayed;
|
||||
note the year must be fully specified:
|
||||
.Dq Li cal 89
|
||||
will
|
||||
.Em not
|
||||
display a calendar for 1989. Two parameters denote the month and
|
||||
year; the month is either a number between 1 and 12, or a full or
|
||||
abbreviated name as specified by the current locale. Month and
|
||||
year default to those of the current system clock and time zone (so
|
||||
.Dq Li cal -m 8
|
||||
will display a calendar for the month of August in the current
|
||||
year).
|
||||
.Pp
|
||||
Not all options can be used together. For example, the options
|
||||
.Fl y , 3 ,
|
||||
and
|
||||
.Fl 1
|
||||
are mutually exclusive. If inconsistent options are given, the later
|
||||
ones take precedence over the earlier ones.
|
||||
.Pp
|
||||
A year starts on January 1.
|
||||
.Pp
|
||||
Highlighting of dates is disabled if stdout is not a tty.
|
||||
.Sh SEE ALSO
|
||||
.Xr calendar 3 ,
|
||||
.Xr strftime 3
|
||||
.Sh HISTORY
|
||||
A
|
||||
.Nm
|
||||
command appeared in
|
||||
.At v5 .
|
||||
The
|
||||
.Nm ncal
|
||||
command appeared in
|
||||
.Fx 2.2.6 .
|
||||
The output of the
|
||||
.Nm cal
|
||||
command is supposed to be bit for bit compatible to the original Unix
|
||||
.Nm cal
|
||||
command, because its output is processed by other programs like CGI scripts,
|
||||
that should not be broken. Therefore it will always output 8 lines, even if
|
||||
only 7 contain data. This extra blank line also appears with the original
|
||||
.Nm cal
|
||||
command, at least on Solaris 8
|
||||
.Sh AUTHORS
|
||||
The
|
||||
.Nm ncal
|
||||
command and manual were written by
|
||||
.An Wolfgang Helbig Aq Mt helbig@FreeBSD.org .
|
||||
.Sh BUGS
|
||||
The assignment of Julian\(enGregorian switching dates to country
|
||||
codes is historically naive for many countries.
|
||||
.Pp
|
||||
Not all options are compatible and using them in different orders
|
||||
will give varying results.
|
Loading…
Reference in New Issue