fix 1st day in month

This commit is contained in:
olli 2024-11-01 13:40:30 +01:00
parent 655c3b4032
commit 98d185067b

View File

@ -39,7 +39,7 @@ function currency_converter {
fi fi
# get current date if none given # get current date if none given
[ -z "$f_currency_date" ] && printf -v f_currency_date '%(%Y-%m-%d %H:%M:%S)T' [ -z "$f_currency_date" ] && printf -v f_currency_date '%(%Y-%m-%d.%H:%M:%S)T'
# rate per minute # rate per minute
f_currency_date_minute=$(date -d "${f_currency_date}" "+%Y-%m-%d.%H:%M") f_currency_date_minute=$(date -d "${f_currency_date}" "+%Y-%m-%d.%H:%M")
@ -51,7 +51,13 @@ function currency_converter {
f_currency_date_day=$(date -d "${f_currency_date}" "+%Y-%m-%d") f_currency_date_day=$(date -d "${f_currency_date}" "+%Y-%m-%d")
# month failback # month failback
f_currency_date_month=$(date -d "${f_currency_date}" "+%Y-%m") if [ $(date -d "${f_currency_date}" "+%d") = "01" ]
then
# on first day in month use month before because no date from current month
f_currency_date_month=$(date -d "${f_currency_date} yesterday" "+%Y-%m")
else
f_currency_date_month=$(date -d "${f_currency_date}" "+%Y-%m")
fi
# path to history files for the converting rate # path to history files for the converting rate
[ -d asset-histories ] || mkdir asset-histories [ -d asset-histories ] || mkdir asset-histories