Skip to content

Commit

Permalink
correct time format
Browse files Browse the repository at this point in the history
  • Loading branch information
safaabuzaid committed Jan 11, 2025
1 parent 7f3fe86 commit e6b6668
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions solutions/Time_Conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ def Time_Conversion(est_time: str) -> str:
>>> Time_Conversion("14:30")
'22:30'
>>> Time_Conversion("8:15")
>>> Time_Conversion("08:15")
'16:15'
>>> Time_Conversion("0:0")
'8:0'
>>> Time_Conversion("00:00")
'08:00'
"""
Expand Down Expand Up @@ -62,4 +62,4 @@ def Time_Conversion(est_time: str) -> str:
if hours >= 24:
hours -= 24

return f"{hours}:{minutes}"
return f"{str(hours).zfill(2)}:{str(minutes).zfill(2)}"
6 changes: 3 additions & 3 deletions solutions/tests/test_Time_Conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,17 @@ def test_equal_minutes_hours(self):

def test_regular_time(self):
"""It should return the time conversion properly"""
self.assertEqual(Time_Conversion("08:00"), "16:0")
self.assertEqual(Time_Conversion("08:00"), "16:00")

# Boundary cases

def test_minimum_time(self):
"""It should return the time conversion properly"""
self.assertEqual(Time_Conversion("00:00"), "8:0")
self.assertEqual(Time_Conversion("00:00"), "08:00")

def test_maximum_time(self):
"""It should return the time conversion properly"""
self.assertEqual(Time_Conversion("23:59"), "7:59")
self.assertEqual(Time_Conversion("23:59"), "07:59")

# Defensive cases

Expand Down

0 comments on commit e6b6668

Please sign in to comment.