172 lines
5.5 KiB
Groff
172 lines
5.5 KiB
Groff
.TH gregorian "" "" "/rdb Command"
|
|
.PC "Convert column of dates for arithmetic and format change"
|
|
\fBgregorian [ \-ceu ] [ \fIColumn ... \fB] < \fItableorlist\fR
|
|
.PP
|
|
.II "date^Gregorian"
|
|
.II "Gregorian date"
|
|
.II "date^convert"
|
|
The command
|
|
.B gregorian
|
|
converts Julian dates in one or more
|
|
.BR Column s
|
|
to Gregorian date.
|
|
When used with the command
|
|
.BR julian ,
|
|
you can do the following:
|
|
.IP \fB1.\fR 0.3i
|
|
Add days to a date.
|
|
.IP \fB2.\fR
|
|
Subtract days from a date.
|
|
.IP \fB3.\fR
|
|
Subtract two dates to find the number of days between them.
|
|
.IP \fB4.\fR
|
|
Change the format of a date.
|
|
.PP
|
|
A Gregorian date is a string that presents the date of the
|
|
current year, month, and day; for example ``911231''.
|
|
A Julian date, however, is the number of days since the
|
|
beginning of the Julian calendar (January 1, 4713 BC).
|
|
This system is used by astronomers, computer programmers, and other
|
|
people who wish to store dates in a form that can be
|
|
easily translated from one system of dating to another, without having
|
|
to worry about leap years, dates of the births of religious figures, etc.
|
|
Because Julian dates are integers,
|
|
you can subtract one from another to find the number of days between
|
|
two dates.
|
|
.PP
|
|
To perform arithmetic on dates, first use the command
|
|
.B julian
|
|
to convert the dates from Gregorian form to Julian.
|
|
Then, use the command
|
|
.B compute
|
|
to add or subtract the dates (or add a constant to a date).
|
|
Finally, use
|
|
.B gregorian
|
|
to convert the sum or the difference back to Gregorian form.
|
|
.SH Options
|
|
.B gregorian
|
|
recognizes the following options:
|
|
.IP \fB\-c\fR 0.3i
|
|
Output
|
|
\fIcomputer\fR
|
|
date format, i.e., \fIYYMMDD\fR.
|
|
.B /rdb
|
|
uses this format by default for its Gregorian dates
|
|
because it can be sorted and selected in correct numerical sequence.
|
|
.IP \fB\-e\fR
|
|
Output
|
|
.I European
|
|
date format, i.e., \fIDD/MM/YY\fR.
|
|
.IP \fB\-u\fR
|
|
Output
|
|
.I U.S.
|
|
date format, i.e., \fIMM/DD/YY\fR.
|
|
.SH Example
|
|
The first example shows how to add dates.
|
|
Suppose we have a file called
|
|
.BR journal ,
|
|
as follows:
|
|
.DM
|
|
Date Account Debit Credit Description
|
|
------ ------- ----- ------ ----------------------------------
|
|
861222 101 25000 cash from loan
|
|
861222 211.1 25000 loan number #378-14 Bank Amerigold
|
|
861223 150.1 10000 test equipment from Zarkoff
|
|
861223 101 5000 cash payment
|
|
861223 211.2 5000 note payable to Zarkoff Equipment
|
|
861224 130 30000 inventory - parts from CCPSC
|
|
861224 201.1 15000 accounts payable to CCPSC
|
|
861224 101 15000 cash payment to CCPSC for parts
|
|
.DE
|
|
.PP
|
|
Now, suppose that we want to add 45 days to each of the dates.
|
|
First, see what
|
|
.B julian
|
|
does.
|
|
Typing
|
|
.DM
|
|
julian Date < journal
|
|
.DE
|
|
.PP
|
|
prints the following on the standard output:
|
|
.DM
|
|
Date Account Debit Credit Description
|
|
------ ------- ----- ------ ----------------------------------
|
|
1752827 101 25000 cash from loan
|
|
1752827 211.1 25000 loan number #378-14 Bank Amerigold
|
|
1752828 150.1 10000 test equipment from Zarkoff
|
|
1752828 101 5000 cash payment
|
|
1752828 211.2 5000 note payable to Zarkoff Equipment
|
|
1752829 130 30000 inventory - parts from CCPSC
|
|
1752829 201.1 15000 accounts payable to CCPSC
|
|
1752829 101 15000 cash payment to CCPSC for parts
|
|
.DE
|
|
.PP
|
|
The
|
|
.B Date
|
|
column now holds a Julian date.
|
|
Note we gave no option because computer format is the default.
|
|
.PP
|
|
The next command adds 45 days to each entry in the
|
|
.B Date
|
|
column:
|
|
.DM
|
|
julian Date < journal | compute 'Date += 45' | gregorian Date
|
|
.DE
|
|
.PP
|
|
This command prints the following on the standard output:
|
|
.DM
|
|
Date Account Debit Credit Description
|
|
------ ------- ----- ------ ----------------------------------
|
|
870205 101 25000 cash from loan
|
|
870205 211.1 25000 loan number #378-14 Bank Amerigold
|
|
870206 150.1 10000 test equipment from Zarkoff
|
|
870206 101 5000 cash payment
|
|
870206 211.2 5000 note payable to Zarkoff Equipment
|
|
870207 130 30000 inventory - parts from CCPSC
|
|
870207 201.1 15000 accounts payable to CCPSC
|
|
870207 101 15000 cash payment to CCPSC for parts
|
|
.DE
|
|
.PP
|
|
As you can see, every date is now 45 days later than they originally were.
|
|
.PP
|
|
The next example converts one format of Gregorian date to another.
|
|
To convert the
|
|
.B Date
|
|
column in our example table from computer format to U.S. format,
|
|
type the following:
|
|
.DM
|
|
julian Date < journal | gregorian -u Date | justify Date
|
|
.DE
|
|
.PP
|
|
The result is as follows:
|
|
.DM
|
|
Date Account Debit Credit Description
|
|
-------- ------- ----- ------ ----------------------------------
|
|
12/22/86 101 25000 cash from loan
|
|
12/22/86 211.1 25000 loan number #378-14 Bank Amerigold
|
|
12/23/86 150.1 10000 test equipment from Zarkoff
|
|
12/23/86 101 5000 cash payment
|
|
12/23/86 211.2 5000 note payable`to Zarkoff Equipment
|
|
12/24/86 130 30000 inventory - parts from CCPSC
|
|
12/24/86 201.1 15000 accounts payable to CCPSC
|
|
12/24/86 101 15000 cash payment to CCPSC for parts
|
|
.DE
|
|
.PP
|
|
Because the U.S. format is two characters wider than the
|
|
computer format, we included the command
|
|
.B justify
|
|
in our command line to line things up.
|
|
.SH "See Also"
|
|
.B
|
|
compute,
|
|
computedate,
|
|
julian
|
|
.R
|
|
.br
|
|
COHERENT Lexicon:
|
|
.B
|
|
awk,
|
|
date
|
|
.R
|