Compare commits

..

2 Commits

Author SHA1 Message Date
Philippe Caseiro c563ba96f0 Make it more readble 2022-03-24 13:09:14 +01:00
Philippe Caseiro 29a306f988 Adding nice Balance at the moment 2022-03-24 13:07:30 +01:00
1 changed files with 29 additions and 15 deletions

44
badgy
View File

@ -24,21 +24,34 @@ devalidate()
s2h()
{
local sc=${1}
local sc=0
local sign=""
if [ ${1} -lt 0 ]; then
sign="-"
sc=$(echo ${1} | cut -c2-)
else
sc=${1}
fi
local h=$(( sc / 3600))
local m=$(( (sc % 3600) / 60 ))
local s=$(( sc % 60))
printf "%dh%02dm" "${h}" "${m}"
printf "%s%dh%02dm" "${sign}" "${h}" "${m}"
}
getNewBalance()
{
local wk=25200
local blh=$(echo ${1} | cut -d ':' -f 1)
local workDay=25200
local blh=$(echo ${1} | cut -d ':' -f 1 | cut -c2-)
local blm=$(echo ${1} | cut -d ':' -f 2)
local bls=""
local nbls=""
echo ${nbls}
local bls=$((blh*3600 + blm*60))
local nbls=0
if [ "${bls}" -le "${workDay}" ]; then
nbls=$((${2}-(workDay - bls)))
else
nbls=$((bls+${2}))
fi
echo $nbls
}
getCapitalTime()
@ -47,17 +60,17 @@ getCapitalTime()
clocks=$(echo ${data} | jq -rc ".timers[]")
sl=$(echo ${data} | jq -rc ".capitaltime")
dr=0
echo "Timers:"
for cl in ${clocks}
do
starts=$(echo ${cl} | jq -rc ".start")
st=$(date --date="${starts}" +'%s')
st=$(date --date="${starts}" +'%s')
ends=$(echo ${cl} | jq -rc ".end")
echo
echo
echo " Start: $(date --date=${starts} +'%A %d %B %Y : %H:%M')"
if [ "${ends}" != "null" ];then
ed=$(date --date="${ends}" +'%s')
ed=$(date --date="${ends}" +'%s')
echo " End: $(date --date=${ends} +'%A %d %B %Y : %H:%M')"
else
ed=$(date +'%s')
@ -69,9 +82,10 @@ getCapitalTime()
nbl=$(getNewBalance "${sl}" "${dr}")
echo
echo "Your time balance is : ${sl}"
echo "Today you worked $(s2h ${dr})"
#echo "If you validate now your balance will be : ${nbl}"
echo "Your time balance is: ${sl}"
echo "Today you worked: $(s2h ${dr})"
echo
echo "Balance if you validate now: $(s2h ${nbl})"
}
show()
@ -88,7 +102,7 @@ else
exit 2
fi
case ${1} in
case ${1} in
in|clockin|c)
clockin | jq
;;