# shellcheck shell=sh        disable=SC2039,SC1090,SC3043,SC2263
# x-cmd cwe lib/util — shared helpers used by data/, la/, fz/.
#
# Tiny wrappers so callers don't have to remember whether `stat` is GNU
# or BSD on the host, and so date format strings aren't run through
# x-cmd's command wrappers (which refuse `%` format strings).

# Current epoch seconds. Always emits a number so callers don't have to
# handle empty output.
___x_cmd_cwe_util_now(){
    command date +%s 2>/dev/null || printf '0'
}

# Current calendar year (4 digits).
___x_cmd_cwe_util_year(){
    command date +%Y 2>/dev/null || printf '0'
}

# Portable file mtime in seconds since epoch.
___x_cmd_cwe_util_mtime(){
    command stat -c %Y "$1" 2>/dev/null \
    || command stat -f %m "$1" 2>/dev/null \
    || printf '0'
}