mirror of
https://github.com/keanuplayz/dotfiles.git
synced 2024-08-15 02:33:12 +00:00
[zsh] add more date formatting functions, remove the --utc
argument
This commit is contained in:
parent
5d68d60ff6
commit
c2bc86c546
1 changed files with 12 additions and 6 deletions
|
@ -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
|
||||||
|
|
Loading…
Reference in a new issue