-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update the date syntax to use gnu date #1
Conversation
Hey! Thanks for this. Since this is at least 2 different changes, I'd want this to be a separate pull request from the new feature being added. For the date, I'm not getting that variant to work correctly on MacOS — this is the same I tried in my own work. Unfortunately, it gives too big values, i.e.
Is there an issue with the current formatting when run on your system, which I suspect is some Linux variant? |
Mac/BSD uses a non standard date variant, this fix makes it run with 90% of the linux distros... lemme try to find something that does that |
runns the date command accordingly
This reverts commit 7c0a08a.
like this? |
im new to git |
Thanks for the find! Had a suggestion that I updated with the I'd suggest the following as a solution. It checks for MacOS (because that's a bit particular) and otherwise assumes standard Linux functionality. At this point I'm not overly interested in Windows or anything, given where Bash is used most commonly. daysSinceLastCommit() {
last_commit_date=$(git log -1 --format="%ai")
if [[ "$(uname | tr '[:upper:]' '[:lower:]')" == "darwin" ]]; then
last_commit_timestamp=$(date -jf "%Y-%m-%d %H:%M:%S %z" "$last_commit_date" "+%s")
else
last_commit_timestamp=$(date -d "$last_commit_date" "+%s")
fi
current_timestamp=$(date "+%s")
time_diff=$((current_timestamp - last_commit_timestamp))
days_since_last_commit=$((time_diff / 86400)) # 86400 seconds in a day
echo "Days since the last commit: $days_since_last_commit" >"$GITANALYZED_FOLDER/$FILENAME_DAYS_SINCE_LAST_COMMIT"
} |
yeah, seems good, should i change it? |
Go ahead, and I'll merge. |
Added the changes and merged. |
No description provided.