Skip to content

Instantly share code, notes, and snippets.

View minorsecond's full-sized avatar

Robert Ross Wardrup minorsecond

View GitHub Profile
@minorsecond
minorsecond / Main Menu
Created April 16, 2015 09:46
Main menu - causes error in Python3: "SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 11-12: malformed \N character escape
print('PYPER Timesheet Utility \n \n' \
'What would you like to do? \n' \
'1. Clock In\New Job\n' \
'2. Switch Job\n' \
'3. Break Time\Quit\n' \
'4. Set up jobs/break types\n' \
'5. Timesheet Minute Formatter\n' \
'6. Calculate Total Time Worked\n' \
'7. Generate Today\'s Timesheet\n' \
'8. Quit\n')
@minorsecond
minorsecond / Time_formatter
Created April 13, 2015 19:25
Tenths of hours between two times
def get_time(time):
return datetime.datetime.strptime(time, '%I:%M %p')
def total_time():
t_in = get_time(raw_input("Please enter your start time in 00:00 format: "))
t_out = get_time(raw_input("Please enter your end time in 00:00 format: "))
delta = t_out - t_in
HOUR = 60 * 60
delta_tenths = float(delta.seconds // (HOUR / 10)) / 10
def time_formatter():
"""
Takes user input as 00:00, splits those using : as seperator,
and prints the time formatted for timesheet in tenths of an
hour
"""
time_input = raw_input("\nTime Formatter\n" \
"Please enter hours and minutes worked today" \
"in 00:00 format: ")
if len(time_input.split(':')) == 2: