Compare commits

..

No commits in common. "c563ba96f027db8eaa8c5a1f52bb74589aa62fd5" and "f0aca745f515c7b34e84d15498e525843b86bc88" have entirely different histories.

1 changed files with 15 additions and 29 deletions

44
badgy
View File

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