summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYuval Adam <_@yuv.al>2020-09-28 18:33:22 +0300
committerYuval Adam <_@yuv.al>2020-09-28 18:33:56 +0300
commitca75913e447f37656ca516b235d27d8cf054e9f0 (patch)
treec872bee903ec0674c43be3598f1346ff6c319fa9
parent4efa661b96d682cad76356ef1355482211c5efc5 (diff)
Implement seconds_to_minutes()
-rw-r--r--iss/tests/test_utils.py15
-rw-r--r--iss/utils.py4
2 files changed, 18 insertions, 1 deletions
diff --git a/iss/tests/test_utils.py b/iss/tests/test_utils.py
index 4c67322..ee4971f 100644
--- a/iss/tests/test_utils.py
+++ b/iss/tests/test_utils.py
@@ -1,4 +1,17 @@
-from ..utils import deg_to_cardinal
+from ..utils import deg_to_cardinal, seconds_to_minutes
+
+
+def test_seconds_to_minutes():
+ cases = [
+ (0, "0:00"),
+ (1, "0:01"),
+ (60, "1:00"),
+ (61, "1:01"),
+ (1439, "23:59"),
+ (1440, "24:00"),
+ ]
+ for secs, s in cases:
+ assert seconds_to_minutes(secs) == s
def test_deg_to_cardinal():
diff --git a/iss/utils.py b/iss/utils.py
index 0bf9d04..326d835 100644
--- a/iss/utils.py
+++ b/iss/utils.py
@@ -3,6 +3,10 @@ def chunks(l, n):
yield l[i : i + n]
+def seconds_to_minutes(secs):
+ return f"{secs // 60}:{secs % 60:02}"
+
+
def deg_to_cardinal(deg):
cardinals = [
"N",