aboutsummaryrefslogtreecommitdiff
path: root/utils.py
diff options
context:
space:
mode:
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