1
0
Fork 0
mirror of https://github.com/notwa/rc synced 2024-11-12 15:49:03 -08:00
rc/sh/dated
Connor Olding d5f3f14d72 merge compatibility lines
RIP meaningful last-modified dates
2024-03-26 15:08:14 -07:00

16 lines
408 B
Bash
Executable file

#!/usr/bin/env sh
# YES_ZSH YES_BASH YES_DASH YES_ASH
dated() {
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
for ts; do
if [ $u = 1 ]; then date -u -d '@'"$ts"; else date -d '@'"$ts"; fi
done
}
[ -n "${preload+-}" ] || dated "$@"