3 #==============================================================================
5 # File ID: 9b034192-0a68-11e2-98ae-fefdb24f8e10
6 # Author: Øyvind A. Holm <sunny@sunbase.org>
7 # License: GNU General Public License version 2 or later.
8 #==============================================================================
17 while test -n "$1"; do
19 -h|
--help) opt_help
=1; shift ;;
20 -q|
--quiet) opt_quiet
=$
(($opt_quiet + 1)); shift ;;
21 -s|
--seconds) opt_seconds
=1; shift ;;
22 -v|
--verbose) opt_verbose
=$
(($opt_verbose + 1)); shift ;;
23 --version) echo $progname $VERSION; exit 0 ;;
26 if printf '%s\n' "$1" |
grep -q ^
-; then
27 echo "$progname: $1: Unknown option" >&2
35 opt_verbose
=$
(($opt_verbose - $opt_quiet))
37 if test "$opt_help" = "1"; then
38 test $opt_verbose -gt 0 && { echo; echo $progname $VERSION; }
41 Print number of seconds since the UTC timestamp specified on the command
42 line, use format "YYYY-MM-DD [HH:MM[:SS]]" or any other format
43 understood by sqlite3. If two timestamps are specified, print number of
46 Usage: $progname [options] date1 [date2]
53 Be more quiet. Can be repeated to increase silence.
55 Display seconds instead of the default datefmt(1) output.
57 Increase level of verbosity. Can be repeated.
59 Print version information.
66 echo $progname: Missing arguments
>&2
70 end
=now
# Memento mori
71 test -n "$2" && end
=$2
73 cat <<END | sqlite3 | (test "$opt_seconds" = "1" && cat || datefmt)
74 SELECT strftime('%s', datetime('$end'))
75 - strftime('%s', datetime('$begin'));
78 # vim: set ts=8 sw=8 sts=8 noet fo+=w tw=79 fenc=UTF-8 :