
# shellcheck shell=dash

___x_cmd_epoch_minus(){
    local x_=""
    ___x_cmd_epoch_minus_ "$@" || return $?
    printf "%s\n" "$x_"
}

___x_cmd_epoch_minus_(){
    local is_human=""
    case "$1" in
        -H) is_human=1 ; shift ;;
    esac

    local a b
    case "$#" in
        0)  ___x_cmd_epoch_get_ ; a="$x_" ; b=0 ;;
        1)  ___x_cmd_epoch_get_ ; a="$x_" ; b="$1" ;;
        2)  a="$1" ; b="$2" ;;
        *)  N=epoch M="Usage: x epoch minus [-H] [a] [b]" log:ret:64 ;;
    esac

    # awk (not $((a-b))): handles negative results and any precision in one shot.
    x_="$(___x_cmd_cmds awk -v a="$a" -v b="$b" 'BEGIN { printf "%.3f", a - b }')"

    case "$x_" in
        *.000) x_="${x_%.000}" ;;
    esac

    if [ "$is_human" = 1 ]; then
        ___x_cmd humantime sec_ "$x_"
    fi
}
