-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
allowed decimal format for hours, this resolves #1
- Loading branch information
Showing
4 changed files
with
46 additions
and
19 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class DecimalNotationStrategy: | ||
def calculate_minutes(self, decimal_notation_string): | ||
decimal_hour = float(decimal_notation_string) | ||
|
||
return int(decimal_hour * 60) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
class HourNotationStrategy: | ||
def calculate_minutes(self, hour_notation_string): | ||
change_sign = False | ||
if hour_notation_string.startswith('-'): | ||
hour_notation_string = hour_notation_string[1:] | ||
change_sign = True | ||
|
||
time_list = hour_notation_string.split(':') | ||
hours = int(time_list[0]) | ||
minutes = int(time_list[1]) | ||
|
||
total_minutes = minutes + hours * 60 | ||
|
||
return -total_minutes if change_sign else total_minutes |
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
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