-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathptc.1
128 lines (128 loc) · 2.76 KB
/
ptc.1
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
.\" Copyright (c) 2014, Dmitrij D. Czarkoff
.\"
.\" Permission to use, copy, modify, and distribute this software for any
.\" purpose with or without fee is hereby granted, provided that the above
.\" copyright notice and this permission notice appear in all copies.
.\"
.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
.Dd $Mdocdate: February 17 2014$
.Dt PTC 1
.Os
.Sh NAME
.Nm ptc
.Nd calculate time
.Sh SYNOPSIS
.Nm
.Sh DESCRIPTION
.Nm
is a stacking (reverse Polish) calculator similar to
.Xr dc 1 ,
but crafted towards time calculation.
.Nm
reads commands from standard input and performs requested operations.
Currently the following constructions are recognized:
.Bl -tag -width "number"
.It Va number
The value of the number is pushed on the stack. The values are parsed
according to the following rules:
.Bl -enum
.It
If value contains
.Sq \&.
.Pq dot ,
it is assumed to be in format
.Do
.Sm off
.Oo Oo Oo
.Ar HH: Oc
.Ar MM: Oc
.Ar SS Oc No \&. Ns Op Ar MSS
.Sm on
.Dc .
.It
If value contains
.Sq \:
.Pq column ,
it is assumed to be in format
.Do
.Sm off
.Ar HH:MM
.Oo Ar :SS
.Oc
.Sm on
.Dc
.It
If value contains only digits, it is assumed to be expressed in
.Em milliseconds .
Value may also contain specifiers
.Sq d ,
.Sq h ,
.Sq m ,
or
.Sq s
for
.Em days ,
.Em hours ,
.Em minutes ,
or
.Em seconds .
.El
where
.Sq HH ,
.Sq MM ,
.Sq SS
and
.Sq MSS
stand for
.Em hours ,
.Em minutes ,
.Em seconds
and
.Em milliseconds
respectively. Negative numbers are denoted with
.Sq _
.Pq underscore .
.It Cm "+ - / * %"
The top two values on the stack are added
.Pq + ,
substracted
.Pq \- ,
multiplied
.Pq * ,
divided
.Pq / ,
or remaindered
.Pq % .
The two entries are popped off the stack;
the result is pushed on the stack in their place.
.It Ic t
Pop all the values on the stack and push their total.
.It Ic p
The top value on the stack is printed with a trailing newline.
The top value remains unchanged.
.El
.Sh SEE ALSO
.Xr dc 1
.Sh AUTHORS
.An -nosplit
The
.Nm
utility was written by
.An Dmitrij D. Czarkoff Aq [email protected] .
.Sh CAVEATS
In
.Nm
time values are internally represented as integer amounts of milliseconds.
While theoretically this approach improves the precision of operations, the
result of devision operation suffers from rounding.
.Pp
.Nm
is currently in early stages of development, so anything may be subject to
future changes.