3 #=======================================================================
5 # File ID: 75a10a58-8f7e-11e5-a744-fefdb24f8e10
9 # Author: Øyvind A. Holm <sunny@sunbase.org>
10 # License: GNU General Public License version 2 or later.
11 #=======================================================================
29 " -n "$progname" -- "$@
")"
30 test "$?" = "0" ||
exit 1
40 -h|
--help) opt_help
=1; shift ;;
41 -i|
--init) opt_init
=1; shift ;;
42 -q|
--quiet) opt_quiet
=$
(($opt_quiet + 1)); shift ;;
43 -r|
--reverse) opt_reverse
=1; shift ;;
44 -v|
--verbose) opt_verbose
=$
(($opt_verbose + 1)); shift ;;
45 --version) echo $progname $VERSION; exit 0 ;;
47 *) echo $progname: Internal error
>&2; exit 1 ;;
50 opt_verbose
=$
(($opt_verbose - $opt_quiet))
52 if test "$opt_help" = "1"; then
53 test $opt_verbose -gt 0 && { echo; echo $progname $VERSION; }
56 Usage: $progname [options] [km [timestamp]]
63 Init the spar db with initial values.
65 Be more quiet. Can be repeated to increase silence.
67 Count km in reverse order, from 0 and up.
69 Increase level of verbosity. Can be repeated.
71 Print version information.
80 test -z "$desttime" && desttime
=18:00
81 test -z "$destkm" && destkm
=7.68
83 currdate
="$(date -u +%Y-%m-%d)"
84 currtime
="$(date -u +%H:%M:%S)"
85 currsec
=$
(date -u +%s
)
87 destdate
="$currdate $desttime"
88 echo "$desttime" |
grep -q ' ' && {
92 if test "$opt_init" = "1"; then
93 if test "$opt_reverse" = "1"; then
101 --bt "$currdate $currtime" \
108 destsec
=$
(date -u -d "$destdate" +%s
)
109 printf '%.2f km/h\n' $
(echo "$destkm/($destsec-$currsec)*3600" |
bc)
112 printf '%.3f\n' $
(spar ov
)