Update the daypercentage module to fix bug and use python

This commit is contained in:
Baitinq 2021-12-21 23:29:20 +00:00 committed by GitHub
parent a0cb7fddca
commit 79d7dacd4f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 13 deletions

View file

@ -1,13 +0,0 @@
#!/bin/bash
# Prints the percentage of the day that has been completed
PREFIX=' '
get_daypercentage()
{
MINUTES="$[$(date +%R | cut -d ':' -f1 | sed 's/^0*//') * 60 + $(date +%R | cut -d ':' -f2) ]"
echo "$PREFIX$(echo $[ $MINUTES * 100 / 1440 ] | sed 's/\..*//g')%"
}
get_daypercentage

11
modules/daypercentage.py Executable file
View file

@ -0,0 +1,11 @@
#!/usr/bin/env python3
PREFIX = ''
import datetime
now = datetime.datetime.now()
minutes = now.hour * 60 + now.minute
percentage = round(minutes * 100 / 1440)
print(PREFIX + str(percentage) + "%")