Created
October 31, 2018 20:16
-
-
Save jakevossen5/ad022cab014ecbd0a30ee49782e9272c to your computer and use it in GitHub Desktop.
Percent done with hour/day/month
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env PYTHONIOENCODING=UTF-8 /usr/local/bin/python3 | |
# To be used with bit-bar, which shows the % you are done with the current hour, day, week, and year | |
from datetime import datetime | |
now = datetime.now() | |
digits = 3 | |
seconds_since_hour = (now - now.replace(minute=0, second=0, microsecond=0)).total_seconds() | |
print(("h" + ('{0:.2f}'.format(round((seconds_since_hour / 3600), digits)))[1:]), end= ' ') | |
seconds_since_midnight = (now - now.replace(hour=0, minute=0, second=0, microsecond=0)).total_seconds() | |
print("d" +('{0:.2f}'.format(round((seconds_since_midnight / 86400), digits)))[1:],end = ' ') | |
days_past_friday=(datetime.today().weekday() + 2) % 7 | |
seconds_since_friday = days_past_friday * 86400 + seconds_since_midnight | |
#print(seconds_since_friday) | |
print("w" + ('{0:.2f}'.format(round((seconds_since_friday / 604800), digits)))[1:],end = ' ') | |
seconds_since_jan_1 = (now - now.replace(month = 1, hour=0, minute=0, second=0, microsecond=0)).total_seconds() | |
print("y" +('{0:.2f}'.format(round((seconds_since_jan_1 / (31540000)), digits)))[1:],end = ' ') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment