tof-voters: add commit analysis subcommand
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: I6e56202c014a52d16773415edf59d4e6a7ecdf59
diff --git a/tof-voters/libvoters/time.py b/tof-voters/libvoters/time.py
new file mode 100644
index 0000000..efcee29
--- /dev/null
+++ b/tof-voters/libvoters/time.py
@@ -0,0 +1,23 @@
+#!/usr/bin/python3
+from enum import Enum
+from datetime import datetime, timezone
+
+
+class TimeOfDay(Enum):
+ AM = 0
+ PM = 1
+
+
+def timestamp(date: str, time: TimeOfDay) -> int:
+ [year, month, day] = [int(x) for x in date.split("-")]
+
+ if time == TimeOfDay.AM:
+ [hour, minute, second] = [00, 00, 00]
+ else:
+ [hour, minute, second] = [23, 59, 59]
+
+ return int(
+ datetime(
+ year, month, day, hour, minute, second, tzinfo=timezone.utc
+ ).timestamp()
+ )