Created
September 13, 2012 08:55
-
-
Save esamson/3713028 to your computer and use it in GitHub Desktop.
time-to-uwian
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 python | |
# | |
# Tools for the Extra Bored | |
# brought to you by Edward Samson | |
# | |
# time-to-uwian | |
# | |
# If you turn on your computer as soon as you get to work, this script will | |
# show how much longer you have to wait before you can leave. | |
# | |
# Uses psutil (http://code.google.com/p/psutil/) to get system startup time. | |
import psutil | |
import time | |
import datetime | |
# number of seconds you are expected to be at your desk in a day | |
workday = 32400 # 9 hours | |
# when you turned on your computer | |
started = int(psutil.BOOT_TIME) | |
now = int(time.time()) | |
pumasok = datetime.datetime.fromtimestamp(started) | |
uwian = datetime.datetime.fromtimestamp(started + workday) | |
time_worked = now - started | |
time_left = workday - time_worked | |
print "pumasok: %s" % str(pumasok) | |
print "uwian: %s" % str(uwian) | |
print "worked: %s" % str(datetime.timedelta(seconds=time_worked)) | |
print "left: %s" % str(datetime.timedelta(seconds=time_left)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment