creates directories on fresh install

main
spinach 2 years ago
parent e2a5d2db15
commit dbe65c011c

@ -26,12 +26,14 @@ TIMESHEET=$(ls "$TIMESHEET_DIR" | grep ".csv")
# generated by clock in
CURRENT_SESSION="$TIMESHEET_DIR/.session"
# creates directory on fresh installs
if [[ ! -d "$WORKING_DIR" ]] ; then
mkdir -p "$WORKING_DIR"
fi
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")
@ -49,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

Loading…
Cancel
Save