Skip to content

Instantly share code, notes, and snippets.

@RedL0tus RedL0tus/year_progress.sh
Last active May 1, 2018

Embed
What would you like to do?
\\\ Year Progress ///
# Year Progress
export LENGTH=20;
function GET_PERCENTAGE {
local CURRENT_YEAR=$(date +%Y);
if [ $((CURRENT_YEAR % 400)) -eq 0 ]; then
local TOTAL_DAYS=366;
elif [ $((CURRENT_YEAR % 100)) -eq 0 ]; then
local TOTAL_DAYS=365;
elif [ $((CURRENT_YEAR % 4)) -eq 0 ]; then
local TOTAL_DAYS=366;
else
local TOTAL_DAYS=365;
fi
CURRENT_DAY=$(echo "$(date +%j) + 0" | bc)
echo $((200*$CURRENT_DAY/$TOTAL_DAYS % 2 + 100*$CURRENT_DAY/$TOTAL_DAYS));
}
function DISPLAY {
local PERCENTAGE=$(GET_PERCENTAGE);
local FILLED=$(($LENGTH*$PERCENTAGE/100));
local BLANK=$(($LENGTH-$FILLED));
for ((i=0;i<$FILLED;i++)) {
echo -ne "";
}
for ((i=0;i<$BLANK;i++)) {
echo -ne "";
}
echo -ne " $PERCENTAGE %\n";
}
DISPLAY;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.