-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Arbitrary start #17
base: main
Are you sure you want to change the base?
Arbitrary start #17
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -17,6 +17,8 @@ class CountTimer: | |||||||||
start(): start the timer | ||||||||||
pause(): pause the timer | ||||||||||
resume(): resume the timer | ||||||||||
set_minutes_start_time(minutes): set the start time manually in minutes | ||||||||||
set_seconds_start_time(seconds): set the start time manually in seconds | ||||||||||
reset(): reset the timer to default (duration 0/paused/not started) | ||||||||||
|
||||||||||
Properties: | ||||||||||
|
@@ -63,6 +65,18 @@ def resume(self): | |||||||||
self._time_started = self._time_started + pause_duration | ||||||||||
self._paused = False | ||||||||||
|
||||||||||
def set_minutes_start_time(self, minutes): | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion: Consider combining set_minutes_start_time and set_seconds_start_time. Both methods are very similar. You could create a single method that takes both minutes and seconds as optional parameters, defaulting to zero, to reduce code duplication.
Suggested change
|
||||||||||
"""Set the start time manually in minutes.""" | ||||||||||
self._time_started = time.time() - (minutes * 60) | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. issue (bug_risk): Potential issue with negative time values. If a negative value is passed to |
||||||||||
self._time_paused = time.time() | ||||||||||
self._paused = True | ||||||||||
|
||||||||||
def set_seconds_start_time(self, seconds): | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. issue (typo): Incorrect docstring for set_seconds_start_time. The docstring for |
||||||||||
"""Set the start time manually in minutes.""" | ||||||||||
self._time_started = time.time() - seconds | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. issue (bug_risk): Potential issue with negative time values. If a negative value is passed to |
||||||||||
self._time_paused = time.time() | ||||||||||
self._paused = True | ||||||||||
|
||||||||||
def _get(self) -> float: | ||||||||||
"""Time in sec since timer was started, minus any time paused.""" | ||||||||||
if not self._time_started: | ||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: Consider adding validation details in the docstring.
It would be helpful to mention in the docstring that negative values for
minutes
andseconds
are not allowed, assuming you add validation for this.