Files
zulip/zephyr/lib/timestamp.py
Tim Abbott 761b7cd5fa Rename zephyr.lib.time to zephyr.lib.timestamp.
Otherwise one gets:

AttributeError: 'module' object has no attribute 'time'

when trying to use the time module from inside zephyr.lib.

(imported from commit 645368672a3eff68320278dd480edeed56721fcc)
2013-01-11 15:58:19 -05:00

10 lines
294 B
Python

import datetime
import calendar
from django.utils.timezone import utc
def timestamp_to_datetime(timestamp):
return datetime.datetime.utcfromtimestamp(float(timestamp)).replace(tzinfo=utc)
def datetime_to_timestamp(datetime_object):
return calendar.timegm(datetime_object.timetuple())