fix format date

This commit is contained in:
arzzen
2023-10-24 14:52:00 +02:00
committed by GitHub
parent aa6619508a
commit d886facadf

View File

@@ -102,6 +102,23 @@ function optionPicked() {
echo -e "${msg}\n"
}
################################################################################
# DESC: Format date string
# ARGS: $* (required): String
# OUTS: String
################################################################################
format_date() {
local date="${1}"
local outf="${2}"
local datef="${3:-"%b %d %H:%M:%S %Y %Z"}" # Tue Oct 24 13:34:22 2023 +0300
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
local resp="$(date -d "${date}" "+${outf}")"
elif [[ "$OSTYPE" == "darwin"* ]]; then
local resp="$(date -j -f "${datef}" "${date}" "+${outf}")"
fi
printf "%s" "${resp}"
}
################################################################################
# DESC: Help information printed to stdout during non-interactive mode
# ARGS: None
@@ -394,7 +411,7 @@ function changelogs() {
--date=short "${_author}" "$_since" "$_until" $_log_options $_pathspec \
| sort -u -r | head -n $_limit \
| while read DATE; do
day=$(date -d $(echo $DATE|awk -F- '{print $1 "-" $2 "-" $3}') +%A)
day=$(format_date "$DATE" "%A" "%Y-%m-%d")
echo -e "\n[$DATE - $day]"
GIT_PAGER=cat git -c log.showSignature=false log \
--use-mailmap $_merges \