Repository navigation
Add seconds and elapsed checks to stopwatch - #667
Conversation
Also did general clean-up.
Co-Authored-By: Matěj Volf <mat.volfik@gmail.com>
|
Wouldn't def start(self):
"""
Starts the timer. If the timer is already running, does nothing.
If the timer was previously stopped, continues with the previous elapsed time
"""
if self._stopped_total_time is None:
if self._start_time is None:
self._start_time = get_ticks_ms()
else:
self._start_time = get_ticks_ms() - self._stopped_total_time
self._stopped_total_time = NoneAlso I would either remove the However, all of these are just ideas what I would find more intuitive... |
|
I agree on the stop/reset semantics — I did it this way because it was backwards-compatible with what was released before. That being said, it was only released in the beta release, so if we're going to break it we should do it now. I'll look back at it tomorrow and maybe change it to be as you described. @dwalton76 what do you think? |
Co-Authored-By: Matěj Volf <mat.volfik@gmail.com>
| @property | ||
| def is_started(self): | ||
| """ | ||
| True if the StopWatch has been started but not stoped (i.e., it's currently running), false otherwise. |
dwalton76
left a comment
There was a problem hiding this comment.
The rest looks good to me
| @property | ||
| def is_started(self): | ||
| """ | ||
| True if the StopWatch has been started but not stoped (i.e., it's currently running), false otherwise. |
|
@dwalton76 What do you think about the questions raised by @mvolfik (about start/reset behavior)? I think it would make sense to change the interface a bit but I'd like your opinion too. |
|
I think it would be better to have a 2nd call to start raise an Exception, just because it feels like an easy mistake for the user to make. If they want to reset the timer I think they should have to explicitly call |
|
I guess the question of restart behavior comes down to use cases: do we expect there's a common case where someone wants to start+stop a timer then start it again from where they left off? Is that useful? I can see cases where that could be used but it seems like the majority of use cases are where you want to start the timer then wait for some amount of time to elapse while performing another action. |
|
This is a slight breaking change; this prompts a reasonable discussion. One option would be to increment the minor version ( The other option would be to increment it properly and call it |
|
Do we have any other breaking changes? If so 3.0 sounds good, if not then 2.1.0. |
|
So far, we don't. I'll merge this as-is and then I can change the planned version number as new changes come in. |
Also did general clean-up and added documentation. Removed intermediate "value" so that accessors don't modify state.
There is one breaking change (I believe everything else is backwards-compatible): "value_hms" now returns the unstringified tuple, and a new "hms_str" returns the string version. Also changed the
__str__format to include the hms string but I don't view that as a breaking change.Useful for #665.