[go: up one dir, main page]

Menu

[r372]: / libpetey / date_calc.1  Maximize  Restore  History

Download this file

66 lines (64 with data), 1.8 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
.TH date_calc 1 2013-07-31
.SH NAME
date_calc -- A date calculator.
.SH SYNOPSIS
.HP
date_calc [-f ["]format["]] [-h] [["]commands["]]
.SH DESCRIPTION
The date calculator,
.B "date_calc",
is an interactive utility for
performing calculations with dates and times just as you
would with floating point numbers on a pocket calculater.
.B date_calc
also handles floating point calculations.
.SH OPTIONS
.SS -f ["]format["]
Specifies the output format for the calculations. Uses the same format codes
as the
.B date
command.
.SS -h
Print this help screen.
.SH INPUT FORMAT
Dates must be in the following format, as specified using the
.B date
style format codes:
.P
%Y/%m[/%d[-%H[:%M[:%S]]]]
.P
where the seconds field (%S) can be expressed as a decimal.
Alternatively:
.P
%H:%M[:%S]
.SH OPERATORS
The date calculator accepts the four arithmetic operators.
Addition and multiplication are given by the usual symbols,
+ and *, respectively, however
because the symbols normally used for subtraction and division are used
to specify dates, we use instead, _ and | respectively.
Note that multiplication must combine either a date and a number or two
numbers.
It follows then, that if you divide a date by a date, you get back a number,
while dividing a date with a number returns a date.
.SH EXAMPLES
I was born on December 22, 1973 at eight o'clock in the morning. How many
hours have I been alive?
.P
$ date_calc "(2013/8/1_1973/12/22-8)|1:0"
.P
which returns:
.P
347200
.P
I have some climate data starting January 1, 1948 with fields every six hours.
I need the date of the 20165th field (zero-based) and I need to print it out
in a format convenient for turning into a file name:
.P
$ date_calc -f "%Y.%m.%d.%H" "1948/1/1+6:0*20165"
.P
1961.10.20.06
.SH SEE ALSO
date
.SH AUTHOR
Peter Mills (petey@peteysoft.org)