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/}"
|
||||
}
|
||||
|
||||
date-fmt-iso() {
|
||||
date --utc +'%Y-%m-%dT%H:%M:%SZ' "$@"
|
||||
}
|
||||
declare -A date_formats=(
|
||||
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() {
|
||||
date --utc +'%Y%m%d%H%M%S' "$@"
|
||||
}
|
||||
for format_name format in "${(kv)date_formats[@]}"; do
|
||||
eval "date-fmt-${format_name}() { date +${(q)format} \"\$@\"; }"
|
||||
done; unset format_name format
|
||||
|
||||
unset date_formats
|
||||
|
|
Loading…
Reference in a new issue