From bff76bb14815f7351f54d3fc5df3d41bf5325ef1 Mon Sep 17 00:00:00 2001 From: Nicola Silveri Date: Tue, 28 May 2024 12:21:21 +0200 Subject: [PATCH 1/2] Adding the possibility to set the initial min/sec from which to start. --- count_timer/count_timer.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/count_timer/count_timer.py b/count_timer/count_timer.py index 1330692..c196376 100644 --- a/count_timer/count_timer.py +++ b/count_timer/count_timer.py @@ -17,6 +17,7 @@ class CountTimer: start(): start the timer pause(): pause the timer resume(): resume the timer + set_start_time(minutes): set the start time manually in minutes reset(): reset the timer to default (duration 0/paused/not started) Properties: @@ -63,6 +64,12 @@ def resume(self): self._time_started = self._time_started + pause_duration self._paused = False + def set_start_time(self, minutes): + """Set the start time manually in minutes.""" + self._time_started = time.time() - (minutes * 60) + 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: From 7248ca693087f2eea9a87d7202fe8e4fcc5b241f Mon Sep 17 00:00:00 2001 From: Nicola Silveri Date: Tue, 28 May 2024 12:28:33 +0200 Subject: [PATCH 2/2] Adding the possibility to set the initial min/sec from which to start. --- count_timer/count_timer.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/count_timer/count_timer.py b/count_timer/count_timer.py index c196376..c0016a5 100644 --- a/count_timer/count_timer.py +++ b/count_timer/count_timer.py @@ -17,7 +17,8 @@ class CountTimer: start(): start the timer pause(): pause the timer resume(): resume the timer - set_start_time(minutes): set the start time manually in minutes + 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: @@ -64,12 +65,18 @@ def resume(self): self._time_started = self._time_started + pause_duration self._paused = False - def set_start_time(self, minutes): + def set_minutes_start_time(self, minutes): """Set the start time manually in minutes.""" self._time_started = time.time() - (minutes * 60) self._time_paused = time.time() self._paused = True + def set_seconds_start_time(self, seconds): + """Set the start time manually in minutes.""" + self._time_started = time.time() - seconds + 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: