|
|
|
@ -26,7 +26,14 @@ TIMESHEET=$(ls "$TIMESHEET_DIR" | grep ".csv")
|
|
|
|
|
# generated by clock in
|
|
|
|
|
CURRENT_SESSION="$TIMESHEET_DIR/.session"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
createTimesheet() {
|
|
|
|
|
|
|
|
|
|
# creates directory on fresh installs
|
|
|
|
|
if [[ ! -d "$TIMESHEET_DIR" ]] ; then
|
|
|
|
|
mkdir -p "$TIMESHEET_DIR"
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
payperiods=$((($(date +%s) - $(date -d "Dec-30-22" +%s)) / (14*24*3600)))
|
|
|
|
|
period_end=$(date -d "Dec-30-22 + $((($payperiods + 1) * 14)) days" +%b-%d-%y)
|
|
|
|
|
TIMESHEET=$(printf "%s.csv" "$period_end")
|
|
|
|
@ -44,6 +51,11 @@ getTimesheet() {
|
|
|
|
|
period_end=$(date -d "$(echo "$TIMESHEET" | awk -F . '{print $1}') + 1 days" +%s)
|
|
|
|
|
if [[ $(date +%s) -ge $period_end ]] ; then
|
|
|
|
|
# past timesheet, moving to archive and creating new
|
|
|
|
|
# creates directory on fresh installs
|
|
|
|
|
if [[ ! -d "$ARCHIVE_DIR" ]] ; then
|
|
|
|
|
mkdir -p "$ARCHIVE_DIR"
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
mv "${TIMESHEET_DIR}/${TIMESHEET}" "$ARCHIVE_DIR"
|
|
|
|
|
createTimesheet
|
|
|
|
|
fi
|