allow multiple arguments to `dated`

This commit is contained in:
Connor Olding 2021-10-18 17:36:47 -07:00
parent 2debcff660
commit 890254b5ba
1 changed files with 4 additions and 6 deletions

View File

@ -5,17 +5,15 @@
# YES_ASH
dated() {
local u=0
local ts= u=0
[ "$1" != -u ] || { shift; u=1; }
argc $# -le 1 "$0" || return
if [ $# = 0 ]; then
# -u doesn't actually do anything here, but...
if [ $u = 1 ]; then date -u '+%s'; else date '+%s'; fi
else
if [ $u = 1 ]; then date -u -d '@'"$1"; else date -d '@'"$1"; fi
fi
for ts; do
if [ $u = 1 ]; then date -u -d '@'"$ts"; else date -d '@'"$ts"; fi
done
}
[ -n "${preload+-}" ] || . ~/sh/preload || exit 2
eval ${preload:-preload} argc
[ -n "${preload+-}" ] || dated "$@"