Created
May 1, 2018 14:24
-
-
Save ihatecsv/1cc8423bd7c582d6eac8eef3d135d300 to your computer and use it in GitHub Desktop.
Money made today display
This file contains hidden or 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
import os; | |
from datetime import datetime; | |
from time import mktime; | |
import time; | |
import threading; | |
##################### | |
wage = 15; # Hourly wage | |
startHour = 8; # Start hour (24h time) | |
startMinute = 30; # Start minute | |
printInterval = 5; # Time between updates (seconds) | |
termWidth = 20; # Character width of terminal (for centering text) | |
##################### | |
def printValue(): | |
threading.Timer(printInterval, printValue).start(); | |
unused = os.system("clear"); | |
now = datetime.now(); | |
nowUnix = mktime(now.timetuple()); | |
startTime = now.replace(hour=startHour, minute=startMinute, second=0, microsecond=0); | |
startTimeUnix = mktime(startTime.timetuple()); | |
deltaHrs = (nowUnix-startTimeUnix)/3600; | |
deltaHrsFormatted = 'T+{:,.2f}'.format(deltaHrs); | |
doubleValue = deltaHrs*wage; | |
formattedValue = '${:,.2f}'.format(doubleValue); | |
print(deltaHrsFormatted.center(termWidth)); | |
print(formattedValue.center(termWidth)); | |
printValue(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment