1
0
Fork 0
mirror of https://github.com/notwa/rc synced 2024-11-14 08:39:02 -08:00
rc/sh/dated

17 lines
408 B
Text
Raw Normal View History

#!/usr/bin/env sh
# YES_ZSH YES_BASH YES_DASH YES_ASH
dated() {
2021-10-18 17:36:47 -07:00
local ts= u=0
[ "$1" != -u ] || { shift; u=1; }
if [ $# = 0 ]; then
# -u doesn't actually do anything here, but...
if [ $u = 1 ]; then date -u '+%s'; else date '+%s'; fi
fi
2021-10-18 17:36:47 -07:00
for ts; do
if [ $u = 1 ]; then date -u -d '@'"$ts"; else date -d '@'"$ts"; fi
done
}
[ -n "${preload+-}" ] || dated "$@"