1
0
Fork 0
mirror of https://github.com/notwa/rc synced 2024-11-05 13:09:03 -08:00
rc/sh/dated
2021-10-18 02:49:39 -07:00

21 lines
506 B
Bash

#!/usr/bin/env sh
# YES_ZSH
# YES_BASH
# YES_DASH
# YES_ASH
dated() {
local 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
}
[ -n "${preload+-}" ] || . ~/sh/preload || exit 2
eval ${preload:-preload} argc
[ -n "${preload+-}" ] || dated "$@"