Add yt-dlp v2021.09.02
[sunny256-utils.git] / age
blobb53069327d43dcfa16cbe89f701cadfdcd463e6d
1 #!/bin/sh
3 #==============================================================================
4 # age
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 #==============================================================================
10 progname=age
11 VERSION=0.2.0
13 opt_help=0
14 opt_quiet=0
15 opt_seconds=0
16 opt_verbose=0
17 while test -n "$1"; do
18 case "$1" in
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 ;;
24 --) shift; break ;;
26 if printf '%s\n' "$1" | grep -q ^-; then
27 echo "$progname: $1: Unknown option" >&2
28 exit 1
29 else
30 break
32 break ;;
33 esac
34 done
35 opt_verbose=$(($opt_verbose - $opt_quiet))
37 if test "$opt_help" = "1"; then
38 test $opt_verbose -gt 0 && { echo; echo $progname $VERSION; }
39 cat <<END
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
44 seconds between them.
46 Usage: $progname [options] date1 [date2]
48 Options:
50 -h, --help
51 Show this help.
52 -q, --quiet
53 Be more quiet. Can be repeated to increase silence.
54 -s, --seconds
55 Display seconds instead of the default datefmt(1) output.
56 -v, --verbose
57 Increase level of verbosity. Can be repeated.
58 --version
59 Print version information.
61 END
62 exit 0
65 test -z "$1" && {
66 echo $progname: Missing arguments >&2
67 exit 1
69 begin=$1
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'));
76 END
78 # vim: set ts=8 sw=8 sts=8 noet fo+=w tw=79 fenc=UTF-8 :