Skip to content

Commit b8747ff

Browse files
committed
Simplify verbose modes in the main function.
In the main function, verbose falgs "-v" change the layout of what is printed out. The first -v would print two result formats,a nd teh subsequent two -vv would print either one of the two. Now, single -v prints only the various single-unit results, double -vv prints compound time range only,a nd thrice -vv prints AST-style compound rage only. This does not change printing a target single-unit result (when the last argument of the command line invocation is "y", "mo", and "d" for example. This does not change the table layout option, either, meaning that to print the table layout now user may set simply "-vt". Update README.md, help and man pages.
1 parent 9dca740 commit b8747ff

File tree

7 files changed

+46
-38
lines changed

7 files changed

+46
-38
lines changed

README.md

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,11 @@ Setting the last argument of the command line to exactly `y`, `mo`, `w`, `d`, `m
5454

5555
Alternatively, set `options -vvv` to filter the main output layout for specific fields.
5656

57-
For example, print the **compound time range** only:
57+
For example, print the **compound time range** _only_:
5858

5959

6060
```
61-
% datediff.sh -vvv tomorrow+6years+400hours+12seconds
61+
% datediff.sh -vv tomorrow+6years+400hours+12seconds
6262
6363
6Y 00M 02W 03D 16h 00m 12s
6464
```
@@ -71,31 +71,23 @@ prints two sections with processed dates (**DATES**) and time range results (**R
7171

7272
The user can filter out which fields are going to be calculated and printed.
7373

74-
Set the verbose `option -v` up to four times to select different layouts.
74+
Set the verbose `option -v` up to three times to select different layouts in
75+
the main function. Setting `-v` in other functions decrease verbose.
7576

7677

77-
Compound time range and all single unit results:
78+
All single unit results _only_:
7879

7980
```
8081
% datediff.sh -v 2008-01-15
8182
82-
16Y 10M 00W 03D 21h 24m 19s
83-
16.8 years | 378.8 months | 879.0 weeks | 6152.9 days | 147669.4 hours | 8860164.3 mins | 531609859 secs
84-
```
85-
86-
All single unit results only:
87-
88-
```
89-
% datediff.sh -vv 2008-01-15
90-
9183
16.8 years | 378.8 months | 879.0 weeks | 6152.9 days | 147669.4 hours | 8860165.2 mins | 531609914 secs
9284
```
9385

9486
<!--
95-
Compound time range only:
87+
Compound time range _only_:
9688
9789
```
98-
% datediff.sh -vvv 2008-01-15
90+
% datediff.sh -vv 2008-01-15
9991
10092
16Y 10M 00W 03D 21h 25m 28s
10193
```
@@ -105,7 +97,7 @@ Compound time range only:
10597
Compound time range (`AST date` style):
10698

10799
```
108-
% datediff.sh -vvvv 2008-01-15
100+
% datediff.sh -vvv 2008-01-15
109101
110102
16Y10M00W03D21h25m34s
111103
```
@@ -143,7 +135,7 @@ must set both `options -ttvv` at the command line incantation:
143135

144136

145137
```
146-
% datediff.sh -3 -ttvv 2008-01-15
138+
% datediff.sh -3 -ttv 2008-01-15
147139
148140
Years 16.844
149141
Months 378.833

datediff.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env ksh
22
# datediff.sh - Calculate time ranges between dates
3-
# v0.25 nov/2024 mountaineerbr GPLv3+
3+
# v0.25.1 dec/2024 mountaineerbr GPLv3+
44
[[ -n $BASH_VERSION ]] && shopt -s extglob #bash2.05b+/ksh93u+/zsh5+
55
[[ -n $ZSH_VERSION ]] && setopt NO_SH_GLOB KSH_GLOB KSH_ARRAYS SH_WORD_SPLIT GLOB_SUBST
66

@@ -1129,7 +1129,7 @@ function mainf
11291129
fi
11301130

11311131
#single unit time durations (when `bc' is available)
1132-
if ((OPTT || OPTVERBOSE<3))
1132+
if ((OPTT || OPTVERBOSE<2))
11331133
then if bc=( $(bc <<<" /* round argument 'x' to 'd' digits */
11341134
define r(x, d) {
11351135
auto r, s
@@ -1226,10 +1226,10 @@ function mainf
12261226
"${date2_iso8601_pr:-${date2_iso8601:-$inputB}}" ''${unix2:+$'\t'} "$unix2" \
12271227
"${BOLD}RANGES${NC}"
12281228
fi
1229-
((OPTVERBOSE<2 || OPTVERBOSE>2)) && { ((OPTVERBOSE>3)) && v= || v=' ' #AST `date -E' style
1229+
((OPTVERBOSE<1 || OPTVERBOSE>1)) && { ((OPTVERBOSE>2)) && v= || v=' ' #AST `date -E' style
12301230
printf "%dY${v}%02dM${v}%02dW${v}%02dD${v}${v}%02dh${v}%02dm${v}%02ds\n" "${sh[@]}"
12311231
}
1232-
((OPTVERBOSE<3)) && printf '%s\n' "${range_pr:-$range secs}"
1232+
((OPTVERBOSE<2)) && printf '%s\n' "${range_pr:-$range secs}"
12331233

12341234
return ${ret:-0}
12351235
}
@@ -1331,7 +1331,7 @@ fi
13311331
#set single time unit
13321332
opt="${opt:-${@: -1}}" opt="${opt//[$IFS]}"
13331333
if [[ $opt$OPTFF = $GLOBOPT ]]
1334-
then OPTT=1 OPTVERBOSE=2 OPTLAYOUT=
1334+
then OPTT=1 OPTVERBOSE=1 OPTLAYOUT=
13351335
case $opt in
13361336
[yY]) OPTTy=1;;
13371337
[mM][oO]) OPTTmo=1;;

man/README.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
---
22
author:
33
- Jamil Soni N
4-
date: November 2024
5-
title: DATEDIFF.SH(1) v0.25 \| General Commands Manual
4+
date: December 2024
5+
title: DATEDIFF.SH(1) v0.25.1 \| General Commands Manual
66
---
77

88
# NAME
@@ -70,7 +70,10 @@ Output “DATES” section prints two dates in **ISO-8601 format** or, if
7070
in the main function. This affects how the `C-code date` programme
7171
process dates.
7272

73-
Set **options -vvv** to print different output layouts.
73+
In the main function, set **options -v** to print only the single-unit
74+
results and **-vv** to print only the compound time range result.
75+
76+
In other function, set **options -v** to decrease verbose.
7477

7578
### Extra Functions
7679

man/datediff.sh.1

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
.\" Automatically generated by Pandoc 3.1.11.1
22
.\"
3-
.TH "DATEDIFF.SH" "1" "November 2024" "v0.25" "General Commands Manual"
3+
.TH "DATEDIFF.SH" "1" "December 2024" "v0.25.1" "General Commands Manual"
44
.SH NAME
55
.PP
66
\ \ \ \f[B]datediff.sh\f[R] \- Calculate time ranges / intervals between
@@ -83,7 +83,11 @@ format\f[R].
8383
(UTC) in the main function.
8484
This affects how the \f[CR]C\-code date\f[R] programme process dates.
8585
.PP
86-
Set \f[B]options \-vvv\f[R] to print different output layouts.
86+
In the main function, set \f[B]options \-v\f[R] to print only the
87+
single\-unit results and \f[B]\-vv\f[R] to print only the compound time
88+
range result.
89+
.PP
90+
In other function, set \f[B]options \-v\f[R] to decrease verbose.
8791
.SS Extra Functions
8892
\f[B]Option \-e\f[R] prints Easter dates for given \f[I]YEARS\f[R] (for
8993
Western Churches) and \f[B]option \-ee\f[R] additionally prints Carnaval

man/datediff.sh.1.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
% DATEDIFF.SH(1) v0.25 | General Commands Manual
1+
% DATEDIFF.SH(1) v0.25.1 | General Commands Manual
22
% Jamil Soni N
3-
% November 2024
3+
% December 2024
44

55

66
# NAME
@@ -67,7 +67,10 @@ Output "DATES" section prints two dates in **ISO-8601 format** or, if
6767
**Option -u** sets or prints dates in Coordinated Universal Time (UTC)
6868
in the main function. This affects how the `C-code date` programme process dates.
6969

70-
Set **options -vvv** to print different output layouts.
70+
In the main function, set **options -v** to print only the single-unit results
71+
and **-vv** to print only the compound time range result.
72+
73+
In other function, set **options -v** to decrease verbose.
7174

7275

7376
### Extra Functions

man/datediff.sh.html

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<meta name="generator" content="pandoc" />
66
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
77
<meta name="author" content="Jamil Soni N" />
8-
<title>DATEDIFF.SH(1) v0.25 | General Commands Manual</title>
8+
<title>DATEDIFF.SH(1) v0.25.1 | General Commands Manual</title>
99
<style>
1010
html {
1111
color: #1a1a1a;
@@ -171,9 +171,9 @@
171171
</head>
172172
<body>
173173
<header id="title-block-header">
174-
<h1 class="title">DATEDIFF.SH(1) v0.25 | General Commands Manual</h1>
174+
<h1 class="title">DATEDIFF.SH(1) v0.25.1 | General Commands Manual</h1>
175175
<p class="author">Jamil Soni N</p>
176-
<p class="date">November 2024</p>
176+
<p class="date">December 2024</p>
177177
</header>
178178
<h1 id="name">NAME</h1>
179179
<div class="line-block">   <strong>datediff.sh</strong> - Calculate time
@@ -234,8 +234,11 @@ <h3 id="main-output">Main Output</h3>
234234
<p><strong>Option -u</strong> sets or prints dates in Coordinated
235235
Universal Time (UTC) in the main function. This affects how the
236236
<code>C-code date</code> programme process dates.</p>
237-
<p>Set <strong>options -vvv</strong> to print different output
238-
layouts.</p>
237+
<p>In the main function, set <strong>options -v</strong> to print only
238+
the single-unit results and <strong>-vv</strong> to print only the
239+
compound time range result.</p>
240+
<p>In other function, set <strong>options -v</strong> to decrease
241+
verbose.</p>
239242
<h3 id="extra-functions">Extra Functions</h3>
240243
<p><strong>Option -e</strong> prints Easter dates for given
241244
<em>YEARS</em> (for Western Churches) and <strong>option -ee</strong>

man/datediff.sh.txt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
DATEDIFF.SH(1) v0.25 | General Commands Manual
1+
DATEDIFF.SH(1) v0.25.1 | General Commands Manual
22
Jamil Soni N
3-
November 2024
3+
December 2024
44

55
NAME
66

@@ -64,7 +64,10 @@ Option -u sets or prints dates in Coordinated Universal Time (UTC) in
6464
the main function. This affects how the C-code date programme process
6565
dates.
6666

67-
Set options -vvv to print different output layouts.
67+
In the main function, set options -v to print only the single-unit
68+
results and -vv to print only the compound time range result.
69+
70+
In other function, set options -v to decrease verbose.
6871

6972
Extra Functions
7073

0 commit comments

Comments
 (0)