diff options
author | Baitinq <30861839+Baitinq@users.noreply.github.com> | 2021-12-21 23:29:20 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-21 23:29:20 +0000 |
commit | 79d7dacd4fb9f06976fc5e5f4f4593e7051e2f1d (patch) | |
tree | a38864225cedd79d92f89168c4f5b25a7f708d75 | |
parent | a0cb7fddca5fba76c8c3d70cd9d265c1d16f888a (diff) |
Update the daypercentage module to fix bug and use python
-rwxr-xr-x | modules/daypercentage | 13 | ||||
-rwxr-xr-x | modules/daypercentage.py | 11 |
2 files changed, 11 insertions, 13 deletions
diff --git a/modules/daypercentage b/modules/daypercentage deleted file mode 100755 index 5a2316f..0000000 --- a/modules/daypercentage +++ /dev/null @@ -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 diff --git a/modules/daypercentage.py b/modules/daypercentage.py new file mode 100755 index 0000000..d97d6d8 --- /dev/null +++ b/modules/daypercentage.py @@ -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) + "%") |