[zsh] add more date formatting functions, remove the --utc argument

This commit is contained in:
Dmytro Meleshko 2020-09-04 22:56:14 +03:00
parent 5d68d60ff6
commit c2bc86c546

View file

@ -74,10 +74,16 @@ git_current_branch() {
echo "${ref#refs/heads/}" echo "${ref#refs/heads/}"
} }
date-fmt-iso() { declare -A date_formats=(
date --utc +'%Y-%m-%dT%H:%M:%SZ' "$@" iso '%Y-%m-%dT%H:%M:%SZ'
} normal '%Y-%m-%d %H:%M:%S'
compact '%Y%m%d%H%M%S'
only-date '%Y-%m-%d'
only-time '%H:%M:%S'
)
date-fmt-compact() { for format_name format in "${(kv)date_formats[@]}"; do
date --utc +'%Y%m%d%H%M%S' "$@" eval "date-fmt-${format_name}() { date +${(q)format} \"\$@\"; }"
} done; unset format_name format
unset date_formats