aboutsummaryrefslogtreecommitdiff
path: root/utils.py
diff options
context:
space:
mode:
authorCody Hiar <codyfh@gmail.com>2018-03-23 20:31:56 -0600
committerCody Hiar <codyfh@gmail.com>2018-03-23 20:31:56 -0600
commite3fb796429c674f2b15a3320144ecd3fbf3139f0 (patch)
treee5a26ba184bd212f63afc2c9fe3e7927275298fa /utils.py
parent20cb5be7c9e8b1542ae86a8541bc65b4cb33ee6b (diff)
Split cli into different files, wrap keyboard exception
Diffstat (limited to 'utils.py')
-rw-r--r--utils.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/utils.py b/utils.py
new file mode 100644
index 0000000..8d351ae
--- /dev/null
+++ b/utils.py
@@ -0,0 +1,14 @@
+# -*- coding: utf-8 -*-
+"""Utility functions."""
+import datetime
+
+
+def timestamp_field_to_datetime(json, fieldname):
+ """Convert field from timestamp to datetime for json.
+
+ Currently hardcoded to MST timezone
+ """
+ timestamp = json[fieldname]
+ mst_hours = datetime.timedelta(hours=7)
+ json[fieldname] = datetime.datetime.fromtimestamp(timestamp) + mst_hours
+ return json