From e2a5d2db15b1cd4974a6794852a1d61971e9cff4 Mon Sep 17 00:00:00 2001 From: spinach <19keegandeppe@gmail.com> Date: Sun, 29 Jan 2023 17:14:23 -0500 Subject: [PATCH 1/2] removed extension, added directory creation --- timetracker.sh => timetracker | 5 +++++ 1 file changed, 5 insertions(+) rename timetracker.sh => timetracker (97%) diff --git a/timetracker.sh b/timetracker similarity index 97% rename from timetracker.sh rename to timetracker index 0ab2a9b..a650f8d 100755 --- a/timetracker.sh +++ b/timetracker @@ -26,6 +26,11 @@ 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() { 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) From dbe65c011c8f9d653470333a07a9892ab2d227c7 Mon Sep 17 00:00:00 2001 From: spinach <19keegandeppe@gmail.com> Date: Sun, 29 Jan 2023 18:19:48 -0500 Subject: [PATCH 2/2] creates directories on fresh install --- timetracker | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/timetracker b/timetracker index a650f8d..6800bbc 100755 --- a/timetracker +++ b/timetracker @@ -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