Skip to content

Instantly share code, notes, and snippets.

@esamson
Created September 13, 2012 08:55
Show Gist options
  • Save esamson/3713028 to your computer and use it in GitHub Desktop.
Save esamson/3713028 to your computer and use it in GitHub Desktop.
time-to-uwian
#!/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