diff --git a/dabo/functions/currency_converter.sh b/dabo/functions/currency_converter.sh index 2d31fc3..b5fdfce 100644 --- a/dabo/functions/currency_converter.sh +++ b/dabo/functions/currency_converter.sh @@ -39,7 +39,7 @@ function currency_converter { fi # 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 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") # 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 [ -d asset-histories ] || mkdir asset-histories