I’m having trouble calculating the number of days after, and changing the time to AM or PM accordingly:
F....F..FFFF
======================================================================
FAIL: test_different_period (test_module.UnitTests)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/boilerplate-time-calculator/test_module.py", line 15, in test_different_period
self.assertEqual(actual, expected, 'Expected calling "add_time()" with "11:55 AM", "3:12" to return "3:07 PM"')
AssertionError: '3:07 PM (next day)' != '3:07 PM'
- 3:07 PM (next day)
+ 3:07 PM
: Expected calling "add_time()" with "11:55 AM", "3:12" to return "3:07 PM"
======================================================================
FAIL: test_period_change_at_twelve (test_module.UnitTests)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/boilerplate-time-calculator/test_module.py", line 25, in test_period_change_at_twelve
self.assertEqual(actual, expected, 'Expected period to change from AM to PM at 12:00')
AssertionError: '12:05 AM' != '12:05 PM'
- 12:05 AM
? ^
+ 12:05 PM
? ^
: Expected period to change from AM to PM at 12:00
======================================================================
FAIL: test_twenty_four (test_module.UnitTests)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/boilerplate-time-calculator/test_module.py", line 30, in test_twenty_four
self.assertEqual(actual, expected, 'Expected calling "add_time()" with "2:59 AM", "24:00" to return "2:59 AM"')
AssertionError: '2:59 AM (2 days later)' != '2:59 AM (next day)'
- 2:59 AM (2 days later)
+ 2:59 AM (next day)
: Expected calling "add_time()" with "2:59 AM", "24:00" to return "2:59 AM"
======================================================================
FAIL: test_twenty_four_with_day (test_module.UnitTests)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/boilerplate-time-calculator/test_module.py", line 55, in test_twenty_four_with_day
self.assertEqual(actual, expected, 'Expected calling "add_time()" with "2:59 AM", "24:00", "saturDay" to return "2:59 AM, Sunday (next day)"')
AssertionError: '2:59 AM, Monday (2 days later)' != '2:59 AM, Sunday (next day)'
- 2:59 AM, Monday (2 days later)
+ 2:59 AM, Sunday (next day)
: Expected calling "add_time()" with "2:59 AM", "24:00", "saturDay" to return "2:59 AM, Sunday (next day)"
======================================================================
FAIL: test_two_days_later (test_module.UnitTests)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/boilerplate-time-calculator/test_module.pyy", line 35, in test_two_days_later
self.assertEqual(actual, expected, 'Expected calling "add_time()" with "11:59 PM", "24:05" to return "12:04 AM (2 days later)"')
AssertionError: '12:04 PM (2 days later)' != '12:04 AM (2 days later)'
- 12:04 PM (2 days later)
? ^
+ 12:04 AM (2 days later)
? ^
: Expected calling "add_time()" with "11:59 PM", "24:05" to return "12:04 AM (2 days later)"
======================================================================
FAIL: test_two_days_later_with_day (test_module.UnitTests)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/boilerplate-time-calculator/test_module.py", line 60, in test_two_days_later_with_day
self.assertEqual(actual, expected, 'Expected calling "add_time()" with "11:59 PM", "24:05", "Wednesday" to return "12:04 AM, Friday (2 days later)"')
AssertionError: '12:04 PM, Friday (2 days later)' != '12:04 AM, Friday (2 days later)'
- 12:04 PM, Friday (2 days later)
? ^
+ 12:04 AM, Friday (2 days later)
? ^
: Expected calling "add_time()" with "11:59 PM", "24:05", "Wednesday" to return "12:04 AM, Friday (2 days later)"
----------------------------------------------------------------------
Ran 12 tests in 0.002s
FAILED (failures=6)
3:02 PM (next day)
This bit of code is certainly giving me these errors:
hr_res=s_hr+d_hr #Adding the hours of the start time and duration time
mi_res=s_mi+d_mi #Adding the minutes of the start time and duration time
if mi_res>59:
hr_res+=1
mi_res-=60
while hr_res>12:
if h12=='AM':
h12=h12.replace('AM','PM')
elif h12=='PM':
h12=h12.replace('PM','AM')
hr_res-=12
days+=0.5
days=round(days+0.5) #Trying to round the days into whole number