Adding possible clockout times

This commit is contained in:
Philippe Caseiro 2022-03-31 14:56:10 +02:00
parent f7ebc0409f
commit 7800235bd1

29
badgy
View File

@ -54,6 +54,24 @@ getNewBalance()
echo $nbls echo $nbls
} }
getClockOutTime()
{
local workDay=25200
local dr=${1}
local now=$(date +'%s')
local remaining=$((workDay - dr))
local endingTime=$((now + remaining))
date -d @${endingTime} +'%H:%M'
}
captitalTime2seconds()
{
cph=$(echo "${1}" | awk -F ':' '{gsub("+|-",""); print $1}' )
cpm=$(echo "${1}" | awk -F ':' '{gsub("+|-",""); print $2}' )
sign=${1::1}
echo ${sign}$(( (cphd*3600)+(cpm*60)))
}
getCapitalTime() getCapitalTime()
{ {
data=$(${CURLIE} POST ${BADGEURL}/showtimers key=${KEY} dateof=$(date +'%Y-%m-%d') 2> /dev/null) data=$(${CURLIE} POST ${BADGEURL}/showtimers key=${KEY} dateof=$(date +'%Y-%m-%d') 2> /dev/null)
@ -83,13 +101,16 @@ getCapitalTime()
done done
nbl=$(getNewBalance "${sl}" "${dr}") nbl=$(getNewBalance "${sl}" "${dr}")
balance=$(captitalTime2seconds "${sl}")
echo clockOutTime=$(getClockOutTime "$((dr+balance))")
echo echo
echo "Your time balance is: ${sl}" echo "Your time balance is: ${sl}"
echo "Today you worked: $(s2h ${dr})"
echo echo
echo "Balance if you validate now: $(s2h ${nbl})" echo "Today you worked: $(s2h ${dr})"
echo
echo "Balance if you validate now : $(s2h ${nbl})"
echo "Clockout time (use balance) : ${clockOutTime}"
echo "Clockout time (keep balance) : $(getClockOutTime "${dr}")"
} }
show() show()