Skip to content

Instantly share code, notes, and snippets.

@ihatecsv
Created May 1, 2018 14:24
Show Gist options
  • Save ihatecsv/1cc8423bd7c582d6eac8eef3d135d300 to your computer and use it in GitHub Desktop.
Save ihatecsv/1cc8423bd7c582d6eac8eef3d135d300 to your computer and use it in GitHub Desktop.
Money made today display
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